hash: make 64-bit even on 32-bit
authorJens Axboe <axboe@fb.com>
Wed, 25 May 2016 19:19:16 +0000 (13:19 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 25 May 2016 19:19:16 +0000 (13:19 -0600)
Fixes this warning on Windows, where unsigned long is 32-bit:

hash.h: In function ‘__hash_long’:
hash.h:58:2: warning: left shift count >= width of type
  n <<= 33;
  ^

Signed-off-by: Jens Axboe <axboe@fb.com>
hash.h

diff --git a/hash.h b/hash.h
index 1d7608beb40500dba75541f374b815f88672eadb..d227b938a246881229ab5d5e304427da8f03cff3 100644 (file)
--- a/hash.h
+++ b/hash.h
 #define GOLDEN_RATIO_32 0x61C88647
 #define GOLDEN_RATIO_64 0x61C8864680B583EBull
 
-static inline unsigned long __hash_long(unsigned long val)
+static inline unsigned long __hash_long(uint64_t val)
 {
-       unsigned long hash = val;
+       uint64_t hash = val;
 
 #if BITS_PER_LONG == 64
        hash *= GOLDEN_RATIO_64;
 #else
        /*  Sigh, gcc can't optimise this alone like it does for 32 bits. */
-       unsigned long n = hash;
+       uint64_t n = hash;
        n <<= 18;
        hash -= n;
        n <<= 33;