blob: 04c0560c9f421bea6796b1f3aef680bc5eb80827 [file] [log] [blame]
Jens Axboedc34c742014-09-27 21:26:58 -06001#include "fnv.h"
2
3#define FNV_PRIME 0x100000001b3ULL
4
5uint64_t fnv(const void *buf, uint32_t len, uint64_t hval)
6{
7 const uint64_t *ptr = buf;
8 const uint64_t *end = (void *) buf + len;
9
10 while (ptr < end) {
11 hval *= FNV_PRIME;
12 hval ^= (uint64_t) *ptr++;
13 }
14
15 return hval;
16}