From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Mon, 28 Nov 2011 08:23:44 -0500 Subject: [lttng-dev] [PATCH 07/12] Add rcu_flavor In-Reply-To: <1322467688-2930-8-git-send-email-laijs@cn.fujitsu.com> References: <1322467688-2930-1-git-send-email-laijs@cn.fujitsu.com> <1322467688-2930-8-git-send-email-laijs@cn.fujitsu.com> Message-ID: <20111128132344.GF2663@Krystal> * Lai Jiangshan (laijs at cn.fujitsu.com) wrote: > Not all related functions are added. > Left functions will be added when needed. merged, thanks! Mathieu > > Signed-off-by: Lai Jiangshan > --- > Makefile.am | 2 +- > urcu-bp.c | 2 + > urcu-bp.h | 1 + > urcu-flavor.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ > urcu-qsbr.c | 2 + > urcu-qsbr.h | 1 + > urcu.c | 2 + > urcu.h | 1 + > urcu/map/urcu-bp.h | 2 + > urcu/map/urcu-qsbr.h | 2 + > urcu/map/urcu.h | 6 ++++ > 11 files changed, 85 insertions(+), 1 deletions(-) > create mode 100644 urcu-flavor.h > > 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" > -- > 1.7.4.4 > -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com