summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-06-30 23:15:35 +0200
committerRichard Braun <rbraun@sceen.net>2017-06-30 23:15:35 +0200
commit1edbaa9f03a118dabf3e6a53f0a60e1f0bf9690a (patch)
tree7a0f75ea694be48a0189524eadd0f1da20cf02e6
parentdde74d4334a874ed25141d474d981631a244d54c (diff)
rdxtree: provide a lockless-aware slot load accessor
-rw-r--r--rdxtree.c7
-rw-r--r--rdxtree.h13
2 files changed, 13 insertions, 7 deletions
diff --git a/rdxtree.c b/rdxtree.c
index b93c345..1480a8e 100644
--- a/rdxtree.c
+++ b/rdxtree.c
@@ -76,13 +76,6 @@ typedef unsigned long long rdxtree_bm_t;
((~(rdxtree_bm_t)0) >> (RDXTREE_BM_SIZE - RDXTREE_RADIX_SIZE))
/*
- * These macros can be replaced by actual functions in an environment
- * that provides lockless synchronization such as RCU.
- */
-#define llsync_assign_ptr(ptr, value) ((ptr) = (value))
-#define llsync_read_ptr(ptr) (ptr)
-
-/*
* Radix tree node.
*
* The height of a tree is the number of nodes to traverse until stored
diff --git a/rdxtree.h b/rdxtree.h
index be0db3b..7604380 100644
--- a/rdxtree.h
+++ b/rdxtree.h
@@ -39,6 +39,13 @@
#include <stdint.h>
/*
+ * These macros can be replaced by actual functions in an environment
+ * that provides lockless synchronization such as RCU.
+ */
+#define llsync_assign_ptr(ptr, value) ((ptr) = (value))
+#define llsync_read_ptr(ptr) (ptr)
+
+/*
* This macro selects between 32 or 64-bits (the default) keys.
*/
#if 0
@@ -174,6 +181,12 @@ rdxtree_lookup_slot(const struct rdxtree *tree, rdxtree_key_t key)
return rdxtree_lookup_common(tree, key, 1);
}
+static inline void *
+rdxtree_load_slot(void **slot)
+{
+ return llsync_read_ptr(*slot);
+}
+
/*
* Replace a pointer in a tree.
*