summaryrefslogtreecommitdiff
path: root/lib/hash.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2012-12-14 13:43:54 -0800
committerBen Pfaff <blp@nicira.com>2013-01-22 13:40:50 -0800
commitb2a52eedaa406bacfa53d2b2a3d4236e46042bcd (patch)
treef83085b1efd7bf817e51a160a26ac56ca9e4b668 /lib/hash.h
parent432fca235c375c1d56bd6d3049b0b24ce2cb2958 (diff)
downloadopenvswitch-b2a52eedaa406bacfa53d2b2a3d4236e46042bcd.tar.gz
hash: Correct implementation of mhash_finish().
With rotates instead of shifts, the upper and lower 16 bits of the returned hash are always the same. I noticed this while working on replacing Jenkins hash by murmurhash, because some of the database unit tests started failing, e.g. "row hashing (scalars)". Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib/hash.h')
-rw-r--r--lib/hash.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/hash.h b/lib/hash.h
index 701e6866e..96866c42a 100644
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -152,11 +152,11 @@ static inline uint32_t mhash_add(uint32_t hash, uint32_t data)
static inline uint32_t mhash_finish(uint32_t hash, size_t n)
{
hash ^= n * 4;
- hash ^= hash_rot(hash, 16);
+ hash ^= hash >> 16;
hash *= 0x85ebca6b;
- hash ^= hash_rot(hash, 13);
+ hash ^= hash >> 13;
hash *= 0xc2b2ae35;
- hash ^= hash_rot(hash, 16);
+ hash ^= hash >> 16;
return hash;
}