diff options
author | Jens Axboe <axboe@kernel.dk> | 2012-11-11 08:27:24 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-11-11 08:27:24 +0100 |
commit | a5a4fdfd44ec1b55ebab7800a931c148540a7324 (patch) | |
tree | fd83eb6acf4d06319dec5517dc2ea55a184ce31a /hash.h | |
parent | 921d17ba00f6fa106f558ea285d1d503f3a41369 (diff) | |
download | fio-a5a4fdfd44ec1b55ebab7800a931c148540a7324.tar.gz |
zipf: use 64-bit safe hash for zipf/pareto
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'hash.h')
-rw-r--r-- | hash.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -28,6 +28,8 @@ #error Define GOLDEN_RATIO_PRIME for your wordsize. #endif +#define GR_PRIME_64 0x9e37fffffffc0001UL + static inline unsigned long __hash_long(unsigned long val) { unsigned long hash = val; @@ -60,6 +62,11 @@ static inline unsigned long hash_long(unsigned long val, unsigned int bits) /* High bits are more random, so use them. */ return __hash_long(val) >> (BITS_PER_LONG - bits); } + +static inline uint64_t __hash_u64(uint64_t val) +{ + return val * GR_PRIME_64; +} static inline unsigned long hash_ptr(void *ptr, unsigned int bits) { |