rculfhash: fix 0 order lookup (special-case)
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 8 Sep 2011 16:16:19 +0000 (09:16 -0700)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 8 Sep 2011 16:16:19 +0000 (09:16 -0700)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rculfhash.c

index 193857647439ef9cc3cfbc222184cab4c32c3360..4a001cf328298d43f16862ece4251ac7e2c43648 100644 (file)
@@ -699,7 +699,7 @@ struct cds_lfht_node *_cds_lfht_add(struct cds_lfht *ht, struct rcu_table *t,
                 */
                index = hash & (t->size - 1);
                order = get_count_order_ulong(index + 1);
-               lookup = &t->tbl[order]->nodes[index & ((1UL << (order - 1)) - 1)];
+               lookup = &t->tbl[order]->nodes[index & ((!order ? 0 : (1UL << (order - 1))) - 1)];
                iter_prev = (struct cds_lfht_node *) lookup;
                /* We can always skip the dummy node initially */
                iter = rcu_dereference(iter_prev->p.next);
@@ -755,7 +755,7 @@ gc_end:
        /* Garbage collect logically removed nodes in the bucket */
        index = hash & (t->size - 1);
        order = get_count_order_ulong(index + 1);
-       lookup = &t->tbl[order]->nodes[index & ((1UL << (order - 1)) - 1)];
+       lookup = &t->tbl[order]->nodes[index & (!order ? 0 : ((1UL << (order - 1)) - 1))];
        dummy_node = (struct cds_lfht_node *) lookup;
        _cds_lfht_gc_bucket(dummy_node, node);
        return node;
@@ -799,7 +799,7 @@ int _cds_lfht_remove(struct cds_lfht *ht, struct rcu_table *t,
        assert(t->size > 0);
        index = hash & (t->size - 1);
        order = get_count_order_ulong(index + 1);
-       lookup = &t->tbl[order]->nodes[index & ((1UL << (order - 1)) - 1)];
+       lookup = &t->tbl[order]->nodes[index & (!order ? 0 : ((1UL << (order - 1)) - 1))];
        dummy = (struct cds_lfht_node *) lookup;
        _cds_lfht_gc_bucket(dummy, node);
 end:
@@ -940,9 +940,9 @@ struct cds_lfht_node *cds_lfht_lookup(struct cds_lfht *ht, void *key, size_t key
        t = rcu_dereference(ht->t);
        index = hash & (t->size - 1);
        order = get_count_order_ulong(index + 1);
-       lookup = &t->tbl[order]->nodes[index & ((1UL << (order - 1)) - 1)];
+       lookup = &t->tbl[order]->nodes[index & (!order ? 0 : ((1UL << (order - 1))) - 1)];
        dbg_printf("lookup hash %lu index %lu order %lu aridx %lu\n",
-                  hash, index, order, index & ((1UL << (order - 1)) - 1));
+                  hash, index, order, index & (!order ? 0 : ((1UL << (order - 1)) - 1)));
        node = (struct cds_lfht_node *) lookup;
        for (;;) {
                if (unlikely(!node))
This page took 0.028499 seconds and 4 git commands to generate.