updated xxhash

This commit is contained in:
Yann Collet 2016-01-06 01:37:46 +01:00
parent 5835e1b5ba
commit 8ab94b653c
2 changed files with 35 additions and 32 deletions

View File

@ -84,7 +84,7 @@ You can contact the author at :
#endif
/**************************************
/* *************************************
* Compiler Specific Options
***************************************/
#ifdef _MSC_VER /* Visual Studio */
@ -103,7 +103,7 @@ You can contact the author at :
#endif
/**************************************
/* *************************************
* Includes & Memory related functions
***************************************/
/* Modify the local functions below should you wish to use some other memory routines */
@ -118,7 +118,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp
#include "xxhash.h"
/**************************************
/* *************************************
* Basic Types
***************************************/
#ifndef MEM_MODULE
@ -178,7 +178,7 @@ static U64 XXH_read64(const void* memPtr)
#endif // XXH_FORCE_DIRECT_MEMORY_ACCESS
/******************************************
/* ****************************************
* Compiler-specific Functions and Macros
******************************************/
#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
@ -220,7 +220,7 @@ static U64 XXH_swap64 (U64 x)
#endif
/***************************************
/* *************************************
* Architecture Macros
***************************************/
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
/*****************************
/* ***************************
* Memory reads
*****************************/
typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
@ -264,13 +264,13 @@ FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
}
/***************************************
/* *************************************
* Macros
***************************************/
#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
/***************************************
/* *************************************
* Constants
***************************************/
#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; }
/*****************************
/* ***************************
* Simple Hash Functions
*****************************/
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 ***/
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;
state->v1 = seed + PRIME32_1 + PRIME32_2;
state->v2 = seed + PRIME32_2;
state->v3 = seed + 0;
state->v4 = seed - PRIME32_1;
state->total_len = 0;
state->memsize = 0;
XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
memset(&state, 0, sizeof(state));
state.seed = seed;
state.v1 = seed + PRIME32_1 + PRIME32_2;
state.v2 = seed + PRIME32_2;
state.v3 = seed + 0;
state.v4 = seed - PRIME32_1;
memcpy(statePtr, &state, sizeof(state));
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;
state->v1 = seed + PRIME64_1 + PRIME64_2;
state->v2 = seed + PRIME64_2;
state->v3 = seed + 0;
state->v4 = seed - PRIME64_1;
state->total_len = 0;
state->memsize = 0;
XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
memset(&state, 0, sizeof(state));
state.seed = seed;
state.v1 = seed + PRIME64_1 + PRIME64_2;
state.v2 = seed + PRIME64_2;
state.v3 = seed + 0;
state.v4 = seed - PRIME64_1;
memcpy(statePtr, &state, sizeof(state));
return XXH_OK;
}

View File

@ -137,9 +137,9 @@ regular symbol name will be automatically translated by this header.
/* *************************************
* Version
***************************************/
#define XXH_VERSION_MAJOR 0 /* for breaking interface changes */
#define XXH_VERSION_MINOR 5 /* for new (non-breaking) interface capabilities */
#define XXH_VERSION_RELEASE 0 /* for tweaks, bug-fixes, or development */
#define XXH_VERSION_MAJOR 0
#define XXH_VERSION_MINOR 5
#define XXH_VERSION_RELEASE 0
#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
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);
/*!
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.
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().
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.
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
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.
*/