ReactOS 0.4.15-dev-7674-gc0b4db1
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 XXHASH_H_5627135585666179   1
 
#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)
 
#define restrict   /* disable restrict */
 

Typedefs

typedef unsigned int XXH32_hash_t
 
typedef unsigned long long XXH64_hash_t
 
typedef struct XXH32_state_s XXH32_state_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 XXH64_hash_t XXH64 (const void *input, size_t length, unsigned long long seed)
 
XXH_PUBLIC_API XXH32_state_tXXH32_createState (void)
 
XXH_PUBLIC_API XXH_errorcode XXH32_freeState (XXH32_state_t *statePtr)
 
XXH_PUBLIC_API XXH64_state_tXXH64_createState (void)
 
XXH_PUBLIC_API XXH_errorcode XXH64_freeState (XXH64_state_t *statePtr)
 
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 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 XXH32_copyState (XXH32_state_t *restrict dst_state, const XXH32_state_t *restrict src_state)
 
XXH_PUBLIC_API void XXH64_copyState (XXH64_state_t *restrict dst_state, const XXH64_state_t *restrict src_state)
 
XXH_PUBLIC_API void XXH32_canonicalFromHash (XXH32_canonical_t *dst, XXH32_hash_t hash)
 
XXH_PUBLIC_API void XXH64_canonicalFromHash (XXH64_canonical_t *dst, XXH64_hash_t hash)
 
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical (const XXH32_canonical_t *src)
 
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical (const XXH64_canonical_t *src)
 

Macro Definition Documentation

◆ restrict

#define restrict   /* disable restrict */

Definition at line 231 of file xxhash.h.

◆ XXH_PUBLIC_API

#define XXH_PUBLIC_API   /* do nothing */

XXH_PRIVATE_API This is useful if you want 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 anymore.

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 another library which also includes xxHash,

you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library with the value of XXH_NAMESPACE (so avoid to keep it NULL and avoid 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.

◆ XXHASH_H_5627135585666179

#define XXHASH_H_5627135585666179   1

Definition at line 72 of file xxhash.h.

Typedef Documentation

◆ XXH32_hash_t

Definition at line 160 of file xxhash.h.

◆ XXH32_state_t

typedef struct XXH32_state_s XXH32_state_t

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 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 2x faster on 64-bits systems, but slower on 32-bits systems (see benchmark).

Definition at line 182 of file xxhash.h.

◆ XXH64_hash_t

Definition at line 161 of file xxhash.h.

◆ XXH64_state_t

typedef struct XXH64_state_s XXH64_state_t

Definition at line 183 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 
)

Definition at line 443 of file xxhash.c.

444{
445#if 0
446 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
447 XXH32_CREATESTATE_STATIC(state);
448 XXH32_reset(state, seed);
450 return XXH32_digest(state);
451#else
453
455 if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */
456 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
458 else
460 } }
461
462 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
464 else
466#endif
467}
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
GLenum GLenum GLenum input
Definition: glext.h:9031
XXH_PUBLIC_API unsigned int XXH32_digest(const XXH32_state_t *state_in)
Definition: xxhash.c:741
XXH_endianess
Definition: xxhash.c:285
@ XXH_littleEndian
Definition: xxhash.c:285
@ XXH_bigEndian
Definition: xxhash.c:285
#define XXH_CPU_LITTLE_ENDIAN
Definition: xxhash.c:290
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t *statePtr, unsigned int seed)
Definition: xxhash.c:609
FORCE_INLINE_TEMPLATE U32 XXH32_endian_align(const void *input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
Definition: xxhash.c:386
@ XXH_aligned
Definition: xxhash.c:297
@ XXH_unaligned
Definition: xxhash.c:297
#define XXH_FORCE_ALIGN_CHECK
Definition: xxhash.c:90
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state_in, const void *input, size_t len)
Definition: xxhash.c:693
#define XXH_FORCE_NATIVE_FORMAT
Definition: xxhash.c:77

◆ 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 895 of file xxhash.c.

