Go to the documentation of this file.
52 #ifndef XXH_FORCE_MEMORY_ACCESS
53 # if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
54 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
55 || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
56 # define XXH_FORCE_MEMORY_ACCESS 2
57 # elif (defined(__INTEL_COMPILER) && !defined(_WIN32)) || \
58 (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
59 || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
60 || defined(__ARM_ARCH_7S__) ))
61 # define XXH_FORCE_MEMORY_ACCESS 1
70 #ifndef XXH_ACCEPT_NULL_INPUT_POINTER
71 # define XXH_ACCEPT_NULL_INPUT_POINTER 0
82 #ifndef XXH_FORCE_NATIVE_FORMAT
83 # define XXH_FORCE_NATIVE_FORMAT 0
93 #ifndef XXH_FORCE_ALIGN_CHECK
94 # if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
95 # define XXH_FORCE_ALIGN_CHECK 0
97 # define XXH_FORCE_ALIGN_CHECK 1
116 #define XXH_STATIC_LINKING_ONLY
124 # pragma warning(disable : 4127)
125 # define FORCE_INLINE static __forceinline
127 # if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
129 # define FORCE_INLINE static inline __attribute__((always_inline))
131 # define FORCE_INLINE static inline
134 # define FORCE_INLINE static
143 # if !defined (__VMS) \
144 && (defined (__cplusplus) \
145 || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) )
147 typedef uint8_t
BYTE;
148 typedef uint16_t
U16;
149 typedef uint32_t
U32;
152 typedef unsigned short U16;
157 #if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
162 #elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
166 typedef union {
U32 u32; } __attribute__((packed)) unalign;
177 memcpy(&val, memPtr,
sizeof(val));
187 #define XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
190 #if defined(_MSC_VER)
191 # define XXH_rotl32(x,r) _rotl(x,r)
192 # define XXH_rotl64(x,r) _rotl64(x,r)
194 # define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
195 # define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r)))
198 #if defined(_MSC_VER)
199 # define XXH_swap32 _byteswap_ulong
200 #elif XXH_GCC_VERSION >= 403
201 # define XXH_swap32 __builtin_bswap32
205 return ((
x << 24) & 0xff000000 ) |
206 ((
x << 8) & 0x00ff0000 ) |
207 ((
x >> 8) & 0x0000ff00 ) |
208 ((
x >> 24) & 0x000000ff );
219 #ifndef XXH_CPU_LITTLE_ENDIAN
222 const union {
U32 u;
BYTE c[4]; } one = { 1 };
225 # define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian()
256 #define XXH_STATIC_ASSERT(c) { enum { XXH_sa = 1/(int)(!!(c)) }; }
288 #define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
298 h32 += (*p++) * PRIME32_5; \
299 h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
302 h32 += XXH_get32bits(p) * PRIME32_3; \
304 h32 = XXH_rotl32(h32, 17) * PRIME32_4 ;
356 const BYTE* bEnd = p + len;
359 #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
362 bEnd=p=(
const BYTE*)(
size_t)16;
367 const BYTE*
const limit = bEnd - 15;
404 if ((((
size_t)input) & 3) == 0) {
434 memcpy(dstState, srcState,
sizeof(*dstState));
455 #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
461 {
const BYTE* p = (
const BYTE*)input;
462 const BYTE*
const bEnd = p + len;
464 state->total_len_32 += (unsigned)len;
465 state->large_len |= (len>=16) | (
state->total_len_32>=16);
467 if (
state->memsize + len < 16) {
469 state->memsize += (unsigned)len;
473 if (
state->memsize) {
481 p += 16-
state->memsize;
486 const BYTE*
const limit = bEnd - 16;
507 state->memsize = (unsigned)(bEnd-p);
531 if (
state->large_len) {
540 h32 +=
state->total_len_32;
578 #ifndef XXH_NO_LONG_LONG
588 # if !defined (__VMS) \
589 && (defined (__cplusplus) \
590 || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) ) )
592 typedef uint64_t
U64;
595 typedef unsigned long long U64;
600 #if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
605 #elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
609 typedef union {
U32 u32;
U64 u64; } __attribute__((packed)) unalign64;
621 memcpy(&val, memPtr,
sizeof(val));
627 #if defined(_MSC_VER)
628 # define XXH_swap64 _byteswap_uint64
629 #elif XXH_GCC_VERSION >= 403
630 # define XXH_swap64 __builtin_bswap64
634 return ((
x << 56) & 0xff00000000000000ULL) |
635 ((
x << 40) & 0x00ff000000000000ULL) |
636 ((
x << 24) & 0x0000ff0000000000ULL) |
637 ((
x << 8) & 0x000000ff00000000ULL) |
638 ((
x >> 8) & 0x00000000ff000000ULL) |
639 ((
x >> 24) & 0x0000000000ff0000ULL) |
640 ((
x >> 40) & 0x000000000000ff00ULL) |
641 ((
x >> 56) & 0x00000000000000ffULL);
699 #define XXH_get64bits(p) XXH_readLE64_align(p, endian, align)
707 #define PROCESS1_64 \
708 h64 ^= (*p++) * PRIME64_5; \
709 h64 = XXH_rotl64(h64, 11) * PRIME64_1;
711 #define PROCESS4_64 \
712 h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1; \
714 h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
716 #define PROCESS8_64 { \
717 U64 const k1 = XXH64_round(0, XXH_get64bits(p)); \
720 h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4; \
815 const BYTE* bEnd = p + len;
818 #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
821 bEnd=p=(
const BYTE*)(
size_t)32;
826 const BYTE*
const limit = bEnd - 32;
867 if ((((
size_t)input) & 7)==0) {
895 memcpy(dstState, srcState,
sizeof(*dstState));
915 #if defined(XXH_ACCEPT_NULL_INPUT_POINTER) && (XXH_ACCEPT_NULL_INPUT_POINTER>=1)
921 {
const BYTE* p = (
const BYTE*)input;
922 const BYTE*
const bEnd = p + len;
924 state->total_len += len;
926 if (
state->memsize + len < 32) {
932 if (
state->memsize) {
938 p += 32-
state->memsize;
943 const BYTE*
const limit = bEnd - 32;
964 state->memsize = (unsigned)(bEnd-p);
985 if (
state->total_len >= 32) {
static U32 XXH32_round(U32 seed, U32 input)
static U64 XXH64_mergeRound(U64 acc, U64 val)
std::size_t hash(const BasicJsonType &j)
hash a JSON value
unsigned long long XXH64_hash_t
XXH_PUBLIC_API XXH32_state_t * XXH32_createState(void)
XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t *statePtr)
XXH_PUBLIC_API XXH64_state_t * XXH64_createState(void)
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, unsigned int seed)
XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t *statePtr)
static U32 XXH32_avalanche(U32 h32)
static U32 XXH_read32(const void *memPtr)
#define XXH_CPU_LITTLE_ENDIAN
static const U64 PRIME64_3
FORCE_INLINE XXH_errorcode XXH32_update_endian(XXH32_state_t *state, const void *input, size_t len, XXH_endianess endian)
static U64 XXH_read64(const void *memPtr)
static U64 XXH64_round(U64 acc, U64 input)
static U64 XXH_readBE64(const void *ptr)
static const U32 PRIME32_5
static U32 XXH32_finalize(U32 h32, const void *ptr, size_t len, XXH_endianess endian, XXH_alignment align)
static void * XXH_memcpy(void *dest, const void *src, size_t size)
FORCE_INLINE U64 XXH64_digest_endian(const XXH64_state_t *state, XXH_endianess endian)
FORCE_INLINE U64 XXH64_endian_align(const void *input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align)
static const U32 PRIME32_3
static const U32 PRIME32_1
#define XXH_VERSION_NUMBER
span_constexpr std::size_t size(span< T, Extent > const &spn)
XXH_PUBLIC_API unsigned long long XXH64(const void *input, size_t len, unsigned long long seed)
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state_in, const void *input, size_t len)
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t *src)
static const U32 PRIME32_2
unsigned int XXH32_hash_t
static void * XXH_malloc(size_t s)
XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t *dst, XXH64_hash_t hash)
XXH_PUBLIC_API unsigned XXH_versionNumber(void)
FORCE_INLINE U32 XXH32_endian_align(const void *input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
FORCE_INLINE U32 XXH_readLE32(const void *ptr, XXH_endianess endian)
static int XXH_isLittleEndian(void)
static void XXH_free(void *p)
static const U64 PRIME64_2
XXH_PUBLIC_API unsigned int XXH32(const void *input, size_t len, unsigned int seed)
FORCE_INLINE U32 XXH32_digest_endian(const XXH32_state_t *state, XXH_endianess endian)
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t *statePtr, unsigned long long seed)
FORCE_INLINE U64 XXH_readLE64(const void *ptr, XXH_endianess endian)
static U64 XXH64_avalanche(U64 h64)
static const U32 PRIME32_4
FORCE_INLINE U64 XXH_readLE64_align(const void *ptr, XXH_endianess endian, XXH_alignment align)
XXH_PUBLIC_API XXH_errorcode XXH64_update(XXH64_state_t *state_in, const void *input, size_t len)
#define XXH_STATIC_ASSERT(c)
static const U64 PRIME64_4
#define assert(condition)
Canonical (big endian) representation of XXH32_hash_t.
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t *src)
XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t *dst, XXH32_hash_t hash)
XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t *dstState, const XXH32_state_t *srcState)
XXH_PUBLIC_API unsigned long long XXH64_digest(const XXH64_state_t *state_in)
FORCE_INLINE XXH_errorcode XXH64_update_endian(XXH64_state_t *state, const void *input, size_t len, XXH_endianess endian)
#define XXH_FORCE_NATIVE_FORMAT
static U32 XXH_readBE32(const void *ptr)
static U32 XXH_swap32(U32 x)
#define XXH_FORCE_ALIGN_CHECK
static const U64 PRIME64_1
XXH_PUBLIC_API unsigned int XXH32_digest(const XXH32_state_t *state_in)
static U64 XXH64_finalize(U64 h64, const void *ptr, size_t len, XXH_endianess endian, XXH_alignment align)
XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t *dstState, const XXH64_state_t *srcState)
FORCE_INLINE U32 XXH_readLE32_align(const void *ptr, XXH_endianess endian, XXH_alignment align)
static const U64 PRIME64_5
static U64 XXH_swap64(U64 x)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:48