Skip to content

Commit

Permalink
[contrib][linux] Add zstd_common module
Browse files Browse the repository at this point in the history
The zstd_common module was added upstream in commit
torvalds/linux@637a642.

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.
  • Loading branch information
terrelln committed Oct 17, 2022
1 parent e0df910 commit d4f5eb4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
1 change: 1 addition & 0 deletions contrib/linux-kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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
Expand Down
21 changes: 9 additions & 12 deletions contrib/linux-kernel/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@
# ################################################################
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 \
Expand All @@ -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 \
32 changes: 32 additions & 0 deletions contrib/linux-kernel/zstd_common_module.c
Original file line number Diff line number Diff line change
@@ -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");

0 comments on commit d4f5eb4

Please sign in to comment.