hash.h (286866) | hash.h (296221) |
---|---|
1/* 2 * The following hash function is based on MurmurHash3, placed into the public | 1/* 2 * The following hash function is based on MurmurHash3, placed into the public |
3 * domain by Austin Appleby. See http://code.google.com/p/smhasher/ for | 3 * domain by Austin Appleby. See https://github.com/aappleby/smhasher for |
4 * details. 5 */ 6/******************************************************************************/ 7#ifdef JEMALLOC_H_TYPES 8 9#endif /* JEMALLOC_H_TYPES */ 10/******************************************************************************/ 11#ifdef JEMALLOC_H_STRUCTS --- 32 unchanged lines hidden (view full) --- 44 45 return ((x << r) | (x >> (64 - r))); 46} 47 48JEMALLOC_INLINE uint32_t 49hash_get_block_32(const uint32_t *p, int i) 50{ 51 | 4 * details. 5 */ 6/******************************************************************************/ 7#ifdef JEMALLOC_H_TYPES 8 9#endif /* JEMALLOC_H_TYPES */ 10/******************************************************************************/ 11#ifdef JEMALLOC_H_STRUCTS --- 32 unchanged lines hidden (view full) --- 44 45 return ((x << r) | (x >> (64 - r))); 46} 47 48JEMALLOC_INLINE uint32_t 49hash_get_block_32(const uint32_t *p, int i) 50{ 51 |
52 /* Handle unaligned read. */ 53 if (unlikely((uintptr_t)p & (sizeof(uint32_t)-1)) != 0) { 54 uint32_t ret; 55 56 memcpy(&ret, &p[i], sizeof(uint32_t)); 57 return (ret); 58 } 59 |
|
52 return (p[i]); 53} 54 55JEMALLOC_INLINE uint64_t 56hash_get_block_64(const uint64_t *p, int i) 57{ 58 | 60 return (p[i]); 61} 62 63JEMALLOC_INLINE uint64_t 64hash_get_block_64(const uint64_t *p, int i) 65{ 66 |
67 /* Handle unaligned read. */ 68 if (unlikely((uintptr_t)p & (sizeof(uint64_t)-1)) != 0) { 69 uint64_t ret; 70 71 memcpy(&ret, &p[i], sizeof(uint64_t)); 72 return (ret); 73 } 74 |
|
59 return (p[i]); 60} 61 62JEMALLOC_INLINE uint32_t 63hash_fmix_32(uint32_t h) 64{ 65 66 h ^= h >> 16; --- 249 unchanged lines hidden (view full) --- 316 r_out[1] = h2; 317} 318 319/******************************************************************************/ 320/* API. */ 321JEMALLOC_INLINE void 322hash(const void *key, size_t len, const uint32_t seed, size_t r_hash[2]) 323{ | 75 return (p[i]); 76} 77 78JEMALLOC_INLINE uint32_t 79hash_fmix_32(uint32_t h) 80{ 81 82 h ^= h >> 16; --- 249 unchanged lines hidden (view full) --- 332 r_out[1] = h2; 333} 334 335/******************************************************************************/ 336/* API. */ 337JEMALLOC_INLINE void 338hash(const void *key, size_t len, const uint32_t seed, size_t r_hash[2]) 339{ |
340 341 assert(len <= INT_MAX); /* Unfortunate implementation limitation. */ 342 |
|
324#if (LG_SIZEOF_PTR == 3 && !defined(JEMALLOC_BIG_ENDIAN)) | 343#if (LG_SIZEOF_PTR == 3 && !defined(JEMALLOC_BIG_ENDIAN)) |
325 hash_x64_128(key, len, seed, (uint64_t *)r_hash); | 344 hash_x64_128(key, (int)len, seed, (uint64_t *)r_hash); |
326#else | 345#else |
327 uint64_t hashes[2]; 328 hash_x86_128(key, len, seed, hashes); 329 r_hash[0] = (size_t)hashes[0]; 330 r_hash[1] = (size_t)hashes[1]; | 346 { 347 uint64_t hashes[2]; 348 hash_x86_128(key, (int)len, seed, hashes); 349 r_hash[0] = (size_t)hashes[0]; 350 r_hash[1] = (size_t)hashes[1]; 351 } |
331#endif 332} 333#endif 334 335#endif /* JEMALLOC_H_INLINES */ 336/******************************************************************************/ | 352#endif 353} 354#endif 355 356#endif /* JEMALLOC_H_INLINES */ 357/******************************************************************************/ |