projects
/
urcu.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rculfhash: add c++ ifdef
[urcu.git]
/
rculfhash.c
diff --git
a/rculfhash.c
b/rculfhash.c
index 11c0077977f327e5437a13d050f8eceb6e7a6a6b..556ec36ddab261625d3c3b412496718c790d0c0b 100644
(file)
--- a/
rculfhash.c
+++ b/
rculfhash.c
@@
-234,14
+234,16
@@
void _ht_gc_bucket(struct rcu_ht_node *dummy, struct rcu_ht_node *node)
}
static
}
static
-
int _ht_add(struct rcu_ht *ht, struct rcu_table *t, struct rcu_ht_node *node
,
- int unique)
+
struct rcu_ht_node *_ht_add(struct rcu_ht *ht, struct rcu_table *t
,
+
struct rcu_ht_node *node,
int unique)
{
struct rcu_ht_node *iter_prev, *dummy, *iter, *next;
unsigned long hash;
{
struct rcu_ht_node *iter_prev, *dummy, *iter, *next;
unsigned long hash;
- if (!t->size)
- return 0;
+ if (!t->size) {
+ assert(node->dummy);
+ return node; /* Initial first add (head) */
+ }
hash = bit_reverse_ulong(node->reverse_hash);
for (;;) {
uint32_t chain_len = 0;
hash = bit_reverse_ulong(node->reverse_hash);
for (;;) {
uint32_t chain_len = 0;
@@
-262,6
+264,12
@@
int _ht_add(struct rcu_ht *ht, struct rcu_table *t, struct rcu_ht_node *node,
next = rcu_dereference(clear_flag(iter)->next);
if (is_removed(next))
goto gc_node;
next = rcu_dereference(clear_flag(iter)->next);
if (is_removed(next))
goto gc_node;
+ if (unique
+ && !clear_flag(iter)->dummy
+ && !ht->compare_fct(node->key, node->key_len,
+ clear_flag(iter)->key,
+ clear_flag(iter)->key_len))
+ return clear_flag(iter);
/* Only account for identical reverse hash once */
if (iter_prev->reverse_hash != clear_flag(iter)->reverse_hash)
check_resize(ht, t, ++chain_len);
/* Only account for identical reverse hash once */
if (iter_prev->reverse_hash != clear_flag(iter)->reverse_hash)
check_resize(ht, t, ++chain_len);
@@
-287,7
+295,7
@@
gc_end:
/* Garbage collect logically removed nodes in the bucket */
dummy = rcu_dereference(t->tbl[hash & (t->size - 1)]);
_ht_gc_bucket(dummy, node);
/* Garbage collect logically removed nodes in the bucket */
dummy = rcu_dereference(t->tbl[hash & (t->size - 1)]);
_ht_gc_bucket(dummy, node);
- return
0
;
+ return
node
;
}
static
}
static
@@
-417,7
+425,7
@@
void ht_add(struct rcu_ht *ht, struct rcu_ht_node *node)
(void) _ht_add(ht, t, node, 0);
}
(void) _ht_add(ht, t, node, 0);
}
-
int
ht_add_unique(struct rcu_ht *ht, struct rcu_ht_node *node)
+
struct rcu_ht_node *
ht_add_unique(struct rcu_ht *ht, struct rcu_ht_node *node)
{
struct rcu_table *t;
unsigned long hash;
{
struct rcu_table *t;
unsigned long hash;
This page took
0.023784 seconds
and
4
git commands to generate.