Turnstone Operating System
Loading...
Searching...
No Matches
xxhash.64.c File Reference

xxHash - Extremely Fast Hash algorithm implementation. More...

#include <xxhash.h>
#include <utils.h>
#include <memory.h>

Classes

struct  xxhash64_context_t
 xxHash 64-bit context structure More...
 
struct  xxhash32_context_t
 xxhash32 context More...
 

Macros

#define XXHASH64_PRIME1   11400714785074694791ULL
 
#define XXHASH64_PRIME2   14029467366897019727ULL
 
#define XXHASH64_PRIME3   1609587929392839161ULL
 
#define XXHASH64_PRIME4   9650029242287828579ULL
 
#define XXHASH64_PRIME5   2870177450012600261ULL
 
#define XXHASH64_MAXBUFFERSIZE   32
 
#define XXHASH32_PRIME1   2654435761U
 
#define XXHASH32_PRIME2   2246822519U
 
#define XXHASH32_PRIME3   3266489917U
 
#define XXHASH32_PRIME4   668265263U
 
#define XXHASH32_PRIME5   374761393U
 
#define XXHASH32_MAXBUFFERSIZE   16
 

Typedefs

typedef struct xxhash64_context_t xxhash64_context_t
 xxHash 64-bit context type More...
 
typedef struct xxhash32_context_t xxhash32_context_t
 xxhash32 context type More...
 

Functions

 MODULE ("turnstone.lib.xxhash")
 
static uint64_t xxhash64_process_single (uint64_t prev, uint64_t curr)
 process single 64-bit block More...
 
static void xxhash64_process (const void *data, uint64_t *state0, uint64_t *state1, uint64_t *state2, uint64_t *state3)
 process 64-bit block More...
 
static xxhash64_context_txxhhash64_init_without_malloc (xxhash64_context_t *ctx, uint64_t seed)
 
static uint64_t xxhash64_final_without_free (xxhash64_context_t *ctx)
 
uint64_t xxhash64_hash_with_seed (const void *input, uint64_t length, uint64_t seed)
 calculate xxhash64 value More...
 
xxhash64_context_txxhash64_init (uint64_t seed)
 initialize xxhash64 context More...
 
uint64_t xxhash64_final (xxhash64_context_t *ctx)
 finalize xxhash64 context More...
 
int8_t xxhash64_update (xxhash64_context_t *ctx, const void *input, uint64_t length)
 update xxhash64 context More...
 
static uint32_t xxhash32_process_single (uint32_t prev, uint32_t curr)
 xxhash32 process single More...
 
static void xxhash32_process (const void *data, uint32_t *state0, uint32_t *state1, uint32_t *state2, uint32_t *state3)
 xxhash32 process block More...
 
uint32_t xxhash32_hash_with_seed (const void *input, uint64_t length, uint32_t seed)
 calculate xxhash32 value More...
 
xxhash32_context_txxhash32_init (uint32_t seed)
 initialize xxhash32 context More...
 
uint32_t xxhash32_final (xxhash32_context_t *ctx)
 finalize xxhash32 context More...
 
int8_t xxhash32_update (xxhash32_context_t *ctx, const void *input, uint64_t length)
 update xxhash32 context More...
 

Detailed Description

xxHash - Extremely Fast Hash algorithm implementation.

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ XXHASH32_MAXBUFFERSIZE

#define XXHASH32_MAXBUFFERSIZE   16

xxHash 32-bit max buffer size

◆ XXHASH32_PRIME1

#define XXHASH32_PRIME1   2654435761U

xxHash 32-bit prime constant 1

◆ XXHASH32_PRIME2

#define XXHASH32_PRIME2   2246822519U

xxHash 32-bit prime constant 2

◆ XXHASH32_PRIME3

#define XXHASH32_PRIME3   3266489917U

xxHash 32-bit prime constant 3

◆ XXHASH32_PRIME4

#define XXHASH32_PRIME4   668265263U

xxHash 32-bit prime constant 4

◆ XXHASH32_PRIME5

#define XXHASH32_PRIME5   374761393U

xxHash 32-bit prime constant 5

◆ XXHASH64_MAXBUFFERSIZE

#define XXHASH64_MAXBUFFERSIZE   32

xxHash 64-bit max buffer size

◆ XXHASH64_PRIME1

#define XXHASH64_PRIME1   11400714785074694791ULL