896{
899 memcpy(dst, &hash, sizeof(*dst));
900}
GLenum GLenum dst
Definition: glext.h:6340
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: _hash_fun.h:40
#define XXH_STATIC_ASSERT(c)
Definition: xxhash.c:339
static U32 XXH_swap32(U32 x)
Definition: xxhash.c:261
unsigned int XXH32_hash_t
Definition: xxhash.h:160

◆ XXH32_copyState()

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

Definition at line 363 of file xxhash.c.

364{
365 memcpy(dstState, srcState, sizeof(*dstState));
366}

◆ XXH32_createState()

XXH_PUBLIC_API XXH32_state_t * XXH32_createState ( void  )

State allocation, compatible with dynamic libraries

Definition at line 586 of file xxhash.c.

587{
588 return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
589}
static void * XXH_malloc(size_t s)
Definition: xxhash.c:115
struct XXH32_state_s XXH32_state_t
Definition: xxhash.h:182

◆ XXH32_digest()

XXH_PUBLIC_API XXH32_hash_t XXH32_digest ( const XXH32_state_t statePtr)

Definition at line 741 of file xxhash.c.

742{
744
745 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
746 return XXH32_digest_endian(state_in, XXH_littleEndian);
747 else
748 return XXH32_digest_endian(state_in, XXH_bigEndian);
749}
FORCE_INLINE_TEMPLATE U32 XXH32_digest_endian(const XXH32_state_t *state, XXH_endianess endian)
Definition: xxhash.c:705

Referenced by XXH32().

◆ XXH32_freeState()

XXH_PUBLIC_API XXH_errorcode XXH32_freeState ( XXH32_state_t statePtr)

Definition at line 590 of file xxhash.c.

591{
592 XXH_free(statePtr);
593 return XXH_OK;
594}
static void XXH_free(void *p)
Definition: xxhash.c:119

◆ XXH32_hashFromCanonical()

XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical ( const XXH32_canonical_t src)

Definition at line 909 of file xxhash.c.

910{
911 return XXH_readBE32(src);
912}
GLenum src
Definition: glext.h:6340
static U32 XXH_readBE32(const void *ptr)
Definition: xxhash.c:312

◆ XXH32_reset()

XXH_PUBLIC_API XXH_errorcode XXH32_reset ( XXH32_state_t statePtr,
unsigned int  seed 
)

Definition at line 609 of file xxhash.c.

610{
611 XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
612 memset(&state, 0, sizeof(state)-4); /* do not write into reserved, for future removal */
613 state.v1 = seed + PRIME32_1 + PRIME32_2;
614 state.v2 = seed + PRIME32_2;
615 state.v3 = seed + 0;
616 state.v4 = seed - PRIME32_1;
617 memcpy(statePtr, &state, sizeof(state));
618 return XXH_OK;
619}
#define memset(x, y, z)
Definition: compat.h:39
static const U32 PRIME32_1
Definition: xxhash.c:345
static const U32 PRIME32_2
Definition: xxhash.c:346

Referenced by XXH32().

◆ XXH32_update()

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

Definition at line 693 of file xxhash.c.

694{
696
697 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
698 return XXH32_update_endian(state_in, input, len, XXH_littleEndian);
699 else
700 return XXH32_update_endian(state_in, input, len, XXH_bigEndian);
701}
FORCE_INLINE_TEMPLATE XXH_errorcode XXH32_update_endian(XXH32_state_t *state, const void *input, size_t len, XXH_endianess endian)
Definition: xxhash.c:635

Referenced by XXH32().

◆ XXH64()

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

Definition at line 555 of file xxhash.c.

556{
557#if 0
558 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
559 XXH64_CREATESTATE_STATIC(state);
560 XXH64_reset(state, seed);
562 return XXH64_digest(state);
563#else
565
567 if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */
568 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
570 else
572 } }
573
574 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
576 else
578#endif
579}
XXH_PUBLIC_API XXH_errorcode XXH64_update(XXH64_state_t *state_in, const void *input, size_t len)
Definition: xxhash.c:810
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t *statePtr, unsigned long long seed)
Definition: xxhash.c:622
XXH_PUBLIC_API unsigned long long XXH64_digest(const XXH64_state_t *state_in)
Definition: xxhash.c:874
FORCE_INLINE_TEMPLATE U64 XXH64_endian_align(const void *input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align)
Definition: xxhash.c:486

