rcuja: range implementation
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 7 Jun 2013 21:30:33 +0000 (17:30 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 7 Jun 2013 21:30:33 +0000 (17:30 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile.am
urcu/rcuja-range.h [new file with mode: 0644]

index 0501e14367ba0f28b3a7a27a5bad1fc98144e161..da4a0c99efcaa5cfa72e294b7e139f77c644be6d 100644 (file)
@@ -17,7 +17,7 @@ nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h urcu/list.h \
                urcu/wfqueue.h urcu/rculfstack.h urcu/rculfqueue.h \
                urcu/ref.h urcu/cds.h urcu/urcu_ref.h urcu/urcu-futex.h \
                urcu/uatomic_arch.h urcu/rculfhash.h urcu/wfcqueue.h \
-               urcu/rcuja.h urcu/lfstack.h \
+               urcu/rcuja.h urcu/rcuja-range.h urcu/lfstack.h \
                $(top_srcdir)/urcu/map/*.h \
                $(top_srcdir)/urcu/static/*.h \
                urcu/tls-compat.h
@@ -45,7 +45,7 @@ endif
 RCULFHASH = rculfhash.c rculfhash-mm-order.c rculfhash-mm-chunk.c \
                rculfhash-mm-mmap.c
 
-RCUJA = rcuja/rcuja.c rcuja/rcuja-shadow-nodes.c
+RCUJA = rcuja/rcuja.c rcuja/rcuja-shadow-nodes.c rcuja/rcuja-range.c
 
 lib_LTLIBRARIES = liburcu-common.la \
                liburcu.la liburcu-qsbr.la \
diff --git a/urcu/rcuja-range.h b/urcu/rcuja-range.h
new file mode 100644 (file)
index 0000000..3476180
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef _URCU_RCUJA_RANGE_H
+#define _URCU_RCUJA_RANGE_H
+
+/*
+ * urcu/rcuja-range.h
+ *
+ * Userspace RCU library - RCU Judy Array Range Support
+ *
+ * Copyright 2012-2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Include this file _after_ including your URCU flavor.
+ */
+
+#include <urcu/rcuja.h>
+#include <pthread.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum cds_ja_range_type {
+       CDS_JA_RANGE_ALLOCATED,
+       CDS_JA_RANGE_FREE,
+       CDS_JA_RANGE_REMOVED,
+};
+
+/*
+ * Range goes from start (inclusive) to end (inclusive).
+ * Range start is used as node key in the Judy array.
+ */
+struct cds_ja_range {
+       uint64_t start, end;
+       struct cds_ja_node ja_node;
+       pthread_mutex_t lock;
+       enum cds_ja_range_type type;
+       struct rcu_head head;
+};
+
+int cds_ja_range_init(struct cds_ja *ja);
+int cds_ja_range_fini(struct cds_ja *ja);
+
+struct cds_ja_range *cds_ja_range_lookup(struct cds_ja *ja, uint64_t key);
+
+struct cds_ja_range *cds_ja_range_add(struct cds_ja *ja,
+               uint64_t start,         /* inclusive */
+               uint64_t end);          /* inclusive */
+
+int cds_ja_range_del(struct cds_ja *ja, struct cds_ja_range *range);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _URCU_RCUJA_H */
This page took 0.025798 seconds and 4 git commands to generate.