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 4e4ce89..1290551 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 4c0ab54..3b2062d 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 451bedb..efb5dca 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 5530295..06e81c7 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 b362304..a2f6575 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 ba013d9..b434655 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 1ad971c..cd4fcbb 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 4abe8dc..16601a1 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 0d88d83..a95441d 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 3f436a7..dd7a691 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.038588 seconds and 4 git commands to generate.