Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
xxhash.h File Reference
#include <stddef.h>
Include dependency graph for xxhash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  XXH32_canonical_t
 
struct  XXH64_canonical_t
 

Macros

#define XXH_PUBLIC_API   /* do nothing */
 
#define XXH_VERSION_MAJOR   0
 
#define XXH_VERSION_MINOR   6
 
#define XXH_VERSION_RELEASE   2
 
#define XXH_VERSION_NUMBER   (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
 

Typedefs

typedef unsigned int XXH32_hash_t
 
typedef struct XXH32_state_s XXH32_state_t
 
typedef unsigned long long XXH64_hash_t
 
typedef struct XXH64_state_s XXH64_state_t
 

Enumerations

enum  XXH_errorcode { XXH_OK =0 , XXH_ERROR }
 

Functions

XXH_PUBLIC_API unsigned XXH_versionNumber (void)
 
XXH_PUBLIC_API XXH32_hash_t XXH32 (const void *input, size_t length, unsigned int seed)
 
XXH_PUBLIC_API XXH32_state_tXXH32_createState (void)
 
XXH_PUBLIC_API XXH_errorcode XXH32_freeState (XXH32_state_t *statePtr)
 
XXH_PUBLIC_API void XXH32_copyState (XXH32_state_t *dst_state, const XXH32_state_t *src_state)
 
XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t *statePtr, unsigned int seed)
 
XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t *statePtr, const void *input, size_t length)
 
XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t *statePtr)
 
XXH_PUBLIC_API void XXH32_canonicalFromHash (XXH32_canonical_t *dst, XXH32_hash_t hash)
 
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical (const XXH32_canonical_t *src)
 
XXH_PUBLIC_API XXH64_hash_t XXH64 (const void *input, size_t length, unsigned long long seed)
 
XXH_PUBLIC_API XXH64_state_tXXH64_createState (void)
 
XXH_PUBLIC_API XXH_errorcode XXH64_freeState (XXH64_state_t *statePtr)
 
XXH_PUBLIC_API void XXH64_copyState (XXH64_state_t *dst_state, const XXH64_state_t *src_state)
 
XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t *statePtr, unsigned long long seed)
 
XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t *statePtr, const void *input, size_t length)
 
XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t *statePtr)
 
XXH_PUBLIC_API void XXH64_canonicalFromHash (XXH64_canonical_t *dst, XXH64_hash_t hash)
 
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical (const XXH64_canonical_t *src)
 

Macro Definition Documentation

◆ XXH_PUBLIC_API

#define XXH_PUBLIC_API   /* do nothing */

XXH_PRIVATE_API This is useful to include xxhash functions in static mode in order to inline them, and remove their symbol from the public list. Methodology : #define XXH_PRIVATE_API #include "xxhash.h" xxhash.c is automatically included. It's not useful to compile and link it as a separate module.

Definition at line 108 of file xxhash.h.

◆ XXH_VERSION_MAJOR

#define XXH_VERSION_MAJOR   0

XXH_NAMESPACE, aka Namespace Emulation :

If you want to include and expose xxHash functions from within your own library, but also want to avoid symbol collisions with other libraries which may also include xxHash,

you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library with the value of XXH_NAMESPACE (therefore, avoid NULL and numeric values).

Note that no change is required within the calling program as long as it includes xxhash.h : regular symbol name will be automatically translated by this header.

Definition at line 150 of file xxhash.h.

◆ XXH_VERSION_MINOR

#define XXH_VERSION_MINOR   6

Definition at line 151 of file xxhash.h.

◆ XXH_VERSION_NUMBER

#define XXH_VERSION_NUMBER   (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)

Definition at line 153 of file xxhash.h.

◆ XXH_VERSION_RELEASE

#define XXH_VERSION_RELEASE   2

Definition at line 152 of file xxhash.h.

Typedef Documentation

◆ XXH32_hash_t

typedef unsigned int XXH32_hash_t

Definition at line 160 of file xxhash.h.

◆ XXH32_state_t

typedef struct XXH32_state_s XXH32_state_t

Definition at line 170 of file xxhash.h.

◆ XXH64_hash_t

typedef unsigned long long XXH64_hash_t

Definition at line 218 of file xxhash.h.

◆ XXH64_state_t

typedef struct XXH64_state_s XXH64_state_t

Definition at line 228 of file xxhash.h.

Enumeration Type Documentation

◆ XXH_errorcode

Enumerator
XXH_OK 
XXH_ERROR 

Definition at line 79 of file xxhash.h.

XXH_errorcode
Definition xxhash.h:79
@ XXH_ERROR
Definition xxhash.h:79
@ XXH_OK
Definition xxhash.h:79

Function Documentation

◆ XXH32()

XXH_PUBLIC_API XXH32_hash_t XXH32 ( const void * input,
size_t length,
unsigned int seed )

