39 const unsigned char *bp = (
const unsigned char *)buf;
40 const unsigned char *be = bp + len;
43 hval ^= (uint64_t)*bp++;
44 hval *= HASH_FNV64_PRIME;
55 const unsigned char *bp = (
const unsigned char *)buf;
56 const unsigned char *be = bp + len;
59 hval ^= (uint32_t)*bp++;
60 hval *= HASH_FNV32_PRIME;
70 const unsigned char *bp = (
const unsigned char *)str;
74 hval ^= (uint64_t)*bp++;
75 hval *= HASH_FNV64_PRIME;
86 const unsigned char *bp = (
const unsigned char *)str;
90 hval ^= (uint32_t)*bp++;
91 hval *= HASH_FNV32_PRIME;
106 uint64_t mask = ~0ULL>>bits;
107 for (
int todo = 32; bits && todo; todo >>= 1)
110 hash = hash ^ hash>>todo;
121 REQUIRE (bits <= 32);
125 uint32_t mask = ~0ULL>>bits;
126 for (
int todo = 16; bits && todo; todo >>= 1)
129 hash = hash ^ hash>>todo;
140 uint64_t retry_level= (UINT64_MAX / limit) * limit;
142 while (hash >= retry_level)
143 hash = (hash * HASH_FNV64_PRIME) + HASH_FNV64_BASE;
152 uint32_t retry_level= (UINT32_MAX / limit) * limit;
154 while (hash >= retry_level)
155 hash = (hash * HASH_FNV32_PRIME) + HASH_FNV32_BASE;
uint32_t hash_fnv32a_buf(const void *buf, size_t len, uint32_t hval)
FNV-1a 32 bit hash over a buffer.
uint32_t hash_fnv32a_strn(const char *str, size_t len, uint32_t hval)
FNV-1a 32 bit hash over a zero terminated string.
uint32_t hash_fnv32_retry(uint64_t hash, uint32_t limit)
reduce hash to be within 0 to limit-1.
uint64_t hash_fnv64a_strn(const char *str, size_t len, uint64_t hval)
FNV-1a 64 bit hash over a zero terminated string.
uint64_t hash_fnv64_retry(uint64_t hash, uint64_t limit)
reduce hash to be within 0 to limit-1.
uint64_t hash_fnv64a_buf(const void *buf, size_t len, uint64_t hval)
FNV-1a 64 bit hash over a buffer.
uint32_t hash_fnv32_xorfold(uint32_t hash, int bits)
reduce a hash value to n bits.
uint64_t hash_fnv64_xorfold(uint64_t hash, int bits)
reduce a hash value to n bits.