xxHash  0.8.0
Extremely fast non-cryptographic hash function
Macros | Functions
XXH32 implementation

Macros

#define XXH_PRIME32_1   0x9E3779B1U
 
#define XXH_PRIME32_2   0x85EBCA77U
 
#define XXH_PRIME32_3   0xC2B2AE3DU
 
#define XXH_PRIME32_4   0x27D4EB2FU
 
#define XXH_PRIME32_5   0x165667B1U
 
#define XXH_get32bits(p)   XXH_readLE32_align(p, align)
 

Functions

static xxh_u32 XXH32_round (xxh_u32 acc, xxh_u32 input)
 Normal stripe processing routine. More...
 
static xxh_u32 XXH32_avalanche (xxh_u32 h32)
 Mixes all bits to finalize the hash. More...
 
static xxh_u32 XXH32_finalize (xxh_u32 h32, const xxh_u8 *ptr, size_t len, XXH_alignment align)
 Processes the last 0-15 bytes of ptr. More...
 
static xxh_u32 XXH32_endian_align (const xxh_u8 *input, size_t len, xxh_u32 seed, XXH_alignment align)
 The implementation for XXH32(). More...
 

Detailed Description

Macro Definition Documentation

◆ XXH_PRIME32_1

#define XXH_PRIME32_1   0x9E3779B1U

0b10011110001101110111100110110001

◆ XXH_PRIME32_2

#define XXH_PRIME32_2   0x85EBCA77U

0b10000101111010111100101001110111

◆ XXH_PRIME32_3

#define XXH_PRIME32_3   0xC2B2AE3DU

0b11000010101100101010111000111101

◆ XXH_PRIME32_4

#define XXH_PRIME32_4   0x27D4EB2FU

0b00100111110101001110101100101111

◆ XXH_PRIME32_5

#define XXH_PRIME32_5   0x165667B1U

0b00010110010101100110011110110001

Function Documentation

◆ XXH32_round()

static xxh_u32 XXH32_round ( xxh_u32  acc,
xxh_u32  input 
)
static

Normal stripe processing routine.

This shuffles the bits so that any bit from input impacts several bits in acc.

Parameters
accThe accumulator lane.
inputThe stripe of input to mix.
Returns
The mixed accumulator lane.

◆ XXH32_avalanche()

static xxh_u32 XXH32_avalanche ( xxh_u32  h32)
static

Mixes all bits to finalize the hash.

The final mix ensures that all input bits have a chance to impact any bit in the output digest, resulting in an unbiased distribution.

Parameters
h32The hash to avalanche.
Returns
The avalanched hash.

◆ XXH32_finalize()

static xxh_u32 XXH32_finalize ( xxh_u32  h32,
const xxh_u8 *  ptr,
size_t  len,
XXH_alignment  align 
)
static

Processes the last 0-15 bytes of ptr.

There may be up to 15 bytes remaining to consume from the input. This final stage will digest them to ensure that all input bytes are present in the final mix.

Parameters
h32The hash to finalize.
ptrThe pointer to the remaining input.
lenThe remaining length, modulo 16.
alignWhether ptr is aligned.
Returns
The finalized hash.

◆ XXH32_endian_align()

static xxh_u32 XXH32_endian_align ( const xxh_u8 *  input,
size_t  len,
xxh_u32  seed,
XXH_alignment  align 
)
inlinestatic

The implementation for XXH32().

Parameters
input,len,seedDirectly passed from XXH32().
alignWhether input is aligned.
Returns
The calculated hash.