]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/include/jemalloc/internal/hash.h
8a46ce30803aef2518bccbed0c0151182af7a066
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
4 #endif /* JEMALLOC_H_TYPES */
5 /******************************************************************************/
6 #ifdef JEMALLOC_H_STRUCTS
8 #endif /* JEMALLOC_H_STRUCTS */
9 /******************************************************************************/
10 #ifdef JEMALLOC_H_EXTERNS
12 #endif /* JEMALLOC_H_EXTERNS */
13 /******************************************************************************/
14 #ifdef JEMALLOC_H_INLINES
16 #ifndef JEMALLOC_ENABLE_INLINE
17 uint64_t hash(const void *key
, size_t len
, uint64_t seed
);
20 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_HASH_C_))
22 * The following hash function is based on MurmurHash64A(), placed into the
23 * public domain by Austin Appleby. See http://murmurhash.googlepages.com/ for
26 JEMALLOC_INLINE
uint64_t
27 hash(const void *key
, size_t len
, uint64_t seed
)
29 const uint64_t m
= 0xc6a4a7935bd1e995LLU
;
31 uint64_t h
= seed
^ (len
* m
);
32 const uint64_t *data
= (const uint64_t *)key
;
33 const uint64_t *end
= data
+ (len
/8);
34 const unsigned char *data2
;
36 assert(((uintptr_t)key
& 0x7) == 0);
49 data2
= (const unsigned char *)data
;
51 case 7: h
^= ((uint64_t)(data2
[6])) << 48;
52 case 6: h
^= ((uint64_t)(data2
[5])) << 40;
53 case 5: h
^= ((uint64_t)(data2
[4])) << 32;
54 case 4: h
^= ((uint64_t)(data2
[3])) << 24;
55 case 3: h
^= ((uint64_t)(data2
[2])) << 16;
56 case 2: h
^= ((uint64_t)(data2
[1])) << 8;
57 case 1: h
^= ((uint64_t)(data2
[0]));
69 #endif /* JEMALLOC_H_INLINES */
70 /******************************************************************************/