Add rcu_flavor
authorLai Jiangshan <laijs@cn.fujitsu.com>
Mon, 28 Nov 2011 13:22:36 +0000 (08:22 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 28 Nov 2011 13:22:36 +0000 (08:22 -0500)
Not all related functions are added.
Left functions will be added when needed.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile.am
urcu-bp.c
urcu-bp.h
urcu-flavor.h [new file with mode: 0644]
urcu-qsbr.c
urcu-qsbr.h
urcu.c
urcu.h
urcu/map/urcu-bp.h
urcu/map/urcu-qsbr.h
urcu/map/urcu.h

index 4e4ce894b9bc1ee8d1f247a8da8255b526619f59..1290551c4dca8a68f6f90141a29e09e92c391dbd 100644 (file)
@@ -8,7 +8,7 @@ AM_CFLAGS=-Wall
 SUBDIRS = . tests
 
 include_HEADERS = urcu.h urcu-bp.h urcu-call-rcu.h urcu-defer.h \
-               urcu-pointer.h urcu-qsbr.h
+               urcu-pointer.h urcu-qsbr.h urcu-flavor.h
 nobase_dist_include_HEADERS = urcu/compiler.h urcu/hlist.h urcu/list.h \
                urcu/rculist.h urcu/rcuhlist.h urcu/system.h urcu/futex.h \
                urcu/uatomic/generic.h urcu/arch/generic.h urcu/wfstack.h \
index 4c0ab54a28e71b47947905d6f5f42354de0135cd..3b2062d6590034ad33619ab1372b137237a9fd1e 100644 (file)
--- a/urcu-bp.c
+++ b/urcu-bp.c
@@ -421,5 +421,7 @@ void rcu_bp_after_fork_child(void)
        assert(!ret);
 }
 
+DEFINE_RCU_FLAVOR()
+
 #include "urcu-call-rcu-impl.h"
 #include "urcu-defer-impl.h"
index 451bedb8dd4700b2f69c788682695005ef71af36..efb5dca8f92c1186b2187bbfa8ee40f9fa911ab4 100644 (file)
--- a/urcu-bp.h
+++ b/urcu-bp.h
@@ -135,5 +135,6 @@ static inline void rcu_thread_online(void)
 
 #include <urcu-call-rcu.h>
 #include <urcu-defer.h>
+#include <urcu-flavor.h>
 
 #endif /* _URCU_BP_H */
diff --git a/urcu-flavor.h b/urcu-flavor.h
new file mode 100644 (file)
index 0000000..e46c9a1
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef _URCU_FLAVOR_H
+#define _URCU_FLAVOR_H
+
+/*
+ * urcu-flavor.h
+ *
+ * Userspace RCU header - rcu flavor declarations
+ *
+ * Copyright (c) 2011 Lai Jiangshan <laijs@cn.fujitsu.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
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct rcu_flavor_struct {
+       void (*read_lock)(void);
+       void (*read_unlock)(void);
+       void (*read_quiescent_state)(void);
+       void (*update_call_rcu)(struct rcu_head *head,
+                               void (*func)(struct rcu_head *head));
+       void (*update_synchronize_rcu)(void);
+       void (*update_defer_rcu)(void (*fct)(void *p), void *p);
+
+       void (*thread_offline)(void);
+       void (*thread_online)(void);
+       void (*register_thread)(void);
+       void (*unregister_thread)(void);
+};
+
+#define DEFINE_RCU_FLAVOR()                            \
+const struct rcu_flavor_struct rcu_flavor = {          \
+       .read_lock              = rcu_read_lock,        \
+       .read_unlock            = rcu_read_unlock,      \
+       .read_quiescent_state   = rcu_quiescent_state,  \
+       .update_call_rcu        = call_rcu,             \
+       .update_synchronize_rcu = synchronize_rcu,      \
+       .update_defer_rcu       = defer_rcu,            \
+       .thread_offline         = rcu_thread_offline,   \
+       .thread_online          = rcu_thread_online,    \
+       .register_thread        = rcu_register_thread,  \
+       .unregister_thread      = rcu_unregister_thread,\
+};
+
+extern const struct rcu_flavor_struct rcu_flavor;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _URCU_FLAVOR_H */
index 553029578a210383df955fb384d6102ad807d51e..06e81c7bbbbe47ad5eb4b0b40bf81be55d8bb9b7 100644 (file)
@@ -356,5 +356,7 @@ void rcu_exit(void)
         */
 }
 
