40 const unsigned char *bp = (
const unsigned char *)buf;
41 const unsigned char *be = bp + len;
44 hval ^= (uint64_t)*bp++;
45 hval *= HASH_FNV64_PRIME;
56 const unsigned char *bp = (
const unsigned char *)buf;
57 const unsigned char *be = bp + len;
60 hval ^= (uint32_t)*bp++;
61 hval *= HASH_FNV32_PRIME;
71 const unsigned char *bp = (
const unsigned char *)str;
75 hval ^= (uint64_t)*bp++;
76 hval *= HASH_FNV64_PRIME;
87 const unsigned char *bp = (
const unsigned char *)str;
91 hval ^= (uint32_t)*bp++;
92 hval *= HASH_FNV32_PRIME;
107 uint64_t mask = ~0ULL>>bits;
108 for (
int todo = 32; bits && todo; todo >>= 1)
111 hash = hash ^ hash>>todo;
122 REQUIRE (bits <= 32);
126 uint32_t mask = ~0ULL>>bits;
127 for (
int todo = 16; bits && todo; todo >>= 1)
130 hash = hash ^ hash>>todo;
141 uint64_t retry_level= (UINT64_MAX / limit) * limit;
143 while (hash >= retry_level)
144 hash = (hash * HASH_FNV64_PRIME) + HASH_FNV64_BASE;
153 uint32_t retry_level= (UINT32_MAX / limit) * limit;
155 while (hash >= retry_level)
156 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.