Lines Matching full:sl
54 struct slabhash* sl = (struct slabhash*)calloc(1, in slabhash_create() local
56 if(!sl) return NULL; in slabhash_create()
57 sl->size = numtables; in slabhash_create()
58 log_assert(sl->size > 0); in slabhash_create()
59 sl->array = (struct lruhash**)calloc(sl->size, sizeof(struct lruhash*)); in slabhash_create()
60 if(!sl->array) { in slabhash_create()
61 free(sl); in slabhash_create()
64 sl->mask = (uint32_t)(sl->size - 1); in slabhash_create()
65 if(sl->mask == 0) { in slabhash_create()
66 sl->shift = 0; in slabhash_create()
68 log_assert( (sl->size & sl->mask) == 0 in slabhash_create()
70 sl->shift = 0; in slabhash_create()
71 while(!(sl->mask & 0x80000000)) { in slabhash_create()
72 sl->mask <<= 1; in slabhash_create()
73 sl->shift ++; in slabhash_create()
76 for(i=0; i<sl->size; i++) { in slabhash_create()
77 sl->array[i] = lruhash_create(start_size, maxmem / sl->size, in slabhash_create()
79 if(!sl->array[i]) { in slabhash_create()
80 slabhash_delete(sl); in slabhash_create()
84 return sl; in slabhash_create()
87 void slabhash_delete(struct slabhash* sl) in slabhash_delete() argument
89 if(!sl) in slabhash_delete()
91 if(sl->array) { in slabhash_delete()
93 for(i=0; i<sl->size; i++) in slabhash_delete()
94 lruhash_delete(sl->array[i]); in slabhash_delete()
95 free(sl->array); in slabhash_delete()
97 free(sl); in slabhash_delete()
100 void slabhash_clear(struct slabhash* sl) in slabhash_clear() argument
103 if(!sl) in slabhash_clear()
105 for(i=0; i<sl->size; i++) in slabhash_clear()
106 lruhash_clear(sl->array[i]); in slabhash_clear()
111 slab_idx(struct slabhash* sl, hashvalue_type hash) in slab_idx() argument
113 return ((hash & sl->mask) >> sl->shift); in slab_idx()
116 void slabhash_insert(struct slabhash* sl, hashvalue_type hash, in slabhash_insert() argument
119 lruhash_insert(sl->array[slab_idx(sl, hash)], hash, entry, data, arg); in slabhash_insert()
122 struct lruhash_entry* slabhash_lookup(struct slabhash* sl, in slabhash_lookup() argument
125 return lruhash_lookup(sl->array[slab_idx(sl, hash)], hash, key, wr); in slabhash_lookup()
128 void slabhash_remove(struct slabhash* sl, hashvalue_type hash, void* key) in slabhash_remove() argument
130 lruhash_remove(sl->array[slab_idx(sl, hash)], hash, key); in slabhash_remove()
133 void slabhash_status(struct slabhash* sl, const char* id, int extended) in slabhash_status() argument
138 id, (unsigned)sl->size, (unsigned)sl->mask, sl->shift); in slabhash_status()
139 for(i=0; i<sl->size; i++) { in slabhash_status()
141 lruhash_status(sl->array[i], num, extended); in slabhash_status()
145 size_t slabhash_get_size(struct slabhash* sl) in slabhash_get_size() argument
148 for(i=0; i<sl->size; i++) { in slabhash_get_size()
149 lock_quick_lock(&sl->array[i]->lock); in slabhash_get_size()
150 total += sl->array[i]->space_max; in slabhash_get_size()
151 lock_quick_unlock(&sl->array[i]->lock); in slabhash_get_size()
156 int slabhash_is_size(struct slabhash* sl, size_t size, size_t slabs) in slabhash_is_size() argument
161 if(!sl) return 0; in slabhash_is_size()
162 if(sl->size != slabs) return 0; in slabhash_is_size()
164 if( (size/slabs)*slabs == slabhash_get_size(sl)) in slabhash_is_size()
169 void slabhash_update_space_used(struct slabhash* sl, hashvalue_type hash, in slabhash_update_space_used() argument
172 lruhash_update_space_used(sl->array[slab_idx(sl, hash)], cb_arg, in slabhash_update_space_used()
176 size_t slabhash_get_mem(struct slabhash* sl) in slabhash_get_mem() argument
178 size_t i, total = sizeof(*sl); in slabhash_get_mem()
179 total += sizeof(struct lruhash*)*sl->size; in slabhash_get_mem()
180 for(i=0; i<sl->size; i++) { in slabhash_get_mem()
181 total += lruhash_get_mem(sl->array[i]); in slabhash_get_mem()
186 struct lruhash* slabhash_gettable(struct slabhash* sl, hashvalue_type hash) in slabhash_gettable() argument
188 return sl->array[slab_idx(sl, hash)]; in slabhash_gettable()
225 void slabhash_setmarkdel(struct slabhash* sl, lruhash_markdelfunc_type md) in slabhash_setmarkdel() argument
228 for(i=0; i<sl->size; i++) { in slabhash_setmarkdel()
229 lruhash_setmarkdel(sl->array[i], md); in slabhash_setmarkdel()