From: Mathieu Desnoyers Date: Fri, 7 Jun 2013 21:30:33 +0000 (-0400) Subject: rcuja: range implementation X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=748e8540272b5183fbd297e5a296951c24291546;p=userspace-rcu.git rcuja: range implementation Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.am b/Makefile.am index 0501e14..da4a0c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 0000000..3476180 --- /dev/null +++ b/urcu/rcuja-range.h @@ -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 + * + * 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 +#include +#include + +#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 */