XXH32() : Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input". The memory between input & input+length must be valid (allocated and read-accessible). "seed" can be used to alter the result predictably. Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s

Definition at line 320 of file xxhash.c.

321{
322#if 0
323 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
325 XXH32_reset(&state, seed);
326 XXH32_update(&state, input, len);
327 return XXH32_digest(&state);
328#else
330
332 if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */
333 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
334 return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
335 else
336 return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
337 } }
338
339 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
341 else
342 return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
343#endif
344}
XXH_PUBLIC_API unsigned int XXH32_digest(const XXH32_state_t *state_in)
Definition xxhash.c:484
FORCE_INLINE U32 XXH32_endian_align(const void *input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
Definition xxhash.c:263
XXH_endianess
Definition xxhash.c:206
@ XXH_littleEndian
Definition xxhash.c:206
@ XXH_bigEndian
Definition xxhash.c:206
#define XXH_CPU_LITTLE_ENDIAN
Definition xxhash.c:211
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, unsigned int seed)
Definition xxhash.c:365
@ XXH_aligned
Definition xxhash.c:218
@ XXH_unaligned
Definition xxhash.c:218
#define XXH_FORCE_ALIGN_CHECK
Definition xxhash.c:91
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state_in, const void *input, size_t len)
Definition xxhash.c:436
#define XXH_FORCE_NATIVE_FORMAT
Definition xxhash.c:77
struct XXH32_state_s XXH32_state_t
Definition xxhash.h:170
size_t len
Here is the call graph for this function:

◆ XXH32_canonicalFromHash()

XXH_PUBLIC_API void XXH32_canonicalFromHash ( XXH32_canonical_t * dst,
XXH32_hash_t hash )

Default XXH result types are basic unsigned 32 and 64 bits. The canonical representation follows human-readable write convention, aka big-endian (large digits first). These functions allow transformation of hash result into and from its canonical format. This way, hash values can be written into a file or buffer, and remain comparable across different systems and programs.

Definition at line 503 of file xxhash.c.

504{
506 if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash);
507 memcpy(dst, &hash, sizeof(*dst));
508}
#define XXH_STATIC_ASSERT(c)
Definition xxhash.c:242
unsigned int XXH32_hash_t
Definition xxhash.h:160
memcpy((char *) pInfo->slotDescription, s, l)
Here is the call graph for this function:

◆ XXH32_copyState()

XXH_PUBLIC_API void XXH32_copyState ( XXH32_state_t * dst_state,
const XXH32_state_t * src_state )

Definition at line 360 of file xxhash.c.

361{
362 memcpy(dstState, srcState, sizeof(*dstState));
363}
Here is the call graph for this function:

◆ XXH32_createState()

XXH_PUBLIC_API XXH32_state_t * XXH32_createState ( void )

Definition at line 350 of file xxhash.c.

351{
352 return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
353}

◆ XXH32_digest()

XXH_PUBLIC_API XXH32_hash_t XXH32_digest ( const XXH32_state_t * statePtr)

Definition at line 484 of file xxhash.c.

485{
487
488 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
489 return XXH32_digest_endian(state_in, XXH_littleEndian);
490 else
491 return XXH32_digest_endian(state_in, XXH_bigEndian);
492}
FORCE_INLINE U32 XXH32_digest_endian(const XXH32_state_t *state, XXH_endianess endian)
Definition xxhash.c:448
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XXH32_freeState()

XXH_PUBLIC_API XXH_errorcode XXH32_freeState ( XXH32_state_t * statePtr)

Definition at line 354 of file xxhash.c.

355{
356 XXH_free(statePtr);
357 return XXH_OK;
358}

◆ XXH32_hashFromCanonical()

XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical ( const XXH32_canonical_t * src)

Definition at line 510 of file xxhash.c.

511{
512 return XXH_readBE32(src);
513}

◆ XXH32_reset()

XXH_PUBLIC_API XXH_errorcode XXH32_reset ( XXH32_state_t * statePtr,
unsigned int seed )

Definition at line 365 of file xxhash.c.

366{
367 XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
368 memset(&state, 0, sizeof(state)-4); /* do not write into reserved, for future removal */
369 state.v1 = seed + PRIME32_1 + PRIME32_2;
370 state.v2 = seed + PRIME32_2;
371 state.v3 = seed + 0;
372 state.v4 = seed - PRIME32_1;
373 memcpy(statePtr, &state, sizeof(state));
374 return XXH_OK;
375}
memset(pInfo->slotDescription, ' ', 64)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XXH32_update()

XXH_PUBLIC_API XXH_errorcode XXH32_update ( XXH32_state_t * statePtr,
const void * input,
size_t length )

Definition at line 436 of file xxhash.c.

437{
439
440 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
441 return XXH32_update_endian(state_in, input, len, XXH_littleEndian);
442 else
443 return XXH32_update_endian(state_in, input, len, XXH_bigEndian);
444}
FORCE_INLINE XXH_errorcode XXH32_update_endian(XXH32_state_t *state, const void *input, size_t len, XXH_endianess endian)
Definition xxhash.c:378
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XXH64()

