From: Lai Jiangshan Date: Mon, 28 Nov 2011 13:22:36 +0000 (-0500) Subject: Add rcu_flavor X-Git-Tag: v0.7.0~43^2~40 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=541d828d3101283ccdb1e25fa5a885e1d1743c1a;p=userspace-rcu.git Add rcu_flavor Not all related functions are added. Left functions will be added when needed. Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- diff --git a/Makefile.am b/Makefile.am index 4e4ce89..1290551 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/urcu-bp.c b/urcu-bp.c index 4c0ab54..3b2062d 100644 --- 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" diff --git a/urcu-bp.h b/urcu-bp.h index 451bedb..efb5dca 100644 --- a/urcu-bp.h +++ b/urcu-bp.h @@ -135,5 +135,6 @@ static inline void rcu_thread_online(void) #include #include +#include #endif /* _URCU_BP_H */ diff --git a/urcu-flavor.h b/urcu-flavor.h new file mode 100644 index 0000000..e46c9a1 --- /dev/null +++ b/urcu-flavor.h @@ -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 + * + * 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 */ diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 5530295..06e81c7 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -356,5 +356,7 @@ void rcu_exit(void) */ } +DEFINE_RCU_FLAVOR() + #include "urcu-call-rcu-impl.h" #include "urcu-defer-impl.h" diff --git a/urcu-qsbr.h b/urcu-qsbr.h index b362304..a2f6575 100644 --- a/urcu-qsbr.h +++ b/urcu-qsbr.h @@ -127,5 +127,6 @@ extern void rcu_unregister_thread(void); #include #include +#include #endif /* _URCU_QSBR_H */ diff --git a/urcu.c b/urcu.c index ba013d9..b434655 100644 --- 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 --- a/urcu.h +++ b/urcu.h @@ -128,5 +128,6 @@ static inline void rcu_thread_online(void) #include #include +#include #endif /* _URCU_H */ diff --git a/urcu/map/urcu-bp.h b/urcu/map/urcu-bp.h index 4abe8dc..16601a1 100644 --- a/urcu/map/urcu-bp.h +++ b/urcu/map/urcu-bp.h @@ -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 */ diff --git a/urcu/map/urcu-qsbr.h b/urcu/map/urcu-qsbr.h index 0d88d83..a95441d 100644 --- a/urcu/map/urcu-qsbr.h +++ b/urcu/map/urcu-qsbr.h @@ -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 */ diff --git a/urcu/map/urcu.h b/urcu/map/urcu.h index 3f436a7..dd7a691 100644 --- a/urcu/map/urcu.h +++ b/urcu/map/urcu.h @@ -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 @@ -127,6 +129,8 @@ #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 @@ -159,6 +163,8 @@ #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"