updated xxhash
This commit is contained in:
+25
-22
@@ -178,7 +178,7 @@ static U64 XXH_read64(const void* memPtr)
|
|||||||
#endif // XXH_FORCE_DIRECT_MEMORY_ACCESS
|
#endif // XXH_FORCE_DIRECT_MEMORY_ACCESS
|
||||||
|
|
||||||
|
|
||||||
/******************************************
|
/* ****************************************
|
||||||
* Compiler-specific Functions and Macros
|
* Compiler-specific Functions and Macros
|
||||||
******************************************/
|
******************************************/
|
||||||
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||||
@@ -220,7 +220,7 @@ static U64 XXH_swap64 (U64 x)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/***************************************
|
/* *************************************
|
||||||
* Architecture Macros
|
* Architecture Macros
|
||||||
***************************************/
|
***************************************/
|
||||||
typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
||||||
@@ -232,7 +232,7 @@ typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
/* ***************************
|
||||||
* Memory reads
|
* Memory reads
|
||||||
*****************************/
|
*****************************/
|
||||||
typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
|
typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
|
||||||
@@ -264,13 +264,13 @@ FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************
|
/* *************************************
|
||||||
* Macros
|
* Macros
|
||||||
***************************************/
|
***************************************/
|
||||||
#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
|
#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
|
||||||
|
|
||||||
|
|
||||||
/***************************************
|
/* *************************************
|
||||||
* Constants
|
* Constants
|
||||||
***************************************/
|
***************************************/
|
||||||
#define PRIME32_1 2654435761U
|
#define PRIME32_1 2654435761U
|
||||||
@@ -288,7 +288,7 @@ FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
|
|||||||
XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
|
XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
/* ***************************
|
||||||
* Simple Hash Functions
|
* Simple Hash Functions
|
||||||
*****************************/
|
*****************************/
|
||||||
FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
|
FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
|
||||||
@@ -591,27 +591,30 @@ XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr)
|
|||||||
|
|
||||||
/*** Hash feed ***/
|
/*** Hash feed ***/
|
||||||
|
|
||||||
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* state, unsigned int seed)
|
XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed)
|
||||||
{
|
{
|
||||||
state->seed = seed;
|
XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
|
||||||
state->v1 = seed + PRIME32_1 + PRIME32_2;
|
memset(&state, 0, sizeof(state));
|
||||||
state->v2 = seed + PRIME32_2;
|
state.seed = seed;
|
||||||
state->v3 = seed + 0;
|
state.v1 = seed + PRIME32_1 + PRIME32_2;
|
||||||
state->v4 = seed - PRIME32_1;
|
state.v2 = seed + PRIME32_2;
|
||||||
state->total_len = 0;
|
state.v3 = seed + 0;
|
||||||
state->memsize = 0;
|
state.v4 = seed - PRIME32_1;
|
||||||
|
memcpy(statePtr, &state, sizeof(state));
|
||||||
return XXH_OK;
|
return XXH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* state, unsigned long long seed)
|
|
||||||
|
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed)
|
||||||
{
|
{
|
||||||
state->seed = seed;
|
XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
|
||||||
state->v1 = seed + PRIME64_1 + PRIME64_2;
|
memset(&state, 0, sizeof(state));
|
||||||
state->v2 = seed + PRIME64_2;
|
state.seed = seed;
|
||||||
state->v3 = seed + 0;
|
state.v1 = seed + PRIME64_1 + PRIME64_2;
|
||||||
state->v4 = seed - PRIME64_1;
|
state.v2 = seed + PRIME64_2;
|
||||||
state->total_len = 0;
|
state.v3 = seed + 0;
|
||||||
state->memsize = 0;
|
state.v4 = seed - PRIME64_1;
|
||||||
|
memcpy(statePtr, &state, sizeof(state));
|
||||||
return XXH_OK;
|
return XXH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -137,9 +137,9 @@ regular symbol name will be automatically translated by this header.
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Version
|
* Version
|
||||||
***************************************/
|
***************************************/
|
||||||
#define XXH_VERSION_MAJOR 0 /* for breaking interface changes */
|
#define XXH_VERSION_MAJOR 0
|
||||||
#define XXH_VERSION_MINOR 5 /* for new (non-breaking) interface capabilities */
|
#define XXH_VERSION_MINOR 5
|
||||||
#define XXH_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
|
#define XXH_VERSION_RELEASE 0
|
||||||
#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)
|
||||||
XXH_PUBLIC_API unsigned XXH_versionNumber (void);
|
XXH_PUBLIC_API unsigned XXH_versionNumber (void);
|
||||||
|
|
||||||
@@ -201,15 +201,15 @@ XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const v
|
|||||||
XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* statePtr);
|
XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* statePtr);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
These functions calculate the xxHash of an input provided in multiple segments,
|
These functions generate the xxHash of an input provided in multiple segments,
|
||||||
as opposed to provided as a single block.
|
as opposed to provided as a single block.
|
||||||
|
|
||||||
XXH state space must first be allocated, using either static or dynamic method provided above.
|
XXH state must first be allocated, using either static or dynamic method provided above.
|
||||||
|
|
||||||
Start a new hash by initializing state with a seed, using XXHnn_reset().
|
Start a new hash by initializing state with a seed, using XXHnn_reset().
|
||||||
|
|
||||||
Then, feed the hash state by calling XXHnn_update() as many times as necessary.
|
Then, feed the hash state by calling XXHnn_update() as many times as necessary.
|
||||||
Obviously, input must be valid, meaning allocated and read accessible.
|
Obviously, input must be valid, hence allocated and read accessible.
|
||||||
The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
|
The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
|
||||||
|
|
||||||
Finally, a hash value can be produced anytime, by using XXHnn_digest().
|
Finally, a hash value can be produced anytime, by using XXHnn_digest().
|
||||||
@@ -217,7 +217,7 @@ This function returns the nn-bits hash.
|
|||||||
It's nonetheless possible to continue inserting input into the hash state
|
It's nonetheless possible to continue inserting input into the hash state
|
||||||
and later on generate some new hashes, by calling again XXHnn_digest().
|
and later on generate some new hashes, by calling again XXHnn_digest().
|
||||||
|
|
||||||
When you are done, don't forget to free XXH state space if it was allocated dynamically.
|
When done, free XXH state space if it was allocated dynamically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user