Rizin
unix-like reverse engineering framework and cli tools
|
Go to the source code of this file.
Macros | |
#define | XXH_ACCEPT_NULL_INPUT_POINTER 0 |
#define | XXH_FORCE_NATIVE_FORMAT 0 |
#define | XXH_FORCE_ALIGN_CHECK 1 |
#define | XXH_STATIC_LINKING_ONLY |
#define | FORCE_INLINE static |
#define | XXH_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) |
#define | XXH_rotl32(x, r) ((x << r) | (x >> (32 - r))) |
#define | XXH_rotl64(x, r) ((x << r) | (x >> (64 - r))) |
#define | XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() |
#define | XXH_STATIC_ASSERT(c) { enum { XXH_sa = 1/(int)(!!(c)) }; } /* use after variable declarations */ |
#define | XXH_get32bits(p) XXH_readLE32_align(p, endian, align) |
#define | PROCESS1 |
#define | PROCESS4 |
#define | MEM_MODULE |
#define | XXH_get64bits(p) XXH_readLE64_align(p, endian, align) |
#define | PROCESS1_64 |
#define | PROCESS4_64 |
#define | PROCESS8_64 |
Typedefs | |
typedef unsigned char | BYTE |
typedef unsigned short | U16 |
typedef unsigned int | U32 |
typedef unsigned long long | U64 |
Enumerations | |
enum | XXH_endianess { XXH_bigEndian =0 , XXH_littleEndian =1 , XXH_bigEndian =0 , XXH_littleEndian =1 } |
enum | XXH_alignment { XXH_aligned , XXH_unaligned , XXH_aligned , XXH_unaligned } |
Variables | |
static const U32 | PRIME32_1 = 2654435761U |
static const U32 | PRIME32_2 = 2246822519U |
static const U32 | PRIME32_3 = 3266489917U |
static const U32 | PRIME32_4 = 668265263U |
static const U32 | PRIME32_5 = 374761393U |
static const U64 | PRIME64_1 = 11400714785074694791ULL |
static const U64 | PRIME64_2 = 14029467366897019727ULL |
static const U64 | PRIME64_3 = 1609587929392839161ULL |
static const U64 | PRIME64_4 = 9650029242287828579ULL |
static const U64 | PRIME64_5 = 2870177450012600261ULL |
#define PROCESS1 |
#define PROCESS1_64 |
#define PROCESS4 |
#define PROCESS4_64 |
#define PROCESS8_64 |
#define XXH_ACCEPT_NULL_INPUT_POINTER 0 |
XXH_FORCE_MEMORY_ACCESS : By default, access to unaligned memory is controlled by memcpy()
, which is safe and portable. Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal. The below switch allow to select different access method for improved performance. Method 0 (default) : use memcpy()
. Safe and portable. Method 1 : __packed
statement. It depends on compiler extension (ie, not portable). This method is safe if your compiler supports it, and generally as fast or faster than memcpy
. Method 2 : direct access. This method doesn't depend on compiler but violate C standard. It can generate buggy code on targets which do not support unaligned memory accesses. But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6) See http://stackoverflow.com/a/32095106/646947 for details. Prefer these methods in priority order (0 > 1 > 2)
XXH_ACCEPT_NULL_INPUT_POINTER : If input pointer is NULL, xxHash default behavior is to dereference it, triggering a segfault. When this macro is enabled, xxHash actively checks input for null pointer. It it is, result for null input pointers is the same as a null-length input.
#define XXH_CPU_LITTLE_ENDIAN XXH_isLittleEndian() |
#define XXH_FORCE_ALIGN_CHECK 1 |
XXH_FORCE_ALIGN_CHECK : This is a minor performance trick, only useful with lots of very small keys. It means : check for aligned/unaligned input. The check costs one initial branch per hash; set it to 0 when the input is guaranteed to be aligned, or when alignment doesn't matter for performance.
#define XXH_FORCE_NATIVE_FORMAT 0 |
XXH_FORCE_NATIVE_FORMAT : By default, xxHash library provides endian-independent Hash values, based on little-endian convention. Results are therefore identical for little-endian and big-endian CPU. This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format. Should endian-independence be of no importance for your application, you may set the #define below to 1, to improve speed for Big-endian CPU. This option has no impact on Little_Endian CPU.
#define XXH_get32bits | ( | p | ) | XXH_readLE32_align(p, endian, align) |
#define XXH_get64bits | ( | p | ) | XXH_readLE64_align(p, endian, align) |
enum XXH_alignment |
enum XXH_endianess |
XXH32() : Calculate the 32-bit 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
Definition at line 392 of file xxhash.c.
References input(), len, XXH32_digest(), XXH32_endian_align(), XXH32_reset(), XXH32_update(), XXH_aligned, XXH_bigEndian, XXH_CPU_LITTLE_ENDIAN, XXH_FORCE_ALIGN_CHECK, XXH_FORCE_NATIVE_FORMAT, XXH_littleEndian, and XXH_unaligned.
Referenced by fullSpeedBench(), FUZ_test(), FUZ_unitTests(), FUZZ_seed(), fuzzerTests(), LZ4F_decompress(), LZ4F_headerChecksum(), LZ4F_makeBlock(), main(), plugin_xxhash32_small_block(), rz_hash_xxhash(), and select_clevel().
Definition at line 278 of file xxhash.c.
References PRIME32_2, and PRIME32_3.
Referenced by XXH32_finalize().
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, remaining comparable across different systems.
Definition at line 565 of file xxhash.c.
References dst, memcpy(), XXH_CPU_LITTLE_ENDIAN, XXH_STATIC_ASSERT, and XXH_swap32().
XXH_PUBLIC_API void XXH32_copyState | ( | XXH32_state_t * | dstState, |
const XXH32_state_t * | srcState | ||
) |
XXH_PUBLIC_API XXH32_state_t* XXH32_createState | ( | void | ) |
Definition at line 422 of file xxhash.c.
References XXH_malloc().
Referenced by plugin_xxhash32_context_new().
XXH_PUBLIC_API unsigned int XXH32_digest | ( | const XXH32_state_t * | state_in | ) |
Definition at line 546 of file xxhash.c.
References XXH32_digest_endian(), XXH_bigEndian, XXH_CPU_LITTLE_ENDIAN, XXH_FORCE_NATIVE_FORMAT, and XXH_littleEndian.
Referenced by LZ4F_compressEnd(), LZ4F_decompress(), plugin_xxhash32_final(), and XXH32().
FORCE_INLINE U32 XXH32_digest_endian | ( | const XXH32_state_t * | state, |
XXH_endianess | endian | ||
) |
Definition at line 527 of file xxhash.c.
References PRIME32_5, XXH32_finalize(), XXH_aligned, and XXH_rotl32.
Referenced by XXH32_digest().
FORCE_INLINE U32 XXH32_endian_align | ( | const void * | input, |
size_t | len, | ||
U32 | seed, | ||
XXH_endianess | endian, | ||
XXH_alignment | align | ||
) |
Definition at line 352 of file xxhash.c.
References input(), len, limit, NULL, p, PRIME32_1, PRIME32_2, PRIME32_5, v1, XXH32_finalize(), XXH32_round(), XXH_get32bits, and XXH_rotl32.
Referenced by XXH32().
|
static |
Definition at line 291 of file xxhash.c.
References assert(), len, p, PROCESS1, PROCESS4, and XXH32_avalanche().
Referenced by XXH32_digest_endian(), and XXH32_endian_align().
XXH_PUBLIC_API XXH_errorcode XXH32_freeState | ( | XXH32_state_t * | statePtr | ) |
Definition at line 426 of file xxhash.c.
References XXH_free(), and XXH_OK.
Referenced by plugin_xxhash32_context_free().
XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical | ( | const XXH32_canonical_t * | src | ) |
XXH_PUBLIC_API XXH_errorcode XXH32_reset | ( | XXH32_state_t * | statePtr, |
unsigned int | seed | ||
) |
Definition at line 437 of file xxhash.c.
References memcpy(), memset(), PRIME32_1, PRIME32_2, and XXH_OK.
Referenced by LZ4F_compressBegin_usingCDict(), LZ4F_decompress(), plugin_xxhash32_init(), and XXH32().
Definition at line 269 of file xxhash.c.
References input(), PRIME32_1, PRIME32_2, and XXH_rotl32.
Referenced by XXH32_endian_align(), and XXH32_update_endian().
XXH_PUBLIC_API XXH_errorcode XXH32_update | ( | XXH32_state_t * | state_in, |
const void * | input, | ||
size_t | len | ||
) |
Definition at line 515 of file xxhash.c.
References input(), len, XXH32_update_endian(), XXH_bigEndian, XXH_CPU_LITTLE_ENDIAN, XXH_FORCE_NATIVE_FORMAT, and XXH_littleEndian.
Referenced by LZ4F_compressUpdate(), LZ4F_decompress(), plugin_xxhash32_update(), and XXH32().
FORCE_INLINE XXH_errorcode XXH32_update_endian | ( | XXH32_state_t * | state, |
const void * | input, | ||
size_t | len, | ||
XXH_endianess | endian | ||
) |
Definition at line 452 of file xxhash.c.
References input(), len, limit, NULL, p, unsigned, v1, XXH32_round(), XXH_ERROR, XXH_memcpy(), XXH_OK, and XXH_readLE32().
Referenced by XXH32_update().
XXH_PUBLIC_API unsigned long long XXH64 | ( | const void * | input, |
size_t | length, | ||
unsigned long long | seed | ||
) |
XXH64() : Calculate the 64-bit hash of sequence of length "len" stored at memory address "input". "seed" can be used to alter the result predictably. This function runs faster on 64-bit systems, but slower on 32-bit systems (see benchmark).
Definition at line 855 of file xxhash.c.
References input(), len, XXH64_digest(), XXH64_endian_align(), XXH64_reset(), XXH64_update(), XXH_aligned, XXH_bigEndian, XXH_CPU_LITTLE_ENDIAN, XXH_FORCE_ALIGN_CHECK, XXH_FORCE_NATIVE_FORMAT, XXH_littleEndian, and XXH_unaligned.
Referenced by basicTests(), BMK_benchMem(), FUZ_unitTests(), and fuzzerTests().
XXH_PUBLIC_API void XXH64_canonicalFromHash | ( | XXH64_canonical_t * | dst, |
XXH64_hash_t | hash | ||
) |
Definition at line 1018 of file xxhash.c.
References dst, memcpy(), XXH_CPU_LITTLE_ENDIAN, XXH_STATIC_ASSERT, and XXH_swap64().
XXH_PUBLIC_API void XXH64_copyState | ( | XXH64_state_t * | dstState, |
const XXH64_state_t * | srcState | ||
) |
XXH_PUBLIC_API XXH64_state_t* XXH64_createState | ( | void | ) |
Definition at line 883 of file xxhash.c.
References XXH_malloc().
XXH_PUBLIC_API unsigned long long XXH64_digest | ( | const XXH64_state_t * | state_in | ) |
Definition at line 1005 of file xxhash.c.
References XXH64_digest_endian(), XXH_bigEndian, XXH_CPU_LITTLE_ENDIAN, XXH_FORCE_NATIVE_FORMAT, and XXH_littleEndian.
Referenced by FUZ_unitTests(), test_lz4f_decompression_wBuffers(), and XXH64().
FORCE_INLINE U64 XXH64_digest_endian | ( | const XXH64_state_t * | state, |
XXH_endianess | endian | ||
) |
Definition at line 981 of file xxhash.c.
References PRIME64_5, v1, XXH64_finalize(), XXH64_mergeRound(), XXH_aligned, and XXH_rotl64.
Referenced by XXH64_digest().
FORCE_INLINE U64 XXH64_endian_align | ( | const void * | input, |
size_t | len, | ||
U64 | seed, | ||
XXH_endianess | endian, | ||
XXH_alignment | align | ||
) |
Definition at line 811 of file xxhash.c.
References input(), len, limit, NULL, p, PRIME64_1, PRIME64_2, PRIME64_5, v1, XXH64_finalize(), XXH64_mergeRound(), XXH64_round(), XXH_get64bits, and XXH_rotl64.
Referenced by XXH64().
|
static |
Definition at line 702 of file xxhash.c.
References assert(), len, p, PROCESS1_64, PROCESS4_64, PROCESS8_64, and XXH64_avalanche().
Referenced by XXH64_digest_endian(), and XXH64_endian_align().
XXH_PUBLIC_API XXH_errorcode XXH64_freeState | ( | XXH64_state_t * | statePtr | ) |
XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical | ( | const XXH64_canonical_t * | src | ) |
Definition at line 680 of file xxhash.c.
References PRIME64_1, PRIME64_4, val, and XXH64_round().
Referenced by XXH64_digest_endian(), and XXH64_endian_align().
XXH_PUBLIC_API XXH_errorcode XXH64_reset | ( | XXH64_state_t * | statePtr, |
unsigned long long | seed | ||
) |
Definition at line 898 of file xxhash.c.
References memcpy(), memset(), PRIME64_1, PRIME64_2, and XXH_OK.
Referenced by FUZ_unitTests(), test_lz4f_decompression_wBuffers(), and XXH64().
Definition at line 672 of file xxhash.c.
References input(), PRIME64_1, PRIME64_2, and XXH_rotl64.
Referenced by XXH64_endian_align(), XXH64_mergeRound(), and XXH64_update_endian().
XXH_PUBLIC_API XXH_errorcode XXH64_update | ( | XXH64_state_t * | state_in, |
const void * | input, | ||
size_t | len | ||
) |
Definition at line 971 of file xxhash.c.
References input(), len, XXH64_update_endian(), XXH_bigEndian, XXH_CPU_LITTLE_ENDIAN, XXH_FORCE_NATIVE_FORMAT, and XXH_littleEndian.
Referenced by FUZ_unitTests(), test_lz4f_decompression_wBuffers(), and XXH64().
FORCE_INLINE XXH_errorcode XXH64_update_endian | ( | XXH64_state_t * | state, |
const void * | input, | ||
size_t | len, | ||
XXH_endianess | endian | ||
) |
Definition at line 912 of file xxhash.c.
References input(), len, limit, NULL, p, unsigned, v1, XXH64_round(), XXH_ERROR, XXH_memcpy(), XXH_OK, and XXH_readLE64().
Referenced by XXH64_update().
|
static |
|
static |
|
static |
Modify the local functions below should you wish to use some other memory routines for malloc(), free()
Definition at line 108 of file xxhash.c.
Referenced by XXH32_createState(), and XXH64_createState().
Definition at line 247 of file xxhash.c.
References XXH_CPU_LITTLE_ENDIAN, XXH_read32(), and XXH_swap32().
Referenced by XXH32_hashFromCanonical().
Definition at line 658 of file xxhash.c.
References XXH_CPU_LITTLE_ENDIAN, XXH_read64(), and XXH_swap64().
Referenced by XXH64_hashFromCanonical().
FORCE_INLINE U32 XXH_readLE32 | ( | const void * | ptr, |
XXH_endianess | endian | ||
) |
Definition at line 242 of file xxhash.c.
References XXH_readLE32_align(), and XXH_unaligned.
Referenced by XXH32_update_endian().
FORCE_INLINE U32 XXH_readLE32_align | ( | const void * | ptr, |
XXH_endianess | endian, | ||
XXH_alignment | align | ||
) |
Definition at line 234 of file xxhash.c.
References XXH_littleEndian, XXH_read32(), XXH_swap32(), and XXH_unaligned.
Referenced by XXH_readLE32().
FORCE_INLINE U64 XXH_readLE64 | ( | const void * | ptr, |
XXH_endianess | endian | ||
) |
Definition at line 653 of file xxhash.c.
References XXH_readLE64_align(), and XXH_unaligned.
Referenced by XXH64_update_endian().
FORCE_INLINE U64 XXH_readLE64_align | ( | const void * | ptr, |
XXH_endianess | endian, | ||
XXH_alignment | align | ||
) |
Definition at line 645 of file xxhash.c.
References XXH_littleEndian, XXH_read64(), XXH_swap64(), and XXH_unaligned.
Referenced by XXH_readLE64().
Definition at line 203 of file xxhash.c.
References x.
Referenced by XXH32_canonicalFromHash(), XXH_readBE32(), and XXH_readLE32_align().
Definition at line 632 of file xxhash.c.
References x.
Referenced by XXH64_canonicalFromHash(), XXH_readBE64(), and XXH_readLE64_align().
XXH_PUBLIC_API unsigned XXH_versionNumber | ( | void | ) |
Definition at line 263 of file xxhash.c.
Referenced by XXH32_endian_align(), XXH32_reset(), and XXH32_round().
Definition at line 264 of file xxhash.c.
Referenced by XXH32_avalanche(), XXH32_endian_align(), XXH32_reset(), and XXH32_round().
Definition at line 265 of file xxhash.c.
Referenced by XXH32_avalanche().
Definition at line 267 of file xxhash.c.
Referenced by XXH32_digest_endian(), and XXH32_endian_align().
Definition at line 666 of file xxhash.c.
Referenced by XXH64_endian_align(), XXH64_mergeRound(), XXH64_reset(), and XXH64_round().
Definition at line 667 of file xxhash.c.
Referenced by XXH64_avalanche(), XXH64_endian_align(), XXH64_reset(), and XXH64_round().
Definition at line 668 of file xxhash.c.
Referenced by XXH64_avalanche().
Definition at line 669 of file xxhash.c.
Referenced by XXH64_mergeRound().
Definition at line 670 of file xxhash.c.
Referenced by XXH64_digest_endian(), and XXH64_endian_align().