]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/include/jemalloc/internal/ckh.h
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
4 typedef struct ckh_s ckh_t
;
5 typedef struct ckhc_s ckhc_t
;
7 /* Typedefs to allow easy function pointer passing. */
8 typedef void ckh_hash_t (const void *, unsigned, size_t *, size_t *);
9 typedef bool ckh_keycomp_t (const void *, const void *);
11 /* Maintain counters used to get an idea of performance. */
12 /* #define CKH_COUNT */
13 /* Print counter values in ckh_delete() (requires CKH_COUNT). */
14 /* #define CKH_VERBOSE */
17 * There are 2^LG_CKH_BUCKET_CELLS cells in each hash table bucket. Try to fit
18 * one bucket per L1 cache line.
20 #define LG_CKH_BUCKET_CELLS (LG_CACHELINE - LG_SIZEOF_PTR - 1)
22 #endif /* JEMALLOC_H_TYPES */
23 /******************************************************************************/
24 #ifdef JEMALLOC_H_STRUCTS
26 /* Hash table cell. */
34 /* Counters used to get an idea of performance. */
37 uint64_t nshrinkfails
;
42 /* Used for pseudo-random number generation. */
43 #define CKH_A 1103515241
47 /* Total number of items. */
51 * Minimum and current number of hash table buckets. There are
52 * 2^LG_CKH_BUCKET_CELLS cells per bucket.
54 unsigned lg_minbuckets
;
55 unsigned lg_curbuckets
;
57 /* Hash and comparison functions. */
59 ckh_keycomp_t
*keycomp
;
61 /* Hash table with 2^lg_curbuckets buckets. */
65 #endif /* JEMALLOC_H_STRUCTS */
66 /******************************************************************************/
67 #ifdef JEMALLOC_H_EXTERNS
69 bool ckh_new(ckh_t
*ckh
, size_t minitems
, ckh_hash_t
*hash
,
70 ckh_keycomp_t
*keycomp
);
71 void ckh_delete(ckh_t
*ckh
);
72 size_t ckh_count(ckh_t
*ckh
);
73 bool ckh_iter(ckh_t
*ckh
, size_t *tabind
, void **key
, void **data
);
74 bool ckh_insert(ckh_t
*ckh
, const void *key
, const void *data
);
75 bool ckh_remove(ckh_t
*ckh
, const void *searchkey
, void **key
,
77 bool ckh_search(ckh_t
*ckh
, const void *seachkey
, void **key
, void **data
);
78 void ckh_string_hash(const void *key
, unsigned minbits
, size_t *hash1
,
80 bool ckh_string_keycomp(const void *k1
, const void *k2
);
81 void ckh_pointer_hash(const void *key
, unsigned minbits
, size_t *hash1
,
83 bool ckh_pointer_keycomp(const void *k1
, const void *k2
);
85 #endif /* JEMALLOC_H_EXTERNS */
86 /******************************************************************************/
87 #ifdef JEMALLOC_H_INLINES
89 #endif /* JEMALLOC_H_INLINES */
90 /******************************************************************************/