1234370Sjasone/******************************************************************************/ 2234370Sjasone#ifdef JEMALLOC_H_TYPES 3234370Sjasone 4234370Sjasonetypedef struct ckh_s ckh_t; 5234370Sjasonetypedef struct ckhc_s ckhc_t; 6234370Sjasone 7234370Sjasone/* Typedefs to allow easy function pointer passing. */ 8245868Sjasonetypedef void ckh_hash_t (const void *, size_t[2]); 9234370Sjasonetypedef bool ckh_keycomp_t (const void *, const void *); 10234370Sjasone 11234370Sjasone/* Maintain counters used to get an idea of performance. */ 12234370Sjasone/* #define CKH_COUNT */ 13234370Sjasone/* Print counter values in ckh_delete() (requires CKH_COUNT). */ 14234370Sjasone/* #define CKH_VERBOSE */ 15234370Sjasone 16234370Sjasone/* 17234370Sjasone * There are 2^LG_CKH_BUCKET_CELLS cells in each hash table bucket. Try to fit 18234370Sjasone * one bucket per L1 cache line. 19234370Sjasone */ 20234370Sjasone#define LG_CKH_BUCKET_CELLS (LG_CACHELINE - LG_SIZEOF_PTR - 1) 21234370Sjasone 22234370Sjasone#endif /* JEMALLOC_H_TYPES */ 23234370Sjasone/******************************************************************************/ 24234370Sjasone#ifdef JEMALLOC_H_STRUCTS 25234370Sjasone 26234370Sjasone/* Hash table cell. */ 27234370Sjasonestruct ckhc_s { 28234370Sjasone const void *key; 29234370Sjasone const void *data; 30234370Sjasone}; 31234370Sjasone 32234370Sjasonestruct ckh_s { 33234370Sjasone#ifdef CKH_COUNT 34234370Sjasone /* Counters used to get an idea of performance. */ 35234370Sjasone uint64_t ngrows; 36234370Sjasone uint64_t nshrinks; 37234370Sjasone uint64_t nshrinkfails; 38234370Sjasone uint64_t ninserts; 39234370Sjasone uint64_t nrelocs; 40234370Sjasone#endif 41234370Sjasone 42234370Sjasone /* Used for pseudo-random number generation. */ 43234370Sjasone#define CKH_A 1103515241 44234370Sjasone#define CKH_C 12347 45234370Sjasone uint32_t prng_state; 46234370Sjasone 47234370Sjasone /* Total number of items. */ 48234370Sjasone size_t count; 49234370Sjasone 50234370Sjasone /* 51234370Sjasone * Minimum and current number of hash table buckets. There are 52234370Sjasone * 2^LG_CKH_BUCKET_CELLS cells per bucket. 53234370Sjasone */ 54234370Sjasone unsigned lg_minbuckets; 55234370Sjasone unsigned lg_curbuckets; 56234370Sjasone 57234370Sjasone /* Hash and comparison functions. */ 58234370Sjasone ckh_hash_t *hash; 59234370Sjasone ckh_keycomp_t *keycomp; 60234370Sjasone 61234370Sjasone /* Hash table with 2^lg_curbuckets buckets. */ 62234370Sjasone ckhc_t *tab; 63234370Sjasone}; 64234370Sjasone 65234370Sjasone#endif /* JEMALLOC_H_STRUCTS */ 66234370Sjasone/******************************************************************************/ 67234370Sjasone#ifdef JEMALLOC_H_EXTERNS 68234370Sjasone 69234370Sjasonebool ckh_new(ckh_t *ckh, size_t minitems, ckh_hash_t *hash, 70234370Sjasone ckh_keycomp_t *keycomp); 71234370Sjasonevoid ckh_delete(ckh_t *ckh); 72234370Sjasonesize_t ckh_count(ckh_t *ckh); 73234370Sjasonebool ckh_iter(ckh_t *ckh, size_t *tabind, void **key, void **data); 74234370Sjasonebool ckh_insert(ckh_t *ckh, const void *key, const void *data); 75234370Sjasonebool ckh_remove(ckh_t *ckh, const void *searchkey, void **key, 76234370Sjasone void **data); 77234370Sjasonebool ckh_search(ckh_t *ckh, const void *seachkey, void **key, void **data); 78245868Sjasonevoid ckh_string_hash(const void *key, size_t r_hash[2]); 79234370Sjasonebool ckh_string_keycomp(const void *k1, const void *k2); 80245868Sjasonevoid ckh_pointer_hash(const void *key, size_t r_hash[2]); 81234370Sjasonebool ckh_pointer_keycomp(const void *k1, const void *k2); 82234370Sjasone 83234370Sjasone#endif /* JEMALLOC_H_EXTERNS */ 84234370Sjasone/******************************************************************************/ 85234370Sjasone#ifdef JEMALLOC_H_INLINES 86234370Sjasone 87234370Sjasone#endif /* JEMALLOC_H_INLINES */ 88234370Sjasone/******************************************************************************/ 89