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/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..bcfa09b8904 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 =========================================*/ @@ -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/debug.h b/lib/common/debug.h index a16b69e5743..4b60ddf7f51 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. @@ -108,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/error_private.h b/lib/common/error_private.h index 0156010c745..9dcc8595123 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,7 +21,6 @@ extern "C" { #include "debug.h" #include "zstd_deps.h" /* size_t */ - /* **************************************** * Compiler-specific ******************************************/ @@ -161,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/fse.h b/lib/common/fse.h index 2ae128e60db..b1940d9426a 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,7 +20,6 @@ extern "C" { ******************************************/ #include "zstd_deps.h" /* size_t, ptrdiff_t */ - /*-***************************************** * FSE_PUBLIC_API : control library symbols visibility ******************************************/ @@ -232,11 +226,8 @@ 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 *******************************************/ @@ -631,10 +622,4 @@ 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 diff --git a/lib/common/huf.h b/lib/common/huf.h index 99bf85d6f4e..4b142c4f996 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,7 +21,6 @@ extern "C" { #define FSE_STATIC_LINKING_ONLY #include "fse.h" - /* *** 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) */ @@ -280,7 +275,3 @@ size_t HUF_readDTableX2_wksp(HUF_DTable* DTable, const void* src, size_t srcSize #endif #endif /* HUF_H_298734234 */ - -#if defined (__cplusplus) -} -#endif diff --git a/lib/common/mem.h b/lib/common/mem.h index a02141c9d49..ca756e23711 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 ******************************************/ @@ -76,7 +72,6 @@ extern "C" { typedef signed long long S64; #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 cca4de73a83..f39b7f1eb99 100644 --- a/lib/common/pool.h +++ b/lib/common/pool.h @@ -11,10 +11,6 @@ #ifndef POOL_H #define POOL_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "zstd_deps.h" #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */ @@ -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 fb5c1c87873..e123cdf14a3 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) /** @@ -72,7 +68,6 @@ int ZSTD_pthread_join(ZSTD_pthread_t thread); * add here more wrappers as required */ - #elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */ /* === POSIX Systems === */ # include @@ -143,8 +138,5 @@ typedef int ZSTD_pthread_cond_t; #endif /* ZSTD_MULTITHREAD */ -#if defined (__cplusplus) -} -#endif #endif /* THREADING_H_938743 */ diff --git a/lib/common/xxhash.h b/lib/common/xxhash.h index e59e44267c1..68ec6b29fd1 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) @@ -7005,16 +7080,15 @@ 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 */ /*! * @} */ #endif /* XXH_IMPLEMENTATION */ - - -#if defined (__cplusplus) -} /* extern "C" */ -#endif diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index b67ca863384..2789a359122 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 */ @@ -325,8 +321,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 d33edf35db6..d8eec100758 100644 --- a/lib/common/zstd_trace.h +++ b/lib/common/zstd_trace.h @@ -11,10 +11,6 @@ #ifndef ZSTD_TRACE_H #define ZSTD_TRACE_H -#if defined (__cplusplus) -extern "C" { -#endif - #include /* weak symbol support @@ -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 2d4ecc89f18..2be67a1240a 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 ***************************************/ @@ -1503,10 +1499,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 c58697ad243..cd562fea8ef 100644 --- a/lib/compress/zstd_double_fast.h +++ b/lib/compress/zstd_double_fast.h @@ -11,10 +11,6 @@ #ifndef ZSTD_DOUBLE_FAST_H #define ZSTD_DOUBLE_FAST_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "../common/mem.h" /* U32 */ #include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */ @@ -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 f7fbf4f683c..216821ac33b 100644 --- a/lib/compress/zstd_fast.h +++ b/lib/compress/zstd_fast.h @@ -11,10 +11,6 @@ #ifndef ZSTD_FAST_H #define ZSTD_FAST_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "../common/mem.h" /* U32 */ #include "zstd_compress_internal.h" @@ -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 6da51e4ecff..bd8dc49e64c 100644 --- a/lib/compress/zstd_lazy.h +++ b/lib/compress/zstd_lazy.h @@ -11,10 +11,6 @@ #ifndef ZSTD_LAZY_H #define ZSTD_LAZY_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "zstd_compress_internal.h" /** @@ -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 8efa7c4f0eb..42736231aa8 100644 --- a/lib/compress/zstd_ldm.h +++ b/lib/compress/zstd_ldm.h @@ -11,10 +11,6 @@ #ifndef ZSTD_LDM_H #define ZSTD_LDM_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "zstd_compress_internal.h" /* ldmParams_t, U32 */ #include "../zstd.h" /* ZSTD_CCtx, size_t */ @@ -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 247c9ee6572..756c7b1d0c5 100644 --- a/lib/compress/zstd_opt.h +++ b/lib/compress/zstd_opt.h @@ -11,10 +11,6 @@ #ifndef ZSTD_OPT_H #define ZSTD_OPT_H -#if defined (__cplusplus) -extern "C" { -#endif - #include "zstd_compress_internal.h" #if !defined(ZSTD_EXCLUDE_BTLAZY2_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 ed4dc0e99df..91b489b9cb4 100644 --- a/lib/compress/zstdmt_compress.h +++ b/lib/compress/zstdmt_compress.h @@ -11,10 +11,10 @@ #ifndef ZSTDMT_COMPRESS_H #define ZSTDMT_COMPRESS_H - #if defined (__cplusplus) - extern "C" { - #endif - +/* === Dependencies === */ +#include "../common/zstd_deps.h" /* size_t */ +#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */ +#include "../zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */ /* Note : This is an internal API. * These APIs used to be exposed with ZSTDLIB_API, @@ -25,12 +25,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) @@ -105,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 */ diff --git a/lib/zdict.h b/lib/zdict.h index bcccf750e64..599b793013b 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 @@ -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 */ diff --git a/lib/zstd.h b/lib/zstd.h index 08b3b357a78..907a377d186 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 @@ -245,7 +251,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(). @@ -1205,6 +1210,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,7 +1229,9 @@ 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 */ +#if defined (__cplusplus) +extern "C" { +#endif /* This can be overridden externally to hide static symbols. */ #ifndef ZSTDLIB_STATIC_API @@ -3179,8 +3190,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 */ diff --git a/programs/benchfn.h b/programs/benchfn.h index 1bd93d13519..3fc6e0d0455 100644 --- a/programs/benchfn.h +++ b/programs/benchfn.h @@ -15,17 +15,12 @@ * or detecting and returning an error */ -#if defined (__cplusplus) -extern "C" { -#endif - #ifndef BENCH_FN_H_23876 #define BENCH_FN_H_23876 /* === Dependencies === */ #include /* size_t */ - /* ==== 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 6ff62d43eda..4fd0e5a8af4 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 @@ -26,7 +22,6 @@ extern "C" { #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */ #include "../lib/zstd.h" /* ZSTD_compressionParameters */ - /* === 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 e8cb2e6abe9..cb53ef53781 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 feb25a3f9e9..d4980ef5b01 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" @@ -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 696626fe478..8aa70edea81 100644 --- a/programs/fileio_common.h +++ b/programs/fileio_common.h @@ -11,10 +11,6 @@ #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" @@ -122,7 +118,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/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..80f72e228a3 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 ******************************************/ @@ -62,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 */ 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 3a83a50ae3a..d768e766091 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 !(defined(_MSC_VER) || defined(__MINGW32__) || defined (__MSVCRT__)) +#include +#endif /*-************************************************************ * Fix fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW @@ -119,7 +122,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);