Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[contrib][linux] Add zstd_common module #3292

Merged
merged 2 commits into from
Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion contrib/linux-kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ libzstd:
-DZSTD_HAVE_WEAK_SYMBOLS=0 \
-DZSTD_TRACE=0 \
-DZSTD_NO_TRACE \
-DZSTD_DISABLE_ASM \
-DZSTD_LINUX_KERNEL
rm linux/lib/zstd/decompress/huf_decompress_amd64.S
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 Expand Up @@ -102,4 +105,5 @@ test: libzstd

.PHONY: clean
clean:
$(RM) -rf linux test/test test/static_test
$(RM) -rf linux
$(MAKE) -C test clean
20 changes: 8 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,15 @@ zstd_compress-y := \

zstd_decompress-y := \
zstd_decompress_module.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 \
1 change: 1 addition & 0 deletions contrib/linux-kernel/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ clean:
$(RM) -f $(LINUX_ZSTDLIB)/*.o
$(RM) -f $(LINUX_ZSTDLIB)/**/*.o
$(RM) -f *.o *.a
$(RM) -f static_test
$(RM) -f test
2 changes: 2 additions & 0 deletions contrib/linux-kernel/test/include/linux/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
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");