From: Mathieu Desnoyers Date: Tue, 11 Jun 2013 12:38:26 +0000 (-0400) Subject: rcuja-range: allow variable number of bits for key X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=63d2de6a60e9cc108f66f61f0e432741c38f0571;p=urcu.git rcuja-range: allow variable number of bits for key Signed-off-by: Mathieu Desnoyers --- diff --git a/rcuja/rcuja-range.c b/rcuja/rcuja-range.c index 863c960..72a7609 100644 --- a/rcuja/rcuja-range.c +++ b/rcuja/rcuja-range.c @@ -136,8 +136,6 @@ do { \ } while (0) #endif -#define CDS_JA_RANGE_KEY_BITS 64 - enum cds_ja_range_type { CDS_JA_RANGE_ALLOCATED, CDS_JA_RANGE_FREE, @@ -514,13 +512,14 @@ unlock_error: return ret; } -struct cds_ja *_cds_ja_range_new(const struct rcu_flavor_struct *flavor) +struct cds_ja *_cds_ja_range_new(unsigned int key_bits, + const struct rcu_flavor_struct *flavor) { struct cds_ja_range *range; struct cds_ja *ja; int ret; - ja = _cds_ja_new(CDS_JA_RANGE_KEY_BITS, flavor); + ja = _cds_ja_new(key_bits, flavor); if (!ja) return NULL; range = range_create(0, UINT64_MAX - 1, NULL, CDS_JA_RANGE_FREE); diff --git a/tests/test_urcu_ja_range.c b/tests/test_urcu_ja_range.c index 898adaf..12abcc5 100644 --- a/tests/test_urcu_ja_range.c +++ b/tests/test_urcu_ja_range.c @@ -405,8 +405,9 @@ int do_mt_test(void) count_reader = malloc(sizeof(*count_reader) * nr_readers); count_writer = malloc(sizeof(*count_writer) * nr_writers); - printf("Allocating Judy Array for ranges\n"); - test_ja = cds_ja_range_new(); + printf("Allocating %u-bit Judy Array for ranges\n", + key_bits); + test_ja = cds_ja_range_new(key_bits); if (!test_ja) { printf("Error allocating judy array.\n"); ret = -1; diff --git a/urcu/rcuja-range.h b/urcu/rcuja-range.h index 3a22a5b..05ba08a 100644 --- a/urcu/rcuja-range.h +++ b/urcu/rcuja-range.h @@ -45,12 +45,13 @@ int cds_ja_range_add(struct cds_ja *ja, int cds_ja_range_del(struct cds_ja *ja, struct cds_ja_range *range); -struct cds_ja *_cds_ja_range_new(const struct rcu_flavor_struct *flavor); +struct cds_ja *_cds_ja_range_new(unsigned int key_bits, + const struct rcu_flavor_struct *flavor); static inline -struct cds_ja *cds_ja_range_new(void) +struct cds_ja *cds_ja_range_new(unsigned int key_bits) { - return _cds_ja_range_new(&rcu_flavor); + return _cds_ja_range_new(key_bits, &rcu_flavor); } int cds_ja_range_destroy(struct cds_ja *ja,