From: Jens Axboe Date: Sun, 28 Sep 2014 03:26:58 +0000 (-0600) Subject: Add fnv hash X-Git-Tag: fio-2.1.13~21 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=41177ed32fe815545061f7d10ce13559f1e9eb98;ds=sidebyside Add fnv hash Signed-off-by: Jens Axboe --- diff --git a/crc/fnv.c b/crc/fnv.c new file mode 100644 index 00000000..04c0560c --- /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; +} diff --git a/crc/fnv.h b/crc/fnv.h new file mode 100644 index 00000000..ef2b77b4 --- /dev/null +++ b/crc/fnv.h @@ -0,0 +1,8 @@ +#ifndef FIO_FNV_H +#define FIO_FNV_H + +#include + +uint64_t fnv(const void *, uint32_t, uint64_t); + +#endif