Skip to content

Commit 4782c72

Browse files
committed
zstd: Move zstd-common module exports to zstd_common_module.c
The zstd codebase is imported from the upstream zstd repo, and is over-written on every update. Upstream keeps the kernel specific code separate from the main library. So the module definition is moved into the zstd_common_module.c file. This matches the pattern followed by the zstd-compress and zstd-decompress files. I've done build and boot testing on x86-64, i386, and aarch64. I've verified that zstd built both as modules and built-in build and boot. Signed-off-by: Nick Terrell <[email protected]>
1 parent 19d7df9 commit 4782c72

File tree

4 files changed

+33
-14
lines changed

4 files changed

+33
-14
lines changed

lib/zstd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ zstd_decompress-y := \
3535
decompress/zstd_decompress_block.o \
3636

3737
zstd_common-y := \
38+
zstd_common_module.o \
3839
common/debug.o \
3940
common/entropy_common.o \
4041
common/error_private.o \

lib/zstd/common/entropy_common.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
/* *************************************
1616
* Dependencies
1717
***************************************/
18-
#include <linux/module.h>
1918
#include "mem.h"
2019
#include "error_private.h" /* ERR_*, ERROR */
2120
#define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
@@ -240,7 +239,6 @@ size_t FSE_readNCount(
240239
{
241240
return FSE_readNCount_bmi2(normalizedCounter, maxSVPtr, tableLogPtr, headerBuffer, hbSize, /* bmi2 */ 0);
242241
}
243-
EXPORT_SYMBOL_GPL(FSE_readNCount);
244242

245243
/*! HUF_readStats() :
246244
Read compact Huffman tree, saved by HUF_writeCTable().
@@ -256,7 +254,6 @@ size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
256254
U32 wksp[HUF_READ_STATS_WORKSPACE_SIZE_U32];
257255
return HUF_readStats_wksp(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, wksp, sizeof(wksp), /* bmi2 */ 0);
258256
}
259-
EXPORT_SYMBOL_GPL(HUF_readStats);
260257

261258
FORCE_INLINE_TEMPLATE size_t
262259
HUF_readStats_body(BYTE* huffWeight, size_t hwSize, U32* rankStats,
@@ -357,4 +354,3 @@ size_t HUF_readStats_wksp(BYTE* huffWeight, size_t hwSize, U32* rankStats,
357354
(void)bmi2;
358355
return HUF_readStats_body_default(huffWeight, hwSize, rankStats, nbSymbolsPtr, tableLogPtr, src, srcSize, workSpace, wkspSize);
359356
}
360-
EXPORT_SYMBOL_GPL(HUF_readStats_wksp);

lib/zstd/common/zstd_common.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
/*-*************************************
1414
* Dependencies
1515
***************************************/
16-
#include <linux/module.h>
1716
#define ZSTD_DEPS_NEED_MALLOC
1817
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
1918
#include "error_private.h"
@@ -36,17 +35,14 @@ const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
3635
* tells if a return value is an error code
3736
* symbol is required for external callers */
3837
unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
39-
EXPORT_SYMBOL_GPL(ZSTD_isError);
4038

4139
/*! ZSTD_getErrorName() :
4240
* provides error code string from function result (useful for debugging) */
4341
const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
44-
EXPORT_SYMBOL_GPL(ZSTD_getErrorName);
4542

4643
/*! ZSTD_getError() :
4744
* convert a `size_t` function result into a proper ZSTD_errorCode enum */
4845
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
49-
EXPORT_SYMBOL_GPL(ZSTD_getErrorCode);
5046

5147
/*! ZSTD_getErrorString() :
5248
* provides error code string from enum */
@@ -63,7 +59,6 @@ void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
6359
return customMem.customAlloc(customMem.opaque, size);
6460
return ZSTD_malloc(size);
6561
}
66-
EXPORT_SYMBOL_GPL(ZSTD_customMalloc);
6762

6863
void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
6964
{
@@ -76,7 +71,6 @@ void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
7671
}
7772
return ZSTD_calloc(1, size);
7873
}
79-
EXPORT_SYMBOL_GPL(ZSTD_customCalloc);
8074

8175
void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
8276
{
@@ -87,7 +81,3 @@ void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
8781
ZSTD_free(ptr);
8882
}
8983
}
90-
EXPORT_SYMBOL_GPL(ZSTD_customFree);
91-
92-
MODULE_LICENSE("Dual BSD/GPL");
93-
MODULE_DESCRIPTION("Zstd Common");

lib/zstd/zstd_common_module.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2+
/*
3+
* Copyright (c) Facebook, Inc.
4+
* All rights reserved.
5+
*
6+
* This source code is licensed under both the BSD-style license (found in the
7+
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
8+
* in the COPYING file in the root directory of this source tree).
9+
* You may select, at your option, one of the above-listed licenses.
10+
*/
11+
12+
#include <linux/module.h>
13+
14+
#include "common/huf.h"
15+
#include "common/fse.h"
16+
#include "common/zstd_internal.h"
17+
18+
// Export symbols shared by compress and decompress into a common module
19+
20+
#undef ZSTD_isError /* defined within zstd_internal.h */
21+
EXPORT_SYMBOL_GPL(FSE_readNCount);
22+
EXPORT_SYMBOL_GPL(HUF_readStats);
23+
EXPORT_SYMBOL_GPL(HUF_readStats_wksp);
24+
EXPORT_SYMBOL_GPL(ZSTD_isError);
25+
EXPORT_SYMBOL_GPL(ZSTD_getErrorName);
26+
EXPORT_SYMBOL_GPL(ZSTD_getErrorCode);
27+
EXPORT_SYMBOL_GPL(ZSTD_customMalloc);
28+
EXPORT_SYMBOL_GPL(ZSTD_customCalloc);
29+
EXPORT_SYMBOL_GPL(ZSTD_customFree);
30+
31+
MODULE_LICENSE("Dual BSD/GPL");
32+
MODULE_DESCRIPTION("Zstd Common");

0 commit comments

Comments
 (0)