]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[contrib][linux] Add zstd_common module
authorNick Terrell <terrelln@fb.com>
Mon, 17 Oct 2022 20:07:41 +0000 (13:07 -0700)
committerNick Terrell <nickrterrell@gmail.com>
Sat, 22 Oct 2022 00:14:31 +0000 (17:14 -0700)
The zstd_common module was added upstream in commit
https://github.com/torvalds/linux/commit/637a642f5ca5e850186bb64ac75ebb0f124b458d.

But the kernel specific code was inlined into the library. This commit
switches it to use the out of line method that we use for the other
modules.

contrib/linux-kernel/Makefile
contrib/linux-kernel/linux.mk
contrib/linux-kernel/test/include/linux/module.h
contrib/linux-kernel/zstd_common_module.c [new file with mode: 0644]

index 38aa6f4f4a0296a89b980e17b227127dd82a3463..d54ed4c0738f7bea1b5e56c960965ae98e45c240 100644 (file)
@@ -60,6 +60,7 @@ libzstd:
        mv linux/lib/zstd/zstd.h linux/include/linux/zstd_lib.h
        mv linux/lib/zstd/zstd_errors.h linux/include/linux/
        cp linux_zstd.h linux/include/linux/zstd.h
+       cp zstd_common_module.c linux/lib/zstd
        cp zstd_compress_module.c linux/lib/zstd
        cp zstd_decompress_module.c linux/lib/zstd
        cp decompress_sources.h linux/lib/zstd
index f6f3a8983d8145bc2ce2054668eadd4f16d00db3..00068d2d8e21408e03044543dee8ff8093fdeae9 100644 (file)
 # ################################################################
 obj-$(CONFIG_ZSTD_COMPRESS) += zstd_compress.o
 obj-$(CONFIG_ZSTD_DECOMPRESS) += zstd_decompress.o
-
-ccflags-y += -Wno-error=deprecated-declarations
+obj-$(CONFIG_ZSTD_COMMON) += zstd_common.o
 
 zstd_compress-y := \
                zstd_compress_module.o \
-               common/debug.o \
-               common/entropy_common.o \
-               common/error_private.o \
-               common/fse_decompress.o \
-               common/zstd_common.o \
                compress/fse_compress.o \
                compress/hist.o \
                compress/huf_compress.o \
@@ -35,13 +29,16 @@ zstd_compress-y := \
 
 zstd_decompress-y := \
                zstd_decompress_module.o \
+               decompress/huf_decompress_amd64.o \
+               decompress/huf_decompress.o \
+               decompress/zstd_ddict.o \
+               decompress/zstd_decompress.o \
+               decompress/zstd_decompress_block.o \
+
+zstd_common-y := \
+               zstd_common_module.o \
                common/debug.o \
                common/entropy_common.o \
                common/error_private.o \
                common/fse_decompress.o \
                common/zstd_common.o \
-               decompress/huf_decompress.o \
-               decompress/huf_decompress_amd64.o \
-               decompress/zstd_ddict.o \
-               decompress/zstd_decompress.o \
-               decompress/zstd_decompress_block.o \
index be6d20daea26e5a16fd3cf504b035bb7b01dfe41..63a28d57b269f702ffb400964443415383d76519 100644 (file)
@@ -12,6 +12,8 @@
 
 #define EXPORT_SYMBOL(symbol)                                                  \
   void* __##symbol = symbol
+#define EXPORT_SYMBOL_GPL(symbol)                                              \
+  void* __##symbol = symbol
 #define MODULE_LICENSE(license)
 #define MODULE_DESCRIPTION(description)
 
diff --git a/contrib/linux-kernel/zstd_common_module.c b/contrib/linux-kernel/zstd_common_module.c
new file mode 100644 (file)
index 0000000..22686e3
--- /dev/null
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (c) Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#include <linux/module.h>
+
+#include "common/huf.h"
+#include "common/fse.h"
+#include "common/zstd_internal.h"
+
+// Export symbols shared by compress and decompress into a common module
+
+#undef ZSTD_isError   /* defined within zstd_internal.h */
+EXPORT_SYMBOL_GPL(FSE_readNCount);
+EXPORT_SYMBOL_GPL(HUF_readStats);
+EXPORT_SYMBOL_GPL(HUF_readStats_wksp);
+EXPORT_SYMBOL_GPL(ZSTD_isError);
+EXPORT_SYMBOL_GPL(ZSTD_getErrorName);
+EXPORT_SYMBOL_GPL(ZSTD_getErrorCode);
+EXPORT_SYMBOL_GPL(ZSTD_customMalloc);
+EXPORT_SYMBOL_GPL(ZSTD_customCalloc);
+EXPORT_SYMBOL_GPL(ZSTD_customFree);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_DESCRIPTION("Zstd Common");