X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=rculfhash-internal.h;h=d7cec95a10e286f4693c91925e61441146196ebe;hp=38a031793c3afc616d81f96883e0d8325336bae2;hb=2af1c19e6a553878fcb2a5106f050d5ed7ac0f54;hpb=f45b03e03cc09b539b6f6c4f6a72663c212343d8 diff --git a/rculfhash-internal.h b/rculfhash-internal.h index 38a0317..d7cec95 100644 --- a/rculfhash-internal.h +++ b/rculfhash-internal.h @@ -25,11 +25,17 @@ */ #include +#include #ifdef DEBUG #define dbg_printf(fmt, args...) printf("[debug rculfhash] " fmt, ## args) #else -#define dbg_printf(fmt, args...) +#define dbg_printf(fmt, args...) \ +do { \ + /* do nothing but check printf format */ \ + if (0) \ + printf("[debug rculfhash] " fmt, ## args); \ +} while (0) #endif #if (CAA_BITS_PER_LONG == 32) @@ -137,8 +143,8 @@ struct cds_lfht { */ }; -extern unsigned int fls_ulong(unsigned long x); -extern int get_count_order_ulong(unsigned long x); +extern unsigned int cds_lfht_fls_ulong(unsigned long x); +extern int cds_lfht_get_count_order_ulong(unsigned long x); #ifdef POISON_FREE #define poison_free(ptr) \ @@ -152,4 +158,26 @@ extern int get_count_order_ulong(unsigned long x); #define poison_free(ptr) free(ptr) #endif +static inline +struct cds_lfht *__default_alloc_cds_lfht( + const struct cds_lfht_mm_type *mm, + unsigned long cds_lfht_size, + unsigned long min_nr_alloc_buckets, + unsigned long max_nr_buckets) +{ + struct cds_lfht *ht; + + ht = calloc(1, cds_lfht_size); + assert(ht); + + ht->mm = mm; + ht->bucket_at = mm->bucket_at; + ht->min_nr_alloc_buckets = min_nr_alloc_buckets; + ht->min_alloc_buckets_order = + cds_lfht_get_count_order_ulong(min_nr_alloc_buckets); + ht->max_nr_buckets = max_nr_buckets; + + return ht; +} + #endif /* _URCU_RCULFHASH_INTERNAL_H */