+DEFINE_RCU_FLAVOR()
+
 #include "urcu-call-rcu-impl.h"
 #include "urcu-defer-impl.h"
index b362304578a50a93f407d2a6cf97dc143340de30..a2f6575986bf7976811ae6db3150f81f457609c4 100644 (file)
@@ -127,5 +127,6 @@ extern void rcu_unregister_thread(void);
 
 #include <urcu-call-rcu.h>
 #include <urcu-defer.h>
+#include <urcu-flavor.h>
 
 #endif /* _URCU_QSBR_H */
diff --git a/urcu.c b/urcu.c
index ba013d990b6f052da8e85f69af7192de72a4b799..b4346551b2403127da9822f08223f875c991e4ca 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -452,5 +452,7 @@ void rcu_exit(void)
 
 #endif /* #ifdef RCU_SIGNAL */
 
+DEFINE_RCU_FLAVOR()
+
 #include "urcu-call-rcu-impl.h"
 #include "urcu-defer-impl.h"
diff --git a/urcu.h b/urcu.h
index 1ad971c7744c2fe2e92d0e0b63daaccf88a0d05f..cd4fcbbfd0a871878e006faa561b74a15c91ab57 100644 (file)
--- a/urcu.h
+++ b/urcu.h
@@ -128,5 +128,6 @@ static inline void rcu_thread_online(void)
 
 #include <urcu-call-rcu.h>
 #include <urcu-defer.h>
+#include <urcu-flavor.h>
 
 #endif /* _URCU_H */
index 4abe8dccb1bc8d56358baedf9f5457eb608730c8..16601a1f7f842c6703a10cb63bffe784f5afc2b1 100644 (file)
@@ -64,4 +64,6 @@
 #define rcu_defer_barrier              rcu_defer_barrier_bp
 #define rcu_defer_barrier_thread       rcu_defer_barrier_thread_bp
 
+#define rcu_flavor                     rcu_flavor_bp
+
 #endif /* _URCU_BP_MAP_H */
index 0d88d83afa3d70946f131c36fdf296aeea3a4c28..a95441d2d36206b2a61b5e22097e615de76d819f 100644 (file)
@@ -66,4 +66,6 @@
 #define        rcu_defer_barrier               rcu_defer_barrier_qsbr
 #define rcu_defer_barrier_thread       rcu_defer_barrier_thread_qsbr
 
+#define rcu_flavor                     rcu_flavor_qsbr
+
 #endif /* _URCU_QSBR_MAP_H */
index 3f436a7375120366bca0898aafd3debdc45a48a5..dd7a6914b93f5c2325dae840824b89d1790b2259 100644 (file)
@@ -95,6 +95,8 @@
 #define rcu_defer_barrier              rcu_defer_barrier_memb
 #define rcu_defer_barrier_thread       rcu_defer_barrier_thread_memb
 
+#define rcu_flavor                     rcu_flavor_memb
+
 #elif defined(RCU_SIGNAL)
 
 #define rcu_read_lock                  rcu_read_lock_sig
 #define rcu_defer_barrier              rcu_defer_barrier_sig
 #define rcu_defer_barrier_thread       rcu_defer_barrier_thread_sig
 
+#define rcu_flavor                     rcu_flavor_sig
+
 #elif defined(RCU_MB)
 
 #define rcu_read_lock                  rcu_read_lock_mb
 #define rcu_defer_barrier              rcu_defer_barrier_mb
 #define rcu_defer_barrier_thread       rcu_defer_barrier_thread_mb
 
+#define rcu_flavor                     rcu_flavor_mb
+
 #else
 
 #error "Undefined selection"
This page took 0.030596 seconds and 4 git commands to generate.