Referenced by calc_superblock_checksum(), calc_thread_main(), calc_tree_checksum(), check_sector_csum(), check_superblock_checksum(), check_tree_checksum(), get_sector_csum(), and get_tree_checksum().

◆ XXH64_canonicalFromHash()

XXH_PUBLIC_API void XXH64_canonicalFromHash ( XXH64_canonical_t dst,
XXH64_hash_t  hash 
)

Definition at line 902 of file xxhash.c.

903{
906 memcpy(dst, &hash, sizeof(*dst));
907}
static U64 XXH_swap64(U64 x)
Definition: xxhash.c:268
unsigned long long XXH64_hash_t
Definition: xxhash.h:161

◆ XXH64_copyState()

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

Definition at line 368 of file xxhash.c.

369{
370 memcpy(dstState, srcState, sizeof(*dstState));
371}

◆ XXH64_createState()

XXH_PUBLIC_API XXH64_state_t * XXH64_createState ( void  )

Definition at line 596 of file xxhash.c.

597{
598 return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t));
599}
struct XXH64_state_s XXH64_state_t
Definition: xxhash.h:183

◆ XXH64_digest()

XXH_PUBLIC_API XXH64_hash_t XXH64_digest ( const XXH64_state_t statePtr)

Definition at line 874 of file xxhash.c.

875{
877
878 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
879 return XXH64_digest_endian(state_in, XXH_littleEndian);
880 else
881 return XXH64_digest_endian(state_in, XXH_bigEndian);
882}
FORCE_INLINE_TEMPLATE U64 XXH64_digest_endian(const XXH64_state_t *state, XXH_endianess endian)
Definition: xxhash.c:822

Referenced by XXH64(), ZSTD_decompressContinue(), ZSTD_decompressFrame(), and ZSTD_writeEpilogue().

◆ XXH64_freeState()

XXH_PUBLIC_API XXH_errorcode XXH64_freeState ( XXH64_state_t statePtr)

Definition at line 600 of file xxhash.c.

601{
602 XXH_free(statePtr);
603 return XXH_OK;
604}

◆ XXH64_hashFromCanonical()

XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical ( const XXH64_canonical_t src)

Definition at line 914 of file xxhash.c.

915{
916 return XXH_readBE64(src);
917}
static U64 XXH_readBE64(const void *ptr)
Definition: xxhash.c:330

◆ XXH64_reset()

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

Definition at line 622 of file xxhash.c.

623{
624 XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
625 memset(&state, 0, sizeof(state)-8); /* do not write into reserved, for future removal */
626 state.v1 = seed + PRIME64_1 + PRIME64_2;
627 state.v2 = seed + PRIME64_2;
628 state.v3 = seed + 0;
629 state.v4 = seed - PRIME64_1;
630 memcpy(statePtr, &state, sizeof(state));
631 return XXH_OK;
632}
static const U64 PRIME64_2
Definition: xxhash.c:352
static const U64 PRIME64_1
Definition: xxhash.c:351

Referenced by XXH64(), ZSTD_decodeFrameHeader(), and ZSTD_resetCCtx_internal().

◆ XXH64_update()

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

Definition at line 810 of file xxhash.c.

811{
813
814 if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
815 return XXH64_update_endian(state_in, input, len, XXH_littleEndian);
816 else
817 return XXH64_update_endian(state_in, input, len, XXH_bigEndian);
818}
FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian(XXH64_state_t *state, const void *input, size_t len, XXH_endianess endian)
Definition: xxhash.c:755

Referenced by XXH64(), ZSTD_compress_frameChunk(), ZSTD_decompressContinue(), and ZSTD_decompressFrame().

◆ XXH_versionNumber()

XXH_PUBLIC_API unsigned XXH_versionNumber ( void  )

Definition at line 357 of file xxhash.c.

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