]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fixed clash when projects are already using xxHash 2065/head
authorCarl Woffenden <cwoffenden@gmail.com>
Tue, 7 Apr 2020 16:17:59 +0000 (18:17 +0200)
committerCarl Woffenden <cwoffenden@gmail.com>
Tue, 7 Apr 2020 16:17:59 +0000 (18:17 +0200)
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`).

contrib/single_file_libs/zstd-in.c
contrib/single_file_libs/zstddeclib-in.c

index afbab99908d4509860f0745cd3ccdaafba6e91fb..c3551226411358987c274ade398b249a49a806e3 100644 (file)
@@ -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
  */
 /*
  * 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
 #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"
index eb88af3652107036824d374bf13606ef43921fd8..c447bc25ca308ef0c7475600ca8404da121245f0 100755 (executable)
@@ -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
  */
 /*
  * 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
 #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"