From: Carl Woffenden Date: Tue, 7 Apr 2020 16:17:59 +0000 (+0200) Subject: Fixed clash when projects are already using xxHash X-Git-Tag: v1.4.5^2~66^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2065%2Fhead;p=thirdparty%2Fzstd.git Fixed clash when projects are already using xxHash Undefing XXH_* macros allows the `.c` to build standalone without clashes. Removing `xxhash.c` and only including the header is the correct usage (according to `XXH_PRIVATE_API`). --- diff --git a/contrib/single_file_libs/zstd-in.c b/contrib/single_file_libs/zstd-in.c index afbab9990..c35512264 100644 --- a/contrib/single_file_libs/zstd-in.c +++ b/contrib/single_file_libs/zstd-in.c @@ -1,7 +1,7 @@ /** * \file zstd.c * Single-file Zstandard library. - * + * * Generate using: * \code * combine.sh -r ../../lib -r ../../lib/common -r ../../lib/compress -r ../../lib/decompress -k zstd.h -o zstd.c zstd-in.c @@ -18,19 +18,25 @@ */ /* * Settings to bake for the single library file. - * + * * Note: It's important that none of these affects 'zstd.h' (only the * implementation files we're amalgamating). - * + * * Note: MEM_MODULE stops xxhash redefining BYTE, U16, etc., which are also * defined in mem.h (breaking C99 compatibility). - * + * + * Note: the undefs for xxHash allow Zstd's implementation to coinside with with + * standalone xxHash usage (with global defines). + * * Note: multithreading is enabled for all platforms apart from Emscripten. */ #define DEBUGLEVEL 0 #define MEM_MODULE +#undef XXH_NAMESPACE #define XXH_NAMESPACE ZSTD_ +#undef XXH_PRIVATE_API #define XXH_PRIVATE_API +#undef XXH_INLINE_ALL #define XXH_INLINE_ALL #define ZSTD_LEGACY_SUPPORT 0 #define ZSTD_LIB_DICTBUILDER 0 @@ -40,17 +46,16 @@ #define ZSTD_MULTITHREAD #endif -/* common */ +/* lib/common */ #include "debug.c" #include "entropy_common.c" #include "error_private.c" #include "fse_decompress.c" #include "threading.c" #include "pool.c" -#include "xxhash.c" #include "zstd_common.c" -/* compress */ +/* lib/compress */ #include "fse_compress.c" #include "hist.c" #include "huf_compress.c" @@ -67,7 +72,7 @@ #include "zstdmt_compress.c" #endif -/* decompress */ +/* lib/decompress */ #include "huf_decompress.c" #include "zstd_ddict.c" #include "zstd_decompress.c" diff --git a/contrib/single_file_libs/zstddeclib-in.c b/contrib/single_file_libs/zstddeclib-in.c index eb88af365..c447bc25c 100755 --- a/contrib/single_file_libs/zstddeclib-in.c +++ b/contrib/single_file_libs/zstddeclib-in.c @@ -1,7 +1,7 @@ /** * \file zstddeclib.c * Single-file Zstandard decompressor. - * + * * Generate using: * \code * combine.sh -r ../../lib -r ../../lib/common -r ../../lib/decompress -o zstddeclib.c zstddeclib-in.c @@ -18,17 +18,23 @@ */ /* * Settings to bake for the standalone decompressor. - * + * * Note: It's important that none of these affects 'zstd.h' (only the * implementation files we're amalgamating). - * + * * Note: MEM_MODULE stops xxhash redefining BYTE, U16, etc., which are also * defined in mem.h (breaking C99 compatibility). + * + * Note: the undefs for xxHash allow Zstd's implementation to coinside with with + * standalone xxHash usage (with global defines). */ #define DEBUGLEVEL 0 #define MEM_MODULE +#undef XXH_NAMESPACE #define XXH_NAMESPACE ZSTD_ +#undef XXH_PRIVATE_API #define XXH_PRIVATE_API +#undef XXH_INLINE_ALL #define XXH_INLINE_ALL #define ZSTD_LEGACY_SUPPORT 0 #define ZSTD_LIB_COMPRESSION 0 @@ -36,15 +42,14 @@ #define ZSTD_NOBENCH #define ZSTD_STRIP_ERROR_STRINGS -/* common */ +/* lib/common */ #include "debug.c" #include "entropy_common.c" #include "error_private.c" #include "fse_decompress.c" -#include "xxhash.c" #include "zstd_common.c" -/* decompress */ +/* lib/decompress */ #include "huf_decompress.c" #include "zstd_ddict.c" #include "zstd_decompress.c"