1 /* Copyright 2012-present Facebook, Inc.
2  * Licensed under the Apache License, Version 2.0 */
3 
4 #ifndef WATCHMAN_HASH_H
5 #define WATCHMAN_HASH_H
6 
7 /* Bob Jenkins' lookup3.c hash function */
8 uint32_t w_hash_bytes(const void* key, size_t length, uint32_t initval);
9 
10 namespace watchman {
11 // This is the Hash128to64 function from Google's cityhash (available
12 // under the MIT License).  We use it to reduce multiple 64 bit hashes
13 // into a single hash.
hash_128_to_64(const uint64_t upper,const uint64_t lower)14 inline uint64_t hash_128_to_64(const uint64_t upper, const uint64_t lower) {
15   // Murmur-inspired hashing.
16   const uint64_t kMul = 0x9ddfea08eb382d69ULL;
17   uint64_t a = (lower ^ upper) * kMul;
18   a ^= (a >> 47);
19   uint64_t b = (upper ^ a) * kMul;
20   b ^= (b >> 47);
21   b *= kMul;
22   return b;
23 }
24 }
25 
26 #endif
27 
28 /* vim:ts=2:sw=2:et:
29  */
30