XXH_PUBLIC_API XXH64_hash_t XXH64 ( const void * input,
size_t length,
unsigned long long seed )

XXH64() : Calculate the 64-bits hash of sequence of length "len" stored at memory address "input". "seed" can be used to alter the result predictably. This function runs faster on 64-bits systems, but slower on 32-bits systems (see benchmark).

Definition at line 692 of file xxhash.c.

693{
694#if 0
695 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
697 XXH64_reset(&state, seed);
698 XXH64_update(&state, input, len);
699 return XXH64_digest(&state);
700#else
702
704 if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */
705 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
706 return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
707 else
708 return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
709 } }
710
711 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
713 else
714 return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
715#endif
716}
XXH_PUBLIC_API XXH_errorcode XXH64_update(XXH64_state_t *state_in, const void *input, size_t len)
Definition xxhash.c:802
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t *statePtr, unsigned long long seed)
Definition xxhash.c:735
XXH_PUBLIC_API unsigned long long XXH64_digest(const XXH64_state_t *state_in)
Definition xxhash.c:863
FORCE_INLINE U64 XXH64_endian_align(const void *input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align)
Definition xxhash.c:623
struct XXH64_state_s XXH64_state_t
Definition xxhash.h:228
Here is the call graph for this function:

◆ XXH64_canonicalFromHash()

XXH_PUBLIC_API void XXH64_canonicalFromHash ( XXH64_canonical_t * dst,
XXH64_hash_t hash )

Definition at line 876 of file xxhash.c.

877{
879 if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash);
880 memcpy(dst, &hash, sizeof(*dst));
881}
unsigned long long XXH64_hash_t
Definition xxhash.h:218
Here is the call graph for this function:

◆ XXH64_copyState()

XXH_PUBLIC_API void XXH64_copyState ( XXH64_state_t * dst_state,
const XXH64_state_t * src_state )

Definition at line 730 of file xxhash.c.

731{
732 memcpy(dstState, srcState, sizeof(*dstState));
733}
Here is the call graph for this function:

◆ XXH64_createState()

XXH_PUBLIC_API XXH64_state_t * XXH64_createState ( void )

Definition at line 720 of file xxhash.c.

721{
722 return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t));
723}

◆ XXH64_digest()

XXH_PUBLIC_API XXH64_hash_t XXH64_digest ( const XXH64_state_t * statePtr)

Definition at line 863 of file xxhash.c.

864{
866
867 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
868 return XXH64_digest_endian(state_in, XXH_littleEndian);
869 else
870 return XXH64_digest_endian(state_in, XXH_bigEndian);
871}
FORCE_INLINE U64 XXH64_digest_endian(const XXH64_state_t *state, XXH_endianess endian)
Definition xxhash.c:812
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XXH64_freeState()

XXH_PUBLIC_API XXH_errorcode XXH64_freeState ( XXH64_state_t * statePtr)

Definition at line 724 of file xxhash.c.

725{
726 XXH_free(statePtr);
727 return XXH_OK;
728}

◆ XXH64_hashFromCanonical()

XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical ( const XXH64_canonical_t * src)

Definition at line 883 of file xxhash.c.

884{
885 return XXH_readBE64(src);
886}

◆ XXH64_reset()

XXH_PUBLIC_API XXH_errorcode XXH64_reset ( XXH64_state_t * statePtr,
unsigned long long seed )

Definition at line 735 of file xxhash.c.

736{
737 XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
738 memset(&state, 0, sizeof(state)-8); /* do not write into reserved, for future removal */
739 state.v1 = seed + PRIME64_1 + PRIME64_2;
740 state.v2 = seed + PRIME64_2;
741 state.v3 = seed + 0;
742 state.v4 = seed - PRIME64_1;
743 memcpy(statePtr, &state, sizeof(state));
744 return XXH_OK;
745}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XXH64_update()

XXH_PUBLIC_API XXH_errorcode XXH64_update ( XXH64_state_t * statePtr,
const void * input,
size_t length )

Definition at line 802 of file xxhash.c.

803{
805
806 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
807 return XXH64_update_endian(state_in, input, len, XXH_littleEndian);
808 else
809 return XXH64_update_endian(state_in, input, len, XXH_bigEndian);
810}
FORCE_INLINE XXH_errorcode XXH64_update_endian(XXH64_state_t *state, const void *input, size_t len, XXH_endianess endian)
Definition xxhash.c:747
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XXH_versionNumber()

XXH_PUBLIC_API unsigned XXH_versionNumber ( void )

Definition at line 243 of file xxhash.c.

243{ return XXH_VERSION_NUMBER; }
#define XXH_VERSION_NUMBER
Definition xxhash.h:153