From: Mathieu Desnoyers Date: Sun, 12 Aug 2012 19:08:00 +0000 (-0400) Subject: rcuja: add shadow nodes hash table X-Git-Url: http://git.liburcu.org/?p=userspace-rcu.git;a=commitdiff_plain;h=195e72d3c13aa84df6d149b342468ff04f200343 rcuja: add shadow nodes hash table Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.am b/Makefile.am index df170f3..8c552ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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/rcuja.c rcuja/rcuja-shadow-nodes.c lib_LTLIBRARIES = liburcu-common.la \ liburcu.la liburcu-qsbr.la \ @@ -75,9 +75,11 @@ liburcu_signal_la_LIBADD = liburcu-common.la liburcu_bp_la_SOURCES = urcu-bp.c urcu-pointer.c $(COMPAT) liburcu_bp_la_LIBADD = liburcu-common.la +# liburcu-cds depends on liburcu for the judy array hash table +# (internally used). liburcu_cds_la_SOURCES = rculfqueue.c rculfstack.c lfstack.c \ $(RCULFHASH) $(RCUJA) $(COMPAT) -liburcu_cds_la_LIBADD = liburcu-common.la +liburcu_cds_la_LIBADD = liburcu-common.la liburcu.la pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = liburcu-cds.pc liburcu.pc liburcu-bp.pc liburcu-qsbr.pc \ diff --git a/rcuja/rcuja-shadow-nodes.c b/rcuja/rcuja-shadow-nodes.c new file mode 100644 index 0000000..6094b7a --- /dev/null +++ b/rcuja/rcuja-shadow-nodes.c @@ -0,0 +1,60 @@ +/* + * rcuja/rcuja-hashtable.c + * + * Userspace RCU library - RCU Judy Array Shadow Node Hash Table + * + * Copyright 2012 - 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 + */ + +#define _LGPL_SOURCE +#include +#include +#include + +/* + * The hash table used by judy array updates only for the shadow node + * mapping rely on standard urcu_mb flavor. It does not put any + * requirement on the RCU flavor used by applications using the judy + * array. + */ +#include + +#include +#include +#include +#include +#include + +#include "rcuja-internal.h" +#include "bitfield.h" + +__attribute__((visibility("protected"))) +struct cds_lfht *rcuja_create_ht(void) +{ + return cds_lfht_new(1, 1, 0, + CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, + NULL); +} + +__attribute__((visibility("protected"))) +void rcuja_delete_ht(struct cds_lfht *ht) +{ + int ret; + + ret = cds_lfht_destroy(ht, NULL); + assert(!ret); +} diff --git a/rcuja/rcuja.c b/rcuja/rcuja.c index 6d815e2..4b90aa6 100644 --- a/rcuja/rcuja.c +++ b/rcuja/rcuja.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#define _LGPL_SOURCE #include #include #include