xxHash 64-bit prime constant 1

◆ XXHASH64_PRIME2

#define XXHASH64_PRIME2   14029467366897019727ULL

xxHash 64-bit prime constant 2

◆ XXHASH64_PRIME3

#define XXHASH64_PRIME3   1609587929392839161ULL

xxHash 64-bit prime constant 3

◆ XXHASH64_PRIME4

#define XXHASH64_PRIME4   9650029242287828579ULL

xxHash 64-bit prime constant 4

◆ XXHASH64_PRIME5

#define XXHASH64_PRIME5   2870177450012600261ULL

xxHash 64-bit prime constant 5

Typedef Documentation

◆ xxhash32_context_t

xxhash32 context type

opaque xxhash32 context structure

◆ xxhash64_context_t

xxHash 64-bit context type

opaque xxhash64 context structure

Function Documentation

◆ MODULE()

MODULE ( "turnstone.lib.xxhash"  )

module name

◆ xxhash32_final()

uint32_t xxhash32_final ( xxhash32_context_t ctx)

finalize xxhash32 context

call this function after calling xxhash32_update(), also destroy xxhash32 context

Parameters
[in]ctxxxhash32 context
Returns
xxhash32 value

◆ xxhash32_hash_with_seed()

uint32_t xxhash32_hash_with_seed ( const void *  input,
uint64_t  length,
uint32_t  seed 
)

calculate xxhash32 value

Parameters
[in]inputinput data
[in]lengthinput data length
[in]seedseed value
Returns
xxhash32 value

◆ xxhash32_init()

xxhash32_context_t * xxhash32_init ( uint32_t  seed)

initialize xxhash32 context

Parameters
[in]seedseed value
Returns
xxhash32 context

◆ xxhash32_process()

static void xxhash32_process ( const void *  data,
uint32_t state0,
uint32_t state1,
uint32_t state2,
uint32_t state3 
)
inlinestatic

xxhash32 process block

Parameters
[in]datadata
[in,out]state0state 0
[in,out]state1state 1
[in,out]state2state 2
[in,out]state3state 3

◆ xxhash32_process_single()

static uint32_t xxhash32_process_single ( uint32_t  prev,
uint32_t  curr 
)
inlinestatic

xxhash32 process single

Parameters
[in]prevprevious value
[in]currcurrent value
Returns
processed value

◆ xxhash32_update()

int8_t xxhash32_update ( xxhash32_context_t ctx,
const void *  input,
uint64_t  length 
)

update xxhash32 context

Parameters
[in]ctxxxhash32 context
[in]inputinput data
[in]lengthinput data length
Returns
0 if success, -1 if error

◆ xxhash64_final()

uint64_t xxhash64_final ( xxhash64_context_t ctx)

finalize xxhash64 context

call this function after calling xxhash64_update(), also destroy xxhash64 context

Parameters
[in]ctxxxhash64 context
Returns
xxhash64 value

◆ xxhash64_hash_with_seed()

uint64_t xxhash64_hash_with_seed ( const void *  input,
uint64_t  length,
uint64_t  seed 
)

calculate xxhash64 value

Parameters
[in]inputinput data
[in]lengthinput data length
[in]seedseed value
Returns
xxhash64 value

◆ xxhash64_init()

xxhash64_context_t * xxhash64_init ( uint64_t  seed)

initialize xxhash64 context

Parameters
[in]seedseed value
Returns
xxhash64 context

◆ xxhash64_process()

static void xxhash64_process ( const void *  data,
uint64_t state0,
uint64_t state1,
uint64_t state2,
uint64_t state3 
)
inlinestatic

process 64-bit block

Parameters
[in]datadata
[in,out]state0state 0
[in,out]state1state 1
[in,out]state2state 2
[in,out]state3state 3

◆ xxhash64_process_single()

static uint64_t xxhash64_process_single ( uint64_t  prev,
uint64_t  curr 
)
inlinestatic

process single 64-bit block

Parameters
[in]prevprevious value
[in]currcurrent value
Returns
processed value

◆ xxhash64_update()

int8_t xxhash64_update ( xxhash64_context_t ctx,
const void *  input,
uint64_t  length 
)

update xxhash64 context

Parameters
[in]ctxxxhash64 context
[in]inputinput data
[in]lengthinput data length
Returns
0 if success, -1 if error