Separate xxhash includes from extern C blocks

This commit is contained in:
Victor Zhang
2024-12-18 12:35:10 -08:00
parent f25b9f11ba
commit 07ffcc6b65
+91 -17
View File
@@ -227,10 +227,6 @@
* xxHash prototypes and implementation * xxHash prototypes and implementation
*/ */
#if defined (__cplusplus)
extern "C" {
#endif
/* **************************** /* ****************************
* INLINE mode * INLINE mode
******************************/ ******************************/
@@ -537,6 +533,9 @@ extern "C" {
/*! @brief Version number, encoded as two digits each */ /*! @brief Version number, encoded as two digits each */
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) #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. * @brief Obtains the xxHash version.
* *
@@ -547,6 +546,9 @@ extern "C" {
*/ */
XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void); XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void);
#if defined (__cplusplus)
}
#endif
/* **************************** /* ****************************
* Common basic types * Common basic types
@@ -593,6 +595,10 @@ typedef uint32_t XXH32_hash_t;
# endif # endif
#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 #endif
/*! @endcond */ /*! @endcond */
#if defined (__cplusplus)
} /* end of extern "C" */
#endif
/*! /*!
* @} * @}
@@ -859,6 +868,9 @@ typedef uint64_t XXH64_hash_t;
# endif # endif
#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 */ #endif /* !XXH_NO_XXH3 */
#if defined (__cplusplus)
} /* extern "C" */
#endif
#endif /* XXH_NO_LONG_LONG */ #endif /* XXH_NO_LONG_LONG */
/*! /*!
@@ -1748,6 +1765,10 @@ struct XXH3_state_s {
} while(0) } while(0)
#if defined (__cplusplus)
extern "C" {
#endif
/*! /*!
* @brief Calculates the 128-bit hash of @p data using XXH3. * @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); XXH64_hash_t seed64);
#endif /* !XXH_NO_STREAM */ #endif /* !XXH_NO_STREAM */
#if defined (__cplusplus)
} /* extern "C" */
#endif
#endif /* !XXH_NO_XXH3 */ #endif /* !XXH_NO_XXH3 */
#endif /* XXH_NO_LONG_LONG */ #endif /* XXH_NO_LONG_LONG */
#if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)
# define XXH_IMPLEMENTATION # define XXH_IMPLEMENTATION
#endif #endif
@@ -2263,10 +2289,12 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
* @{ * @{
*/ */
/* ************************************* /* *************************************
* Includes & Memory related functions * Includes & Memory related functions
***************************************/ ***************************************/
#include <string.h> /* memcmp, memcpy */
#include <limits.h> /* ULLONG_MAX */
#if defined(XXH_NO_STREAM) #if defined(XXH_NO_STREAM)
/* nothing */ /* nothing */
#elif defined(XXH_NO_STDLIB) #elif defined(XXH_NO_STDLIB)
@@ -2280,9 +2308,17 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr,
* without access to dynamic allocation. * 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 XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; }
static void XXH_free(void* p) { (void)p; } static void XXH_free(void* p) { (void)p; }
#if defined (__cplusplus)
} /* extern "C" */
#endif
#else #else
/* /*
@@ -2291,6 +2327,9 @@ static void XXH_free(void* p) { (void)p; }
*/ */
#include <stdlib.h> #include <stdlib.h>
#if defined (__cplusplus)
extern "C" {
#endif
/*! /*!
* @internal * @internal
* @brief Modify this function to use a different routine than malloc(). * @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); } static void XXH_free(void* p) { free(p); }
#if defined (__cplusplus)
} /* extern "C" */
#endif
#endif /* XXH_NO_STDLIB */ #endif /* XXH_NO_STDLIB */
#include <string.h> #if defined (__cplusplus)
extern "C" {
#endif
/*! /*!
* @internal * @internal
* @brief Modify this function to use a different routine than memcpy(). * @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); return memcpy(dest,src,size);
} }
#include <limits.h> /* ULLONG_MAX */ #if defined (__cplusplus)
} /* extern "C" */
#endif
/* ************************************* /* *************************************
* Compiler Specific Options * Compiler Specific Options
@@ -2452,6 +2497,10 @@ typedef XXH32_hash_t xxh_u32;
# define U32 xxh_u32 # define U32 xxh_u32
#endif #endif
#if defined (__cplusplus)
extern "C" {
#endif
/* *** Memory access *** */ /* *** Memory access *** */
/*! /*!
@@ -3608,6 +3657,10 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_can
return XXH_readBE64(src); return XXH_readBE64(src);
} }
#if defined (__cplusplus)
}
#endif
#ifndef XXH_NO_XXH3 #ifndef XXH_NO_XXH3
/* ********************************************************************* /* *********************************************************************
@@ -3928,6 +3981,10 @@ enum XXH_VECTOR_TYPE /* fake enum */ {
# pragma GCC optimize("-O2") # pragma GCC optimize("-O2")
#endif #endif
#if defined (__cplusplus)
extern "C" {
#endif
#if XXH_VECTOR == XXH_NEON #if XXH_VECTOR == XXH_NEON
/* /*
@@ -4050,6 +4107,10 @@ XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs)
# endif # endif
#endif /* XXH_VECTOR == XXH_NEON */ #endif /* XXH_VECTOR == XXH_NEON */
#if defined (__cplusplus)
} /* extern "C" */
#endif
/* /*
* VSX and Z Vector helpers. * 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__)) # if defined(__POWER9_VECTOR__) || (defined(__clang__) && defined(__s390x__))
# define XXH_vec_revb vec_revb # define XXH_vec_revb vec_revb
# else # else
#if defined (__cplusplus)
extern "C" {
#endif
/*! /*!
* A polyfill for POWER9's vec_revb(). * 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 }; 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
return vec_perm(val, val, vByteSwap); return vec_perm(val, val, vByteSwap);
} }
#if defined (__cplusplus)
} /* extern "C" */
#endif
# endif # endif
# endif /* XXH_VSX_BE */ # endif /* XXH_VSX_BE */
#if defined (__cplusplus)
extern "C" {
#endif
/*! /*!
* Performs an unaligned vector load and byte swaps it on big endian. * 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; return result;
} }
# endif /* XXH_vec_mulo, XXH_vec_mule */ # endif /* XXH_vec_mulo, XXH_vec_mule */
#if defined (__cplusplus)
} /* extern "C" */
#endif
#endif /* XXH_VECTOR == XXH_VSX */ #endif /* XXH_VECTOR == XXH_VSX */
#if XXH_VECTOR == XXH_SVE #if XXH_VECTOR == XXH_SVE
@@ -4200,7 +4275,9 @@ do { \
# endif # endif
#endif /* XXH_NO_PREFETCH */ #endif /* XXH_NO_PREFETCH */
#if defined (__cplusplus)
extern "C" {
#endif
/* ========================================== /* ==========================================
* XXH3 default settings * 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 */ #endif /* !XXH_NO_STREAM */
/* 128-bit utility functions */ /* 128-bit utility functions */
#include <string.h> /* memcmp, memcpy */
/* return : 1 is equal, 0 if different */ /* return : 1 is equal, 0 if different */
/*! @ingroup XXH3_family */ /*! @ingroup XXH3_family */
XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2) 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 */ #endif /* XXH_NO_LONG_LONG */
#if defined (__cplusplus)
} /* extern "C" */
#endif
#endif /* XXH_NO_XXH3 */ #endif /* XXH_NO_XXH3 */
/*! /*!
* @} * @}
*/ */
#endif /* XXH_IMPLEMENTATION */ #endif /* XXH_IMPLEMENTATION */
#if defined (__cplusplus)
} /* extern "C" */
#endif