From fc726da7747b159520de2edb0febab30342d2744 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Tue, 17 Dec 2024 17:55:07 -0800 Subject: [PATCH 01/15] Move #includes out of `extern "C"` blocks Do some include shuffling for `**.h` files within lib, programs, tests, and zlibWrapper. `lib/legacy` and `lib/deprecated` are untouched. `#include`s within `extern "C"` blocks in .cpp files are untouched. todo: shuffling for `xxhash.h` --- contrib/seekable_format/zstd_seekable.h | 6 +++--- lib/common/bitstream.h | 8 ++++---- lib/common/debug.h | 9 ++++----- lib/common/error_private.h | 8 +++----- lib/common/fse.h | 16 +++++++-------- lib/common/huf.h | 7 +++---- lib/common/mem.h | 8 ++++---- lib/common/pool.h | 8 ++++---- lib/common/threading.h | 27 +++++++++++++++++++++---- lib/common/zstd_trace.h | 4 ++-- lib/compress/zstd_double_fast.h | 6 +++--- lib/compress/zstd_fast.h | 6 +++--- lib/compress/zstd_lazy.h | 4 ++-- lib/compress/zstd_ldm.h | 6 +++--- lib/compress/zstd_opt.h | 4 ++-- lib/compress/zstdmt_compress.h | 11 +++++----- lib/zdict.h | 8 ++++---- lib/zstd.h | 15 ++++++++------ programs/benchfn.h | 8 ++++---- programs/benchzstd.h | 8 ++++---- programs/fileio_asyncio.h | 8 ++++---- programs/fileio_common.h | 16 ++++++++++----- programs/platform.h | 21 +++++++++---------- programs/timefn.h | 11 +++++----- programs/util.c | 9 --------- programs/util.h | 4 +++- zlibWrapper/zstd_zlibwrapper.h | 10 ++++----- 27 files changed, 135 insertions(+), 121 deletions(-) diff --git a/contrib/seekable_format/zstd_seekable.h b/contrib/seekable_format/zstd_seekable.h index a0e5e3573d0..b1f83d0e0a1 100644 --- a/contrib/seekable_format/zstd_seekable.h +++ b/contrib/seekable_format/zstd_seekable.h @@ -1,13 +1,13 @@ #ifndef SEEKABLE_H #define SEEKABLE_H +#include +#include "zstd.h" /* ZSTDLIB_API */ + #if defined (__cplusplus) extern "C" { #endif -#include -#include "zstd.h" /* ZSTDLIB_API */ - #define ZSTD_seekTableFooterSize 9 diff --git a/lib/common/bitstream.h b/lib/common/bitstream.h index 676044989c9..bce91e8018c 100644 --- a/lib/common/bitstream.h +++ b/lib/common/bitstream.h @@ -14,9 +14,6 @@ #ifndef BITSTREAM_H_MODULE #define BITSTREAM_H_MODULE -#if defined (__cplusplus) -extern "C" { -#endif /* * This API consists of small unitary functions, which must be inlined for best performance. * Since link-time-optimization is not available for all compilers, @@ -32,7 +29,6 @@ extern "C" { #include "error_private.h" /* error codes and messages */ #include "bits.h" /* ZSTD_highbit32 */ - /*========================================= * Target specific =========================================*/ @@ -44,6 +40,10 @@ extern "C" { # endif #endif +#if defined (__cplusplus) +extern "C" { +#endif + #define STREAM_ACCUMULATOR_MIN_32 25 #define STREAM_ACCUMULATOR_MIN_64 57 #define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64)) diff --git a/lib/common/debug.h b/lib/common/debug.h index a16b69e5743..8ef37a9087a 100644 --- a/lib/common/debug.h +++ b/lib/common/debug.h @@ -32,10 +32,6 @@ #ifndef DEBUG_H_12987983217 #define DEBUG_H_12987983217 -#if defined (__cplusplus) -extern "C" { -#endif - /* static assert is triggered at compile time, leaving no runtime artefact. * static assert only works with compile-time constants. @@ -75,9 +71,12 @@ extern "C" { # endif #endif +#if defined (__cplusplus) +extern "C" { +#endif + #if (DEBUGLEVEL>=2) # define ZSTD_DEPS_NEED_IO -# include "zstd_deps.h" extern int g_debuglevel; /* the variable is only declared, it actually lives in debug.c, and is shared by the whole process. diff --git a/lib/common/error_private.h b/lib/common/error_private.h index 0156010c745..06233aaa8eb 100644 --- a/lib/common/error_private.h +++ b/lib/common/error_private.h @@ -13,11 +13,6 @@ #ifndef ERROR_H_MODULE #define ERROR_H_MODULE -#if defined (__cplusplus) -extern "C" { -#endif - - /* **************************************** * Dependencies ******************************************/ @@ -26,6 +21,9 @@ extern "C" { #include "debug.h" #include "zstd_deps.h" /* size_t */ +#if defined (__cplusplus) +extern "C" { +#endif /* **************************************** * Compiler-specific diff --git a/lib/common/fse.h b/lib/common/fse.h index 2ae128e60db..4c41b06ef2d 100644 --- a/lib/common/fse.h +++ b/lib/common/fse.h @@ -11,11 +11,6 @@ * in the COPYING file in the root directory of this source tree). * You may select, at your option, one of the above-listed licenses. ****************************************************************** */ - -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef FSE_H #define FSE_H @@ -25,6 +20,14 @@ extern "C" { ******************************************/ #include "zstd_deps.h" /* size_t, ptrdiff_t */ +#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY) +#define FSE_H_FSE_STATIC_LINKING_ONLY +#include "bitstream.h" +#endif + +#if defined (__cplusplus) +extern "C" { +#endif /*-***************************************** * FSE_PUBLIC_API : control library symbols visibility @@ -233,9 +236,6 @@ If there is an error, the function will return an error code, which can be teste #if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY) #define FSE_H_FSE_STATIC_LINKING_ONLY -/* *** Dependency *** */ -#include "bitstream.h" - /* ***************************************** * Static allocation diff --git a/lib/common/huf.h b/lib/common/huf.h index 99bf85d6f4e..bfcec4a8127 100644 --- a/lib/common/huf.h +++ b/lib/common/huf.h @@ -12,10 +12,6 @@ * You may select, at your option, one of the above-listed licenses. ****************************************************************** */ -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef HUF_H_298734234 #define HUF_H_298734234 @@ -25,6 +21,9 @@ extern "C" { #define FSE_STATIC_LINKING_ONLY #include "fse.h" +#if defined (__cplusplus) +extern "C" { +#endif /* *** Tool functions *** */ #define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */ diff --git a/lib/common/mem.h b/lib/common/mem.h index a02141c9d49..1b0a946ad15 100644 --- a/lib/common/mem.h +++ b/lib/common/mem.h @@ -11,10 +11,6 @@ #ifndef MEM_H_MODULE #define MEM_H_MODULE -#if defined (__cplusplus) -extern "C" { -#endif - /*-**************************************** * Dependencies ******************************************/ @@ -77,6 +73,10 @@ extern "C" { #endif +#if defined (__cplusplus) +extern "C" { +#endif + /*-************************************************************** * Memory I/O API *****************************************************************/ diff --git a/lib/common/pool.h b/lib/common/pool.h index cca4de73a83..d34082dc1fc 100644 --- a/lib/common/pool.h +++ b/lib/common/pool.h @@ -11,15 +11,15 @@ #ifndef POOL_H #define POOL_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "zstd_deps.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */ #include "../zstd.h" +#if defined (__cplusplus) +extern "C" { +#endif + typedef struct POOL_ctx_s POOL_ctx; /*! POOL_create() : diff --git a/lib/common/threading.h b/lib/common/threading.h index fb5c1c87873..25448548d09 100644 --- a/lib/common/threading.h +++ b/lib/common/threading.h @@ -16,10 +16,6 @@ #include "debug.h" -#if defined (__cplusplus) -extern "C" { -#endif - #if defined(ZSTD_MULTITHREAD) && defined(_WIN32) /** @@ -60,6 +56,11 @@ extern "C" { #define ZSTD_pthread_cond_signal(a) WakeConditionVariable((a)) #define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a)) + +#if defined (__cplusplus) +extern "C" { +#endif + /* ZSTD_pthread_create() and ZSTD_pthread_join() */ typedef HANDLE ZSTD_pthread_t; @@ -73,10 +74,19 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread); */ +#if defined (__cplusplus) +} +#endif + #elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */ /* === POSIX Systems === */ # include + +#if defined (__cplusplus) +extern "C" { +#endif + #if DEBUGLEVEL < 1 #define ZSTD_pthread_mutex_t pthread_mutex_t @@ -123,9 +133,18 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond); #endif +#if defined (__cplusplus) +} +#endif + #else /* ZSTD_MULTITHREAD not defined */ /* No multithreading support */ + +#if defined (__cplusplus) +extern "C" { +#endif + typedef int ZSTD_pthread_mutex_t; #define ZSTD_pthread_mutex_init(a, b) ((void)(a), (void)(b), 0) #define ZSTD_pthread_mutex_destroy(a) ((void)(a)) diff --git a/lib/common/zstd_trace.h b/lib/common/zstd_trace.h index 173d63fb1bc..b9187079c5d 100644 --- a/lib/common/zstd_trace.h +++ b/lib/common/zstd_trace.h @@ -11,12 +11,12 @@ #ifndef ZSTD_TRACE_H #define ZSTD_TRACE_H +#include + #if defined (__cplusplus) extern "C" { #endif -#include - /* weak symbol support * For now, enable conservatively: * - Only GNUC diff --git a/lib/compress/zstd_double_fast.h b/lib/compress/zstd_double_fast.h index ce6ed8c97fd..ae66f314279 100644 --- a/lib/compress/zstd_double_fast.h +++ b/lib/compress/zstd_double_fast.h @@ -11,13 +11,13 @@ #ifndef ZSTD_DOUBLE_FAST_H #define ZSTD_DOUBLE_FAST_H +#include "../common/mem.h" /* U32 */ +#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ + #if defined (__cplusplus) extern "C" { #endif -#include "../common/mem.h" /* U32 */ -#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ - #ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms, diff --git a/lib/compress/zstd_fast.h b/lib/compress/zstd_fast.h index 9e4236b4728..f92cf35b961 100644 --- a/lib/compress/zstd_fast.h +++ b/lib/compress/zstd_fast.h @@ -11,13 +11,13 @@ #ifndef ZSTD_FAST_H #define ZSTD_FAST_H +#include "../common/mem.h" /* U32 */ +#include "zstd_compress_internal.h" + #if defined (__cplusplus) extern "C" { #endif -#include "../common/mem.h" /* U32 */ -#include "zstd_compress_internal.h" - void ZSTD_fillHashTable(ZSTD_matchState_t* ms, void const* end, ZSTD_dictTableLoadMethod_e dtlm, ZSTD_tableFillPurpose_e tfp); diff --git a/lib/compress/zstd_lazy.h b/lib/compress/zstd_lazy.h index 3635813bddf..bec17b1247e 100644 --- a/lib/compress/zstd_lazy.h +++ b/lib/compress/zstd_lazy.h @@ -11,12 +11,12 @@ #ifndef ZSTD_LAZY_H #define ZSTD_LAZY_H +#include "zstd_compress_internal.h" + #if defined (__cplusplus) extern "C" { #endif -#include "zstd_compress_internal.h" - /** * Dedicated Dictionary Search Structure bucket log. In the * ZSTD_dedicatedDictSearch mode, the hashTable has diff --git a/lib/compress/zstd_ldm.h b/lib/compress/zstd_ldm.h index f147021d296..847c2befb1e 100644 --- a/lib/compress/zstd_ldm.h +++ b/lib/compress/zstd_ldm.h @@ -11,13 +11,13 @@ #ifndef ZSTD_LDM_H #define ZSTD_LDM_H +#include "zstd_compress_internal.h" /* ldmParams_t, U32 */ +#include "../zstd.h" /* ZSTD_CCtx, size_t */ + #if defined (__cplusplus) extern "C" { #endif -#include "zstd_compress_internal.h" /* ldmParams_t, U32 */ -#include "../zstd.h" /* ZSTD_CCtx, size_t */ - /*-************************************* * Long distance matching ***************************************/ diff --git a/lib/compress/zstd_opt.h b/lib/compress/zstd_opt.h index d4e71131572..7ce6fdae7b1 100644 --- a/lib/compress/zstd_opt.h +++ b/lib/compress/zstd_opt.h @@ -11,12 +11,12 @@ #ifndef ZSTD_OPT_H #define ZSTD_OPT_H +#include "zstd_compress_internal.h" + #if defined (__cplusplus) extern "C" { #endif -#include "zstd_compress_internal.h" - #if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR) diff --git a/lib/compress/zstdmt_compress.h b/lib/compress/zstdmt_compress.h index ed4dc0e99df..9a58b5ad30d 100644 --- a/lib/compress/zstdmt_compress.h +++ b/lib/compress/zstdmt_compress.h @@ -11,6 +11,11 @@ #ifndef ZSTDMT_COMPRESS_H #define ZSTDMT_COMPRESS_H +/* === Dependencies === */ +#include "../common/zstd_deps.h" /* size_t */ +#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */ +#include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */ + #if defined (__cplusplus) extern "C" { #endif @@ -25,12 +30,6 @@ * otherwise ZSTDMT_createCCtx*() will fail. */ -/* === Dependencies === */ -#include "../common/zstd_deps.h" /* size_t */ -#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */ -#include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */ - - /* === Constants === */ #ifndef ZSTDMT_NBWORKERS_MAX /* a different value can be selected at compile time */ # define ZSTDMT_NBWORKERS_MAX ((sizeof(void*)==4) /*32-bit*/ ? 64 : 256) diff --git a/lib/zdict.h b/lib/zdict.h index bcccf750e64..340a9a24e8b 100644 --- a/lib/zdict.h +++ b/lib/zdict.h @@ -8,16 +8,16 @@ * You may select, at your option, one of the above-listed licenses. */ -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef ZSTD_ZDICT_H #define ZSTD_ZDICT_H + /*====== Dependencies ======*/ #include /* size_t */ +#if defined (__cplusplus) +extern "C" { +#endif /* ===== ZDICTLIB_API : control library symbols visibility ===== */ #ifndef ZDICTLIB_VISIBLE diff --git a/lib/zstd.h b/lib/zstd.h index a78b6db45c6..7571f806991 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -7,16 +7,22 @@ * in the COPYING file in the root directory of this source tree). * You may select, at your option, one of the above-listed licenses. */ -#if defined (__cplusplus) -extern "C" { -#endif #ifndef ZSTD_H_235446 #define ZSTD_H_235446 + /* ====== Dependencies ======*/ #include /* size_t */ +#include "zstd_errors.h" /* list of errors */ +#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) +#include /* INT_MAX */ +#endif /* ZSTD_STATIC_LINKING_ONLY */ + +#if defined (__cplusplus) +extern "C" { +#endif /* ===== ZSTDLIB_API : control library symbols visibility ===== */ #ifndef ZSTDLIB_VISIBLE @@ -240,7 +246,6 @@ ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed s /*====== Error helper functions ======*/ -#include "zstd_errors.h" /* list of errors */ /* ZSTD_isError() : * Most ZSTD_* functions returning a size_t value can be tested for error, * using ZSTD_isError(). @@ -1215,8 +1220,6 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY -#include /* INT_MAX */ - /* This can be overridden externally to hide static symbols. */ #ifndef ZSTDLIB_STATIC_API # if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) diff --git a/programs/benchfn.h b/programs/benchfn.h index 1bd93d13519..3ba3a4f5504 100644 --- a/programs/benchfn.h +++ b/programs/benchfn.h @@ -15,10 +15,6 @@ * or detecting and returning an error */ -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef BENCH_FN_H_23876 #define BENCH_FN_H_23876 @@ -26,6 +22,10 @@ extern "C" { #include /* size_t */ +#if defined (__cplusplus) +extern "C" { +#endif + /* ==== Benchmark any function, iterated on a set of blocks ==== */ /* BMK_runTime_t: valid result return type */ diff --git a/programs/benchzstd.h b/programs/benchzstd.h index 6388d4d58c3..7ea018b12f1 100644 --- a/programs/benchzstd.h +++ b/programs/benchzstd.h @@ -14,10 +14,6 @@ * and display progress result and final summary */ -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef BENCH_ZSTD_H_3242387 #define BENCH_ZSTD_H_3242387 @@ -27,6 +23,10 @@ extern "C" { #include "../lib/zstd.h" /* ZSTD_compressionParameters */ +#if defined (__cplusplus) +extern "C" { +#endif + /* === Constants === */ #define MB_UNIT 1000000 diff --git a/programs/fileio_asyncio.h b/programs/fileio_asyncio.h index feb25a3f9e9..1c30a73da89 100644 --- a/programs/fileio_asyncio.h +++ b/programs/fileio_asyncio.h @@ -22,10 +22,6 @@ #ifndef ZSTD_FILEIO_ASYNCIO_H #define ZSTD_FILEIO_ASYNCIO_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "../lib/common/mem.h" /* U32, U64 */ #include "fileio_types.h" #include "platform.h" @@ -35,6 +31,10 @@ extern "C" { #define MAX_IO_JOBS (10) +#if defined (__cplusplus) +extern "C" { +#endif + typedef struct { /* These struct fields should be set only on creation and not changed afterwards */ POOL_ctx* threadPool; diff --git a/programs/fileio_common.h b/programs/fileio_common.h index 7a014ee4bb1..87f99cda90d 100644 --- a/programs/fileio_common.h +++ b/programs/fileio_common.h @@ -11,15 +11,22 @@ #ifndef ZSTD_FILEIO_COMMON_H #define ZSTD_FILEIO_COMMON_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "../lib/common/mem.h" /* U32, U64 */ #include "fileio_types.h" #include "platform.h" #include "timefn.h" /* UTIL_getTime, UTIL_clockSpanMicro */ +#if !(defined(_MSC_VER) && _MSC_VER >= 1400) \ + && !(!defined(__64BIT__) && (PLATFORM_POSIX_VERSION >= 200112L)) \ + && !(defined(__MINGW32__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) && defined(__MSVCRT__)) \ + && (defined(_WIN32) && !defined(__DJGPP__)) +# include +#endif + +#if defined (__cplusplus) +extern "C" { +#endif + /*-************************************* * Macros ***************************************/ @@ -89,7 +96,6 @@ extern UTIL_time_t g_displayClock; # define LONG_SEEK fseeko64 # define LONG_TELL ftello64 #elif defined(_WIN32) && !defined(__DJGPP__) -# include static int LONG_SEEK(FILE* file, __int64 offset, int origin) { LARGE_INTEGER off; DWORD method; diff --git a/programs/platform.h b/programs/platform.h index 4d2b9490e6d..05a26a564f4 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -11,12 +11,6 @@ #ifndef PLATFORM_H_MODULE #define PLATFORM_H_MODULE -#if defined (__cplusplus) -extern "C" { -#endif - - - /* ************************************** * Compiler Options ****************************************/ @@ -144,10 +138,20 @@ extern "C" { # include /* _isatty */ # include /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */ # include /* FILE */ + +#if defined (__cplusplus) +extern "C" { +#endif + static __inline int IS_CONSOLE(FILE* stdStream) { DWORD dummy; return _isatty(_fileno(stdStream)) && GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdStream)), &dummy); } + +#if defined (__cplusplus) +} +#endif + #else # define IS_CONSOLE(stdStream) 0 #endif @@ -210,9 +214,4 @@ static __inline int IS_CONSOLE(FILE* stdStream) { # endif #endif - -#if defined (__cplusplus) -} -#endif - #endif /* PLATFORM_H_MODULE */ diff --git a/programs/timefn.h b/programs/timefn.h index b814ff8d8da..dc7463be352 100644 --- a/programs/timefn.h +++ b/programs/timefn.h @@ -11,12 +11,6 @@ #ifndef TIME_FN_H_MODULE_287987 #define TIME_FN_H_MODULE_287987 -#if defined (__cplusplus) -extern "C" { -#endif - - - /*-**************************************** * Types ******************************************/ @@ -32,6 +26,11 @@ extern "C" { typedef unsigned long long PTime; /* does not support compilers without long long support */ #endif + +#if defined (__cplusplus) +extern "C" { +#endif + /* UTIL_time_t contains a nanosecond time counter. * The absolute value is not meaningful. * It's only valid to compute the difference between 2 measurements. */ diff --git a/programs/util.c b/programs/util.c index 7f65f93731f..065a35855f2 100644 --- a/programs/util.c +++ b/programs/util.c @@ -8,11 +8,6 @@ * You may select, at your option, one of the above-listed licenses. */ -#if defined (__cplusplus) -extern "C" { -#endif - - /*-**************************************** * Dependencies ******************************************/ @@ -1646,7 +1641,3 @@ int UTIL_countLogicalCores(void) { return UTIL_countCores(1); } - -#if defined (__cplusplus) -} -#endif diff --git a/programs/util.h b/programs/util.h index ec813968446..5868f5eae3e 100644 --- a/programs/util.h +++ b/programs/util.h @@ -20,6 +20,9 @@ #include /* stat, utime */ #include /* stat, chmod */ #include "../lib/common/mem.h" /* U64 */ +#if not (defined(_MSC_VER) || defined(__MINGW32__) || defined (__MSVCRT__)) +#include +#endif /*-************************************************************ * Fix fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW @@ -116,7 +119,6 @@ int UTIL_requireUserConfirmation(const char* prompt, const char* abortMsg, const #define STRDUP(s) _strdup(s) #else #define PATH_SEP '/' -#include #define STRDUP(s) strdup(s) #endif diff --git a/zlibWrapper/zstd_zlibwrapper.h b/zlibWrapper/zstd_zlibwrapper.h index 230bf8411b0..dae6787d3ad 100644 --- a/zlibWrapper/zstd_zlibwrapper.h +++ b/zlibWrapper/zstd_zlibwrapper.h @@ -11,11 +11,6 @@ #ifndef ZSTD_ZLIBWRAPPER_H #define ZSTD_ZLIBWRAPPER_H -#if defined (__cplusplus) -extern "C" { -#endif - - #define ZLIB_CONST #define Z_PREFIX #define ZLIB_INTERNAL /* disables gz*64 functions but fixes zlib 1.2.4 with Z_PREFIX */ @@ -29,6 +24,11 @@ extern "C" { #define _Z_OF OF #endif + +#if defined (__cplusplus) +extern "C" { +#endif + /* returns a string with version of zstd library */ const char * zstdVersion(void); From 5222dd87cff5533a83938d0e54b724f675266bf6 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Tue, 17 Dec 2024 18:11:58 -0800 Subject: [PATCH 02/15] Oopsie with fse.h --- lib/common/fse.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/common/fse.h b/lib/common/fse.h index 4c41b06ef2d..9f031f31fa0 100644 --- a/lib/common/fse.h +++ b/lib/common/fse.h @@ -20,11 +20,6 @@ ******************************************/ #include "zstd_deps.h" /* size_t, ptrdiff_t */ -#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY) -#define FSE_H_FSE_STATIC_LINKING_ONLY -#include "bitstream.h" -#endif - #if defined (__cplusplus) extern "C" { #endif @@ -230,12 +225,16 @@ FSE_decompress_usingDTable() result will tell how many bytes were regenerated (< If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small) */ +#if defined (__cplusplus) +} +#endif + #endif /* FSE_H */ #if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY) #define FSE_H_FSE_STATIC_LINKING_ONLY - +#include "bitstream.h" /* ***************************************** * Static allocation @@ -258,6 +257,10 @@ If there is an error, the function will return an error code, which can be teste * FSE advanced API ***************************************** */ +#if defined (__cplusplus) +extern "C" { +#endif + unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus); /**< same as FSE_optimalTableLog(), which used `minus==2` */ @@ -631,10 +634,8 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr) #define FSE_TABLESTEP(tableSize) (((tableSize)>>1) + ((tableSize)>>3) + 3) - -#endif /* FSE_STATIC_LINKING_ONLY */ - - #if defined (__cplusplus) } #endif + +#endif /* FSE_STATIC_LINKING_ONLY */ From ded4c1ec18bf39db0ce6b4263ddf6daac6712e94 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Tue, 17 Dec 2024 18:18:02 -0800 Subject: [PATCH 03/15] Oopsie with util.h --- programs/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/util.h b/programs/util.h index 5868f5eae3e..93d6c807f05 100644 --- a/programs/util.h +++ b/programs/util.h @@ -20,7 +20,7 @@ #include /* stat, utime */ #include /* stat, chmod */ #include "../lib/common/mem.h" /* U64 */ -#if not (defined(_MSC_VER) || defined(__MINGW32__) || defined (__MSVCRT__)) +#if !(defined(_MSC_VER) || defined(__MINGW32__) || defined (__MSVCRT__)) #include #endif From fa5bfb603065e0f426c3ede2b5e239a13b69ea22 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Tue, 17 Dec 2024 18:34:04 -0800 Subject: [PATCH 04/15] Oopsie with zstd.h --- lib/zstd.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/zstd.h b/lib/zstd.h index 7571f806991..1ae47c2b690 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -1205,6 +1205,10 @@ ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); +#if defined (__cplusplus) +} +#endif + #endif /* ZSTD_H_235446 */ @@ -1220,6 +1224,10 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); #if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) #define ZSTD_H_ZSTD_STATIC_LINKING_ONLY +#if defined (__cplusplus) +extern "C" { +#endif + /* This can be overridden externally to hide static symbols. */ #ifndef ZSTDLIB_STATIC_API # if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) @@ -3138,8 +3146,8 @@ ZSTDLIB_STATIC_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_ ZSTD_DEPRECATED("The block API is deprecated in favor of the normal compression API. See docs.") ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */ -#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ - #if defined (__cplusplus) } #endif + +#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ From 58a7f4b869e02e02ab7e119f20fca9ea631dd83d Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Tue, 17 Dec 2024 18:37:33 -0800 Subject: [PATCH 05/15] Oopsie with threading.h --- lib/common/threading.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/common/threading.h b/lib/common/threading.h index 25448548d09..85b6a3ac823 100644 --- a/lib/common/threading.h +++ b/lib/common/threading.h @@ -140,7 +140,6 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond); #else /* ZSTD_MULTITHREAD not defined */ /* No multithreading support */ - #if defined (__cplusplus) extern "C" { #endif @@ -160,10 +159,11 @@ typedef int ZSTD_pthread_cond_t; /* do not use ZSTD_pthread_t */ -#endif /* ZSTD_MULTITHREAD */ - #if defined (__cplusplus) } #endif +#endif /* ZSTD_MULTITHREAD */ + + #endif /* THREADING_H_938743 */ From 63acf9a9955302c9595d6eccf3e8813256dfe069 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Wed, 18 Dec 2024 09:56:50 -0800 Subject: [PATCH 06/15] Oopsie with huf.h, debug.h --- lib/common/debug.h | 10 +--------- lib/common/huf.h | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/common/debug.h b/lib/common/debug.h index 8ef37a9087a..4b60ddf7f51 100644 --- a/lib/common/debug.h +++ b/lib/common/debug.h @@ -71,12 +71,9 @@ # endif #endif -#if defined (__cplusplus) -extern "C" { -#endif - #if (DEBUGLEVEL>=2) # define ZSTD_DEPS_NEED_IO +# include "zstd_deps.h" extern int g_debuglevel; /* the variable is only declared, it actually lives in debug.c, and is shared by the whole process. @@ -107,9 +104,4 @@ extern int g_debuglevel; /* the variable is only declared, # define DEBUGLOG(l, ...) do { } while (0) /* disabled */ #endif - -#if defined (__cplusplus) -} -#endif - #endif /* DEBUG_H_12987983217 */ diff --git a/lib/common/huf.h b/lib/common/huf.h index bfcec4a8127..962fe43fa73 100644 --- a/lib/common/huf.h +++ b/lib/common/huf.h @@ -278,8 +278,8 @@ size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize, int flags); #endif -#endif /* HUF_H_298734234 */ - #if defined (__cplusplus) } #endif + +#endif /* HUF_H_298734234 */ From f25b9f11ba1df6e2a5bfe7e73e43c24c7c0906db Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Wed, 18 Dec 2024 10:10:20 -0800 Subject: [PATCH 07/15] Oopsie with zdict.h --- lib/zdict.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/zdict.h b/lib/zdict.h index 340a9a24e8b..599b793013b 100644 --- a/lib/zdict.h +++ b/lib/zdict.h @@ -271,11 +271,19 @@ ZDICTLIB_API size_t ZDICT_getDictHeaderSize(const void* dictBuffer, size_t dictS ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode); ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode); +#if defined (__cplusplus) +} +#endif + #endif /* ZSTD_ZDICT_H */ #if defined(ZDICT_STATIC_LINKING_ONLY) && !defined(ZSTD_ZDICT_H_STATIC) #define ZSTD_ZDICT_H_STATIC +#if defined (__cplusplus) +extern "C" { +#endif + /* This can be overridden externally to hide static symbols. */ #ifndef ZDICTLIB_STATIC_API # if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) @@ -466,9 +474,8 @@ ZDICTLIB_STATIC_API size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity, const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples); - -#endif /* ZSTD_ZDICT_H_STATIC */ - #if defined (__cplusplus) } #endif + +#endif /* ZSTD_ZDICT_H_STATIC */ From 07ffcc6b65a0eb95afc63a73e595384aef9f3552 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Wed, 18 Dec 2024 12:35:10 -0800 Subject: [PATCH 08/15] Separate xxhash includes from extern C blocks --- lib/common/xxhash.h | 108 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 91 insertions(+), 17 deletions(-) diff --git a/lib/common/xxhash.h b/lib/common/xxhash.h index e59e44267c1..477fd4792c6 100644 --- a/lib/common/xxhash.h +++ b/lib/common/xxhash.h @@ -227,10 +227,6 @@ * xxHash prototypes and implementation */ -#if defined (__cplusplus) -extern "C" { -#endif - /* **************************** * INLINE mode ******************************/ @@ -537,6 +533,9 @@ extern "C" { /*! @brief Version number, encoded as two digits each */ #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) +#if defined (__cplusplus) +extern "C" { +#endif /*! * @brief Obtains the xxHash version. * @@ -547,6 +546,9 @@ extern "C" { */ XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void); +#if defined (__cplusplus) +} +#endif /* **************************** * Common basic types @@ -593,6 +595,10 @@ typedef uint32_t XXH32_hash_t; # endif #endif +#if defined (__cplusplus) +extern "C" { +#endif + /*! * @} * @@ -821,6 +827,9 @@ XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canoni #endif /*! @endcond */ +#if defined (__cplusplus) +} /* end of extern "C" */ +#endif /*! * @} @@ -859,6 +868,9 @@ typedef uint64_t XXH64_hash_t; # endif #endif +#if defined (__cplusplus) +extern "C" { +#endif /*! * @} * @@ -1562,6 +1574,11 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE con #endif /* !XXH_NO_XXH3 */ + +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_NO_LONG_LONG */ /*! @@ -1748,6 +1765,10 @@ struct XXH3_state_s { } while(0) +#if defined (__cplusplus) +extern "C" { +#endif + /*! * @brief Calculates the 128-bit hash of @p data using XXH3. * @@ -1963,8 +1984,13 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed64); #endif /* !XXH_NO_STREAM */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* !XXH_NO_XXH3 */ #endif /* XXH_NO_LONG_LONG */ + #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) # define XXH_IMPLEMENTATION #endif @@ -2263,10 +2289,12 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, * @{ */ - /* ************************************* * Includes & Memory related functions ***************************************/ +#include /* memcmp, memcpy */ +#include /* ULLONG_MAX */ + #if defined(XXH_NO_STREAM) /* nothing */ #elif defined(XXH_NO_STDLIB) @@ -2280,9 +2308,17 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, * without access to dynamic allocation. */ +#if defined (__cplusplus) +extern "C" { +#endif + static XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; } static void XXH_free(void* p) { (void)p; } +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #else /* @@ -2291,6 +2327,9 @@ static void XXH_free(void* p) { (void)p; } */ #include +#if defined (__cplusplus) +extern "C" { +#endif /*! * @internal * @brief Modify this function to use a different routine than malloc(). @@ -2303,10 +2342,15 @@ static XXH_MALLOCF void* XXH_malloc(size_t s) { return malloc(s); } */ static void XXH_free(void* p) { free(p); } -#endif /* XXH_NO_STDLIB */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif -#include +#endif /* XXH_NO_STDLIB */ +#if defined (__cplusplus) +extern "C" { +#endif /*! * @internal * @brief Modify this function to use a different routine than memcpy(). @@ -2316,8 +2360,9 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) return memcpy(dest,src,size); } -#include /* ULLONG_MAX */ - +#if defined (__cplusplus) +} /* extern "C" */ +#endif /* ************************************* * Compiler Specific Options @@ -2452,6 +2497,10 @@ typedef XXH32_hash_t xxh_u32; # define U32 xxh_u32 #endif +#if defined (__cplusplus) +extern "C" { +#endif + /* *** Memory access *** */ /*! @@ -3608,6 +3657,10 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_can return XXH_readBE64(src); } +#if defined (__cplusplus) +} +#endif + #ifndef XXH_NO_XXH3 /* ********************************************************************* @@ -3928,6 +3981,10 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # pragma GCC optimize("-O2") #endif +#if defined (__cplusplus) +extern "C" { +#endif + #if XXH_VECTOR == XXH_NEON /* @@ -4050,6 +4107,10 @@ XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) # endif #endif /* XXH_VECTOR == XXH_NEON */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + /* * VSX and Z Vector helpers. * @@ -4111,6 +4172,9 @@ typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING; # if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__)) # define XXH_vec_revb vec_revb # else +#if defined (__cplusplus) +extern "C" { +#endif /*! * A polyfill for POWER9's vec_revb(). */ @@ -4120,9 +4184,15 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val) 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 }; return vec_perm(val, val, vByteSwap); } +#if defined (__cplusplus) +} /* extern "C" */ +#endif # endif # endif /* XXH_VSX_BE */ +#if defined (__cplusplus) +extern "C" { +#endif /*! * Performs an unaligned vector load and byte swaps it on big endian. */ @@ -4167,6 +4237,11 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) return result; } # endif /* XXH_vec_mulo, XXH_vec_mule */ + +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_VECTOR == XXH_VSX */ #if XXH_VECTOR == XXH_SVE @@ -4200,7 +4275,9 @@ do { \ # endif #endif /* XXH_NO_PREFETCH */ - +#if defined (__cplusplus) +extern "C" { +#endif /* ========================================== * XXH3 default settings * ========================================== */ @@ -6877,8 +6954,6 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_ #endif /* !XXH_NO_STREAM */ /* 128-bit utility functions */ -#include /* memcmp, memcpy */ - /* return : 1 is equal, 0 if different */ /*! @ingroup XXH3_family */ XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2) @@ -7007,14 +7082,13 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed) #endif /* XXH_NO_LONG_LONG */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_NO_XXH3 */ /*! * @} */ #endif /* XXH_IMPLEMENTATION */ - - -#if defined (__cplusplus) -} /* extern "C" */ -#endif From a7bb6d6c490a5b60b58666e73890c19921907e18 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Wed, 18 Dec 2024 12:41:53 -0800 Subject: [PATCH 09/15] Oopsie with xxhash.h [1/?] --- lib/common/xxhash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/xxhash.h b/lib/common/xxhash.h index 477fd4792c6..68ec6b29fd1 100644 --- a/lib/common/xxhash.h +++ b/lib/common/xxhash.h @@ -7080,12 +7080,12 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed) # pragma GCC pop_options #endif -#endif /* XXH_NO_LONG_LONG */ #if defined (__cplusplus) } /* extern "C" */ #endif +#endif /* XXH_NO_LONG_LONG */ #endif /* XXH_NO_XXH3 */ /*! From d51e6072a847f91610637e44feef972fd41167ea Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Thu, 19 Dec 2024 14:59:02 -0800 Subject: [PATCH 10/15] Test: remove extern C from some lib/common files --- lib/common/bitstream.h | 8 -------- lib/common/fse.h | 16 ---------------- 2 files changed, 24 deletions(-) diff --git a/lib/common/bitstream.h b/lib/common/bitstream.h index bce91e8018c..bcfa09b8904 100644 --- a/lib/common/bitstream.h +++ b/lib/common/bitstream.h @@ -40,10 +40,6 @@ # endif #endif -#if defined (__cplusplus) -extern "C" { -#endif - #define STREAM_ACCUMULATOR_MIN_32 25 #define STREAM_ACCUMULATOR_MIN_64 57 #define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64)) @@ -450,8 +446,4 @@ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream) return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8)); } -#if defined (__cplusplus) -} -#endif - #endif /* BITSTREAM_H_MODULE */ diff --git a/lib/common/fse.h b/lib/common/fse.h index 9f031f31fa0..b1940d9426a 100644 --- a/lib/common/fse.h +++ b/lib/common/fse.h @@ -20,10 +20,6 @@ ******************************************/ #include "zstd_deps.h" /* size_t, ptrdiff_t */ -#if defined (__cplusplus) -extern "C" { -#endif - /*-***************************************** * FSE_PUBLIC_API : control library symbols visibility ******************************************/ @@ -225,10 +221,6 @@ FSE_decompress_usingDTable() result will tell how many bytes were regenerated (< If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small) */ -#if defined (__cplusplus) -} -#endif - #endif /* FSE_H */ @@ -257,10 +249,6 @@ If there is an error, the function will return an error code, which can be teste * FSE advanced API ***************************************** */ -#if defined (__cplusplus) -extern "C" { -#endif - unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus); /**< same as FSE_optimalTableLog(), which used `minus==2` */ @@ -634,8 +622,4 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr) #define FSE_TABLESTEP(tableSize) (((tableSize)>>1) + ((tableSize)>>3) + 3) -#if defined (__cplusplus) -} -#endif - #endif /* FSE_STATIC_LINKING_ONLY */ From d0d5ce4c00469d4f11970e649e55217a659b4690 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Thu, 19 Dec 2024 16:00:11 -0800 Subject: [PATCH 11/15] Remove extern C blocks from lib/* internal APIs (except xxhash.h) --- lib/common/error_private.h | 8 -------- lib/common/huf.h | 8 -------- lib/common/mem.h | 10 ---------- lib/common/pool.h | 9 --------- lib/common/threading.h | 27 --------------------------- lib/common/zstd_internal.h | 8 -------- lib/common/zstd_trace.h | 8 -------- lib/compress/zstd_compress_internal.h | 8 -------- lib/compress/zstd_cwksp.h | 8 -------- lib/compress/zstd_double_fast.h | 8 -------- lib/compress/zstd_fast.h | 8 -------- lib/compress/zstd_lazy.h | 9 --------- lib/compress/zstd_ldm.h | 8 -------- lib/compress/zstd_opt.h | 8 -------- lib/compress/zstd_preSplit.h | 8 -------- lib/compress/zstdmt_compress.h | 10 ---------- lib/dictBuilder/divsufsort.h | 10 ---------- 17 files changed, 163 deletions(-) diff --git a/lib/common/error_private.h b/lib/common/error_private.h index 06233aaa8eb..9dcc8595123 100644 --- a/lib/common/error_private.h +++ b/lib/common/error_private.h @@ -21,10 +21,6 @@ #include "debug.h" #include "zstd_deps.h" /* size_t */ -#if defined (__cplusplus) -extern "C" { -#endif - /* **************************************** * Compiler-specific ******************************************/ @@ -159,8 +155,4 @@ void _force_has_format_string(const char *format, ...) { } \ } while(0) -#if defined (__cplusplus) -} -#endif - #endif /* ERROR_H_MODULE */ diff --git a/lib/common/huf.h b/lib/common/huf.h index 962fe43fa73..4b142c4f996 100644 --- a/lib/common/huf.h +++ b/lib/common/huf.h @@ -21,10 +21,6 @@ #define FSE_STATIC_LINKING_ONLY #include "fse.h" -#if defined (__cplusplus) -extern "C" { -#endif - /* *** Tool functions *** */ #define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */ size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */ @@ -278,8 +274,4 @@ size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize, int flags); #endif -#if defined (__cplusplus) -} -#endif - #endif /* HUF_H_298734234 */ diff --git a/lib/common/mem.h b/lib/common/mem.h index 1b0a946ad15..ca756e23711 100644 --- a/lib/common/mem.h +++ b/lib/common/mem.h @@ -72,11 +72,6 @@ typedef signed long long S64; #endif - -#if defined (__cplusplus) -extern "C" { -#endif - /*-************************************************************** * Memory I/O API *****************************************************************/ @@ -424,9 +419,4 @@ MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val) /* code only tested on 32 and 64 bits systems */ MEM_STATIC void MEM_check(void) { DEBUG_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); } - -#if defined (__cplusplus) -} -#endif - #endif /* MEM_H_MODULE */ diff --git a/lib/common/pool.h b/lib/common/pool.h index d34082dc1fc..f39b7f1eb99 100644 --- a/lib/common/pool.h +++ b/lib/common/pool.h @@ -16,10 +16,6 @@ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */ #include "../zstd.h" -#if defined (__cplusplus) -extern "C" { -#endif - typedef struct POOL_ctx_s POOL_ctx; /*! POOL_create() : @@ -82,9 +78,4 @@ void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque); */ int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque); - -#if defined (__cplusplus) -} -#endif - #endif diff --git a/lib/common/threading.h b/lib/common/threading.h index 85b6a3ac823..e123cdf14a3 100644 --- a/lib/common/threading.h +++ b/lib/common/threading.h @@ -56,11 +56,6 @@ #define ZSTD_pthread_cond_signal(a) WakeConditionVariable((a)) #define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a)) - -#if defined (__cplusplus) -extern "C" { -#endif - /* ZSTD_pthread_create() and ZSTD_pthread_join() */ typedef HANDLE ZSTD_pthread_t; @@ -73,20 +68,10 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread); * add here more wrappers as required */ - -#if defined (__cplusplus) -} -#endif - #elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */ /* === POSIX Systems === */ # include - -#if defined (__cplusplus) -extern "C" { -#endif - #if DEBUGLEVEL < 1 #define ZSTD_pthread_mutex_t pthread_mutex_t @@ -133,17 +118,9 @@ int ZSTD_pthread_cond_destroy(ZSTD_pthread_cond_t* cond); #endif -#if defined (__cplusplus) -} -#endif - #else /* ZSTD_MULTITHREAD not defined */ /* No multithreading support */ -#if defined (__cplusplus) -extern "C" { -#endif - typedef int ZSTD_pthread_mutex_t; #define ZSTD_pthread_mutex_init(a, b) ((void)(a), (void)(b), 0) #define ZSTD_pthread_mutex_destroy(a) ((void)(a)) @@ -159,10 +136,6 @@ typedef int ZSTD_pthread_cond_t; /* do not use ZSTD_pthread_t */ -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_MULTITHREAD */ diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index ecb9cfba87c..e40d15a0599 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -39,10 +39,6 @@ # define ZSTD_TRACE 0 #endif -#if defined (__cplusplus) -extern "C" { -#endif - /* ---- static assert (debug) --- */ #define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) #define ZSTD_isError ERR_isError /* for inlining */ @@ -385,8 +381,4 @@ MEM_STATIC int ZSTD_cpuSupportsBmi2(void) return ZSTD_cpuid_bmi1(cpuid) && ZSTD_cpuid_bmi2(cpuid); } -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_CCOMMON_H_MODULE */ diff --git a/lib/common/zstd_trace.h b/lib/common/zstd_trace.h index b9187079c5d..198438a7c53 100644 --- a/lib/common/zstd_trace.h +++ b/lib/common/zstd_trace.h @@ -13,10 +13,6 @@ #include -#if defined (__cplusplus) -extern "C" { -#endif - /* weak symbol support * For now, enable conservatively: * - Only GNUC @@ -157,8 +153,4 @@ ZSTD_WEAK_ATTR void ZSTD_trace_decompress_end( #endif /* ZSTD_TRACE */ -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_TRACE_H */ diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h index 2d3510adc1c..bbca66cd3c9 100644 --- a/lib/compress/zstd_compress_internal.h +++ b/lib/compress/zstd_compress_internal.h @@ -26,10 +26,6 @@ #include "../common/bits.h" /* ZSTD_highbit32, ZSTD_NbCommonBytes */ #include "zstd_preSplit.h" /* ZSTD_SLIPBLOCK_WORKSPACESIZE */ -#if defined (__cplusplus) -extern "C" { -#endif - /*-************************************* * Constants ***************************************/ @@ -1426,10 +1422,6 @@ MEM_STATIC int ZSTD_comparePackedTags(size_t packedTag1, size_t packedTag2) { return tag1 == tag2; } -#if defined (__cplusplus) -} -#endif - /* =============================================================== * Shared internal declarations * These prototypes may be called from sources not in lib/compress diff --git a/lib/compress/zstd_cwksp.h b/lib/compress/zstd_cwksp.h index aa4c3e49e08..77518002d00 100644 --- a/lib/compress/zstd_cwksp.h +++ b/lib/compress/zstd_cwksp.h @@ -19,10 +19,6 @@ #include "../common/portability_macros.h" #include "../common/compiler.h" /* ZS2_isPower2 */ -#if defined (__cplusplus) -extern "C" { -#endif - /*-************************************* * Constants ***************************************/ @@ -766,8 +762,4 @@ MEM_STATIC void ZSTD_cwksp_bump_oversized_duration( } } -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_CWKSP_H */ diff --git a/lib/compress/zstd_double_fast.h b/lib/compress/zstd_double_fast.h index ae66f314279..a4d4d345e98 100644 --- a/lib/compress/zstd_double_fast.h +++ b/lib/compress/zstd_double_fast.h @@ -14,10 +14,6 @@ #include "../common/mem.h" /* U32 */ #include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms, @@ -43,8 +39,4 @@ size_t ZSTD_compressBlock_doubleFast_extDict( #define ZSTD_COMPRESSBLOCK_DOUBLEFAST_EXTDICT NULL #endif /* ZSTD_EXCLUDE_DFAST_BLOCK_COMPRESSOR */ -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_DOUBLE_FAST_H */ diff --git a/lib/compress/zstd_fast.h b/lib/compress/zstd_fast.h index f92cf35b961..8bbed8f9711 100644 --- a/lib/compress/zstd_fast.h +++ b/lib/compress/zstd_fast.h @@ -14,10 +14,6 @@ #include "../common/mem.h" /* U32 */ #include "zstd_compress_internal.h" -#if defined (__cplusplus) -extern "C" { -#endif - void ZSTD_fillHashTable(ZSTD_matchState_t* ms, void const* end, ZSTD_dictTableLoadMethod_e dtlm, ZSTD_tableFillPurpose_e tfp); @@ -31,8 +27,4 @@ size_t ZSTD_compressBlock_fast_extDict( ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM], void const* src, size_t srcSize); -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_FAST_H */ diff --git a/lib/compress/zstd_lazy.h b/lib/compress/zstd_lazy.h index bec17b1247e..cd4e1c7fa39 100644 --- a/lib/compress/zstd_lazy.h +++ b/lib/compress/zstd_lazy.h @@ -13,10 +13,6 @@ #include "zstd_compress_internal.h" -#if defined (__cplusplus) -extern "C" { -#endif - /** * Dedicated Dictionary Search Structure bucket log. In the * ZSTD_dedicatedDictSearch mode, the hashTable has @@ -194,9 +190,4 @@ size_t ZSTD_compressBlock_btlazy2_extDict( #define ZSTD_COMPRESSBLOCK_BTLAZY2_EXTDICT NULL #endif - -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_LAZY_H */ diff --git a/lib/compress/zstd_ldm.h b/lib/compress/zstd_ldm.h index 847c2befb1e..592b95a9812 100644 --- a/lib/compress/zstd_ldm.h +++ b/lib/compress/zstd_ldm.h @@ -14,10 +14,6 @@ #include "zstd_compress_internal.h" /* ldmParams_t, U32 */ #include "../zstd.h" /* ZSTD_CCtx, size_t */ -#if defined (__cplusplus) -extern "C" { -#endif - /*-************************************* * Long distance matching ***************************************/ @@ -110,8 +106,4 @@ size_t ZSTD_ldm_getMaxNbSeq(ldmParams_t params, size_t maxChunkSize); void ZSTD_ldm_adjustParameters(ldmParams_t* params, ZSTD_compressionParameters const* cParams); -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_FAST_H */ diff --git a/lib/compress/zstd_opt.h b/lib/compress/zstd_opt.h index 7ce6fdae7b1..cace8149481 100644 --- a/lib/compress/zstd_opt.h +++ b/lib/compress/zstd_opt.h @@ -13,10 +13,6 @@ #include "zstd_compress_internal.h" -#if defined (__cplusplus) -extern "C" { -#endif - #if !defined(ZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR) \ || !defined(ZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR) @@ -73,8 +69,4 @@ size_t ZSTD_compressBlock_btultra2( #define ZSTD_COMPRESSBLOCK_BTULTRA2 NULL #endif -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_OPT_H */ diff --git a/lib/compress/zstd_preSplit.h b/lib/compress/zstd_preSplit.h index d606a52b59e..b89a200dccd 100644 --- a/lib/compress/zstd_preSplit.h +++ b/lib/compress/zstd_preSplit.h @@ -13,10 +13,6 @@ #include /* size_t */ -#if defined (__cplusplus) -extern "C" { -#endif - #define ZSTD_SLIPBLOCK_WORKSPACESIZE 8208 /* ZSTD_splitBlock(): @@ -34,8 +30,4 @@ size_t ZSTD_splitBlock(const void* blockStart, size_t blockSize, int level, void* workspace, size_t wkspSize); -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_PRESPLIT_H */ diff --git a/lib/compress/zstdmt_compress.h b/lib/compress/zstdmt_compress.h index 9a58b5ad30d..91b489b9cb4 100644 --- a/lib/compress/zstdmt_compress.h +++ b/lib/compress/zstdmt_compress.h @@ -16,11 +16,6 @@ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */ #include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */ - #if defined (__cplusplus) - extern "C" { - #endif - - /* Note : This is an internal API. * These APIs used to be exposed with ZSTDLIB_API, * because it used to be the only way to invoke MT compression. @@ -104,9 +99,4 @@ void ZSTDMT_updateCParams_whileCompressing(ZSTDMT_CCtx* mtctx, const ZSTD_CCtx_p */ ZSTD_frameProgression ZSTDMT_getFrameProgression(ZSTDMT_CCtx* mtctx); - -#if defined (__cplusplus) -} -#endif - #endif /* ZSTDMT_COMPRESS_H */ diff --git a/lib/dictBuilder/divsufsort.h b/lib/dictBuilder/divsufsort.h index 5440994af15..3ed2b287ab1 100644 --- a/lib/dictBuilder/divsufsort.h +++ b/lib/dictBuilder/divsufsort.h @@ -27,11 +27,6 @@ #ifndef _DIVSUFSORT_H #define _DIVSUFSORT_H 1 -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - /*- Prototypes -*/ /** @@ -59,9 +54,4 @@ divsufsort(const unsigned char *T, int *SA, int n, int openMP); int divbwt(const unsigned char *T, unsigned char *U, int *A, int n, unsigned char * num_indexes, int * indexes, int openMP); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - #endif /* _DIVSUFSORT_H */ From c727d5cd675dc04e07c0113d168ce93dc5624e54 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Thu, 19 Dec 2024 16:20:23 -0800 Subject: [PATCH 12/15] Remove unnecessary extern C declarations from programs/ and contrib/ --- contrib/pzstd/test/PzstdTest.cpp | 2 -- contrib/pzstd/test/RoundTripTest.cpp | 2 -- programs/benchfn.h | 10 ---------- programs/benchzstd.h | 9 --------- programs/datagen.h | 8 ++++++++ programs/fileio.h | 10 ---------- programs/fileio_asyncio.h | 8 -------- programs/fileio_common.h | 7 ------- programs/timefn.h | 10 ---------- 9 files changed, 8 insertions(+), 58 deletions(-) diff --git a/contrib/pzstd/test/PzstdTest.cpp b/contrib/pzstd/test/PzstdTest.cpp index 75453f5f6f3..3249f860af0 100644 --- a/contrib/pzstd/test/PzstdTest.cpp +++ b/contrib/pzstd/test/PzstdTest.cpp @@ -7,9 +7,7 @@ * in the COPYING file in the root directory of this source tree). */ #include "Pzstd.h" -extern "C" { #include "datagen.h" -} #include "test/RoundTrip.h" #include "utils/ScopeGuard.h" diff --git a/contrib/pzstd/test/RoundTripTest.cpp b/contrib/pzstd/test/RoundTripTest.cpp index c37646d1c44..27c5028e880 100644 --- a/contrib/pzstd/test/RoundTripTest.cpp +++ b/contrib/pzstd/test/RoundTripTest.cpp @@ -6,9 +6,7 @@ * 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). */ -extern "C" { #include "datagen.h" -} #include "Options.h" #include "test/RoundTrip.h" #include "utils/ScopeGuard.h" diff --git a/programs/benchfn.h b/programs/benchfn.h index 3ba3a4f5504..3fc6e0d0455 100644 --- a/programs/benchfn.h +++ b/programs/benchfn.h @@ -21,11 +21,6 @@ /* === Dependencies === */ #include /* size_t */ - -#if defined (__cplusplus) -extern "C" { -#endif - /* ==== Benchmark any function, iterated on a set of blocks ==== */ /* BMK_runTime_t: valid result return type */ @@ -175,9 +170,4 @@ typedef union { } BMK_timedFnState_shell; BMK_timedFnState_t* BMK_initStatic_timedFnState(void* buffer, size_t size, unsigned total_ms, unsigned run_ms); - #endif /* BENCH_FN_H_23876 */ - -#if defined (__cplusplus) -} -#endif diff --git a/programs/benchzstd.h b/programs/benchzstd.h index 7ea018b12f1..5125c20e8af 100644 --- a/programs/benchzstd.h +++ b/programs/benchzstd.h @@ -22,11 +22,6 @@ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */ #include "../lib/zstd.h" /* ZSTD_compressionParameters */ - -#if defined (__cplusplus) -extern "C" { -#endif - /* === Constants === */ #define MB_UNIT 1000000 @@ -194,7 +189,3 @@ BMK_benchOutcome_t BMK_benchMemAdvanced(const void* srcBuffer, size_t srcSize, #endif /* BENCH_ZSTD_H_3242387 */ - -#if defined (__cplusplus) -} -#endif diff --git a/programs/datagen.h b/programs/datagen.h index ca72700063f..461fb716c43 100644 --- a/programs/datagen.h +++ b/programs/datagen.h @@ -14,6 +14,10 @@ #include /* size_t */ +#if defined (__cplusplus) +extern "C" { +#endif + void RDG_genStdout(unsigned long long size, double matchProba, double litProba, unsigned seed); void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba, unsigned seed); /*!RDG_genBuffer @@ -27,4 +31,8 @@ void RDG_genBuffer(void* buffer, size_t size, double matchProba, double litProba Same as RDG_genBuffer, but generates data into stdout */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif diff --git a/programs/fileio.h b/programs/fileio.h index 224d89525dc..6babf40e1b1 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -17,11 +17,6 @@ #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */ #include "../lib/zstd.h" /* ZSTD_* */ -#if defined (__cplusplus) -extern "C" { -#endif - - /* ************************************* * Special i/o constants **************************************/ @@ -173,9 +168,4 @@ char const* FIO_zlibVersion(void); char const* FIO_lz4Version(void); char const* FIO_lzmaVersion(void); - -#if defined (__cplusplus) -} -#endif - #endif /* FILEIO_H_23981798732 */ diff --git a/programs/fileio_asyncio.h b/programs/fileio_asyncio.h index 1c30a73da89..d4980ef5b01 100644 --- a/programs/fileio_asyncio.h +++ b/programs/fileio_asyncio.h @@ -31,10 +31,6 @@ #define MAX_IO_JOBS (10) -#if defined (__cplusplus) -extern "C" { -#endif - typedef struct { /* These struct fields should be set only on creation and not changed afterwards */ POOL_ctx* threadPool; @@ -196,8 +192,4 @@ FILE* AIO_ReadPool_getFile(const ReadPoolCtx_t *ctx); * Closes the current set file. Waits for all current enqueued tasks to complete and resets state. */ int AIO_ReadPool_closeFile(ReadPoolCtx_t *ctx); -#if defined (__cplusplus) -} -#endif - #endif /* ZSTD_FILEIO_ASYNCIO_H */ diff --git a/programs/fileio_common.h b/programs/fileio_common.h index 87f99cda90d..e073dc10173 100644 --- a/programs/fileio_common.h +++ b/programs/fileio_common.h @@ -23,10 +23,6 @@ # include #endif -#if defined (__cplusplus) -extern "C" { -#endif - /*-************************************* * Macros ***************************************/ @@ -124,7 +120,4 @@ extern UTIL_time_t g_displayClock; # define LONG_TELL ftell #endif -#if defined (__cplusplus) -} -#endif #endif /* ZSTD_FILEIO_COMMON_H */ diff --git a/programs/timefn.h b/programs/timefn.h index dc7463be352..80f72e228a3 100644 --- a/programs/timefn.h +++ b/programs/timefn.h @@ -26,11 +26,6 @@ typedef unsigned long long PTime; /* does not support compilers without long long support */ #endif - -#if defined (__cplusplus) -extern "C" { -#endif - /* UTIL_time_t contains a nanosecond time counter. * The absolute value is not meaningful. * It's only valid to compute the difference between 2 measurements. */ @@ -61,9 +56,4 @@ PTime UTIL_clockSpanMicro(UTIL_time_t clockStart); #define SEC_TO_MICRO ((PTime)1000000) /* nb of microseconds in a second */ - -#if defined (__cplusplus) -} -#endif - #endif /* TIME_FN_H_MODULE_287987 */ From 10b9d81909f8631e3ac64bd45e3bdd04982e39d6 Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Thu, 19 Dec 2024 16:54:32 -0800 Subject: [PATCH 13/15] Remove unnecessary extern C declarations from xxhash.h --- lib/common/xxhash.h | 90 --------------------------------------------- 1 file changed, 90 deletions(-) diff --git a/lib/common/xxhash.h b/lib/common/xxhash.h index 68ec6b29fd1..a849b75f99d 100644 --- a/lib/common/xxhash.h +++ b/lib/common/xxhash.h @@ -533,9 +533,6 @@ /*! @brief Version number, encoded as two digits each */ #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) -#if defined (__cplusplus) -extern "C" { -#endif /*! * @brief Obtains the xxHash version. * @@ -546,10 +543,6 @@ extern "C" { */ XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void); -#if defined (__cplusplus) -} -#endif - /* **************************** * Common basic types ******************************/ @@ -595,10 +588,6 @@ typedef uint32_t XXH32_hash_t; # endif #endif -#if defined (__cplusplus) -extern "C" { -#endif - /*! * @} * @@ -827,10 +816,6 @@ XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canoni #endif /*! @endcond */ -#if defined (__cplusplus) -} /* end of extern "C" */ -#endif - /*! * @} * @ingroup public @@ -868,9 +853,6 @@ typedef uint64_t XXH64_hash_t; # endif #endif -#if defined (__cplusplus) -extern "C" { -#endif /*! * @} * @@ -1575,10 +1557,6 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE con #endif /* !XXH_NO_XXH3 */ -#if defined (__cplusplus) -} /* extern "C" */ -#endif - #endif /* XXH_NO_LONG_LONG */ /*! @@ -1764,11 +1742,6 @@ struct XXH3_state_s { tmp_xxh3_state_ptr->extSecret = NULL; \ } while(0) - -#if defined (__cplusplus) -extern "C" { -#endif - /*! * @brief Calculates the 128-bit hash of @p data using XXH3. * @@ -1984,10 +1957,6 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed64); #endif /* !XXH_NO_STREAM */ -#if defined (__cplusplus) -} /* extern "C" */ -#endif - #endif /* !XXH_NO_XXH3 */ #endif /* XXH_NO_LONG_LONG */ @@ -2308,17 +2277,9 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, * without access to dynamic allocation. */ -#if defined (__cplusplus) -extern "C" { -#endif - static XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; } static void XXH_free(void* p) { (void)p; } -#if defined (__cplusplus) -} /* extern "C" */ -#endif - #else /* @@ -2327,9 +2288,6 @@ static void XXH_free(void* p) { (void)p; } */ #include -#if defined (__cplusplus) -extern "C" { -#endif /*! * @internal * @brief Modify this function to use a different routine than malloc(). @@ -2342,15 +2300,8 @@ static XXH_MALLOCF void* XXH_malloc(size_t s) { return malloc(s); } */ static void XXH_free(void* p) { free(p); } -#if defined (__cplusplus) -} /* extern "C" */ -#endif - #endif /* XXH_NO_STDLIB */ -#if defined (__cplusplus) -extern "C" { -#endif /*! * @internal * @brief Modify this function to use a different routine than memcpy(). @@ -2360,10 +2311,6 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) return memcpy(dest,src,size); } -#if defined (__cplusplus) -} /* extern "C" */ -#endif - /* ************************************* * Compiler Specific Options ***************************************/ @@ -2497,10 +2444,6 @@ typedef XXH32_hash_t xxh_u32; # define U32 xxh_u32 #endif -#if defined (__cplusplus) -extern "C" { -#endif - /* *** Memory access *** */ /*! @@ -3657,10 +3600,6 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_can return XXH_readBE64(src); } -#if defined (__cplusplus) -} -#endif - #ifndef XXH_NO_XXH3 /* ********************************************************************* @@ -3981,10 +3920,6 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # pragma GCC optimize("-O2") #endif -#if defined (__cplusplus) -extern "C" { -#endif - #if XXH_VECTOR == XXH_NEON /* @@ -4107,10 +4042,6 @@ XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) # endif #endif /* XXH_VECTOR == XXH_NEON */ -#if defined (__cplusplus) -} /* extern "C" */ -#endif - /* * VSX and Z Vector helpers. * @@ -4172,9 +4103,6 @@ typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING; # if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__)) # define XXH_vec_revb vec_revb # else -#if defined (__cplusplus) -extern "C" { -#endif /*! * A polyfill for POWER9's vec_revb(). */ @@ -4184,15 +4112,9 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val) 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 }; return vec_perm(val, val, vByteSwap); } -#if defined (__cplusplus) -} /* extern "C" */ -#endif # endif # endif /* XXH_VSX_BE */ -#if defined (__cplusplus) -extern "C" { -#endif /*! * Performs an unaligned vector load and byte swaps it on big endian. */ @@ -4238,10 +4160,6 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) } # endif /* XXH_vec_mulo, XXH_vec_mule */ -#if defined (__cplusplus) -} /* extern "C" */ -#endif - #endif /* XXH_VECTOR == XXH_VSX */ #if XXH_VECTOR == XXH_SVE @@ -4275,9 +4193,6 @@ do { \ # endif #endif /* XXH_NO_PREFETCH */ -#if defined (__cplusplus) -extern "C" { -#endif /* ========================================== * XXH3 default settings * ========================================== */ @@ -7080,11 +6995,6 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed) # pragma GCC pop_options #endif - -#if defined (__cplusplus) -} /* extern "C" */ -#endif - #endif /* XXH_NO_LONG_LONG */ #endif /* XXH_NO_XXH3 */ From c7af0428c6cceac32a192392d954dc8e6e1ba79a Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Thu, 19 Dec 2024 17:48:00 -0800 Subject: [PATCH 14/15] Oopsie with fileio_common.h --- programs/fileio_common.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/programs/fileio_common.h b/programs/fileio_common.h index e073dc10173..274a6d10cf6 100644 --- a/programs/fileio_common.h +++ b/programs/fileio_common.h @@ -16,13 +16,6 @@ #include "platform.h" #include "timefn.h" /* UTIL_getTime, UTIL_clockSpanMicro */ -#if !(defined(_MSC_VER) && _MSC_VER >= 1400) \ - && !(!defined(__64BIT__) && (PLATFORM_POSIX_VERSION >= 200112L)) \ - && !(defined(__MINGW32__) && !defined(__STRICT_ANSI__) && !defined(__NO_MINGW_LFS) && defined(__MSVCRT__)) \ - && (defined(_WIN32) && !defined(__DJGPP__)) -# include -#endif - /*-************************************* * Macros ***************************************/ @@ -92,6 +85,7 @@ extern UTIL_time_t g_displayClock; # define LONG_SEEK fseeko64 # define LONG_TELL ftello64 #elif defined(_WIN32) && !defined(__DJGPP__) +# include static int LONG_SEEK(FILE* file, __int64 offset, int origin) { LARGE_INTEGER off; DWORD method; From 8f49db5a022f5f77ad2c9a468b5929855bb6f36b Mon Sep 17 00:00:00 2001 From: Victor Zhang Date: Thu, 19 Dec 2024 17:54:41 -0800 Subject: [PATCH 15/15] Revert "Remove unnecessary extern C declarations from xxhash.h" This reverts commit 10b9d81909f8631e3ac64bd45e3bdd04982e39d6. --- lib/common/xxhash.h | 90 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/lib/common/xxhash.h b/lib/common/xxhash.h index a849b75f99d..68ec6b29fd1 100644 --- a/lib/common/xxhash.h +++ b/lib/common/xxhash.h @@ -533,6 +533,9 @@ /*! @brief Version number, encoded as two digits each */ #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) +#if defined (__cplusplus) +extern "C" { +#endif /*! * @brief Obtains the xxHash version. * @@ -543,6 +546,10 @@ */ XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void); +#if defined (__cplusplus) +} +#endif + /* **************************** * Common basic types ******************************/ @@ -588,6 +595,10 @@ typedef uint32_t XXH32_hash_t; # endif #endif +#if defined (__cplusplus) +extern "C" { +#endif + /*! * @} * @@ -816,6 +827,10 @@ XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canoni #endif /*! @endcond */ +#if defined (__cplusplus) +} /* end of extern "C" */ +#endif + /*! * @} * @ingroup public @@ -853,6 +868,9 @@ typedef uint64_t XXH64_hash_t; # endif #endif +#if defined (__cplusplus) +extern "C" { +#endif /*! * @} * @@ -1557,6 +1575,10 @@ XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE con #endif /* !XXH_NO_XXH3 */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_NO_LONG_LONG */ /*! @@ -1742,6 +1764,11 @@ struct XXH3_state_s { tmp_xxh3_state_ptr->extSecret = NULL; \ } while(0) + +#if defined (__cplusplus) +extern "C" { +#endif + /*! * @brief Calculates the 128-bit hash of @p data using XXH3. * @@ -1957,6 +1984,10 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed64); #endif /* !XXH_NO_STREAM */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* !XXH_NO_XXH3 */ #endif /* XXH_NO_LONG_LONG */ @@ -2277,9 +2308,17 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, * without access to dynamic allocation. */ +#if defined (__cplusplus) +extern "C" { +#endif + static XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; } static void XXH_free(void* p) { (void)p; } +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #else /* @@ -2288,6 +2327,9 @@ static void XXH_free(void* p) { (void)p; } */ #include +#if defined (__cplusplus) +extern "C" { +#endif /*! * @internal * @brief Modify this function to use a different routine than malloc(). @@ -2300,8 +2342,15 @@ static XXH_MALLOCF void* XXH_malloc(size_t s) { return malloc(s); } */ static void XXH_free(void* p) { free(p); } +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_NO_STDLIB */ +#if defined (__cplusplus) +extern "C" { +#endif /*! * @internal * @brief Modify this function to use a different routine than memcpy(). @@ -2311,6 +2360,10 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) return memcpy(dest,src,size); } +#if defined (__cplusplus) +} /* extern "C" */ +#endif + /* ************************************* * Compiler Specific Options ***************************************/ @@ -2444,6 +2497,10 @@ typedef XXH32_hash_t xxh_u32; # define U32 xxh_u32 #endif +#if defined (__cplusplus) +extern "C" { +#endif + /* *** Memory access *** */ /*! @@ -3600,6 +3657,10 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_can return XXH_readBE64(src); } +#if defined (__cplusplus) +} +#endif + #ifndef XXH_NO_XXH3 /* ********************************************************************* @@ -3920,6 +3981,10 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # pragma GCC optimize("-O2") #endif +#if defined (__cplusplus) +extern "C" { +#endif + #if XXH_VECTOR == XXH_NEON /* @@ -4042,6 +4107,10 @@ XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) # endif #endif /* XXH_VECTOR == XXH_NEON */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + /* * VSX and Z Vector helpers. * @@ -4103,6 +4172,9 @@ typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING; # if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__)) # define XXH_vec_revb vec_revb # else +#if defined (__cplusplus) +extern "C" { +#endif /*! * A polyfill for POWER9's vec_revb(). */ @@ -4112,9 +4184,15 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_revb(xxh_u64x2 val) 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 }; return vec_perm(val, val, vByteSwap); } +#if defined (__cplusplus) +} /* extern "C" */ +#endif # endif # endif /* XXH_VSX_BE */ +#if defined (__cplusplus) +extern "C" { +#endif /*! * Performs an unaligned vector load and byte swaps it on big endian. */ @@ -4160,6 +4238,10 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) } # endif /* XXH_vec_mulo, XXH_vec_mule */ +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_VECTOR == XXH_VSX */ #if XXH_VECTOR == XXH_SVE @@ -4193,6 +4275,9 @@ do { \ # endif #endif /* XXH_NO_PREFETCH */ +#if defined (__cplusplus) +extern "C" { +#endif /* ========================================== * XXH3 default settings * ========================================== */ @@ -6995,6 +7080,11 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed) # pragma GCC pop_options #endif + +#if defined (__cplusplus) +} /* extern "C" */ +#endif + #endif /* XXH_NO_LONG_LONG */ #endif /* XXH_NO_XXH3 */