commit | dc34c74b8d453e12a9c43ec8b89e29ad6ebd8e6a | [log] [tgz] |
---|---|---|
author | Jens Axboe <axboe@fb.com> | Sat Sep 27 21:26:58 2014 -0600 |
committer | Mohamad Ayyash <mkayyash@google.com> | Fri Mar 06 17:57:18 2015 -0800 |
tree | 513b7c7f09ce2d204949102bc16502d48795a695 | |
parent | fc18c7834ecbde2d3679fd0e51819616b28f9f01 [diff] [blame] |
Add fnv hash Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/crc/fnv.c b/crc/fnv.c new file mode 100644 index 0000000..04c0560 --- /dev/null +++ b/crc/fnv.c
@@ -0,0 +1,16 @@ +#include "fnv.h" + +#define FNV_PRIME 0x100000001b3ULL + +uint64_t fnv(const void *buf, uint32_t len, uint64_t hval) +{ + const uint64_t *ptr = buf; + const uint64_t *end = (void *) buf + len; + + while (ptr < end) { + hval *= FNV_PRIME; + hval ^= (uint64_t) *ptr++; + } + + return hval; +}