From ac258107eb2e669d6f8210c86164f1b2a028f5fc Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 18 Sep 2009 08:20:22 -0400 Subject: [PATCH] qsbr: use defines to clarify code. Signed-off-by: Mathieu Desnoyers --- urcu-qsbr-static.h | 5 ++++- urcu-qsbr.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/urcu-qsbr-static.h b/urcu-qsbr-static.h index 3d2ec8f..887dc3d 100644 --- a/urcu-qsbr-static.h +++ b/urcu-qsbr-static.h @@ -161,6 +161,9 @@ static inline void reader_barrier() smp_mb(); } +#define RCU_GP_ONLINE (1UL << 0) +#define RCU_GP_COUNT (1UL << 1) + /* * Global quiescent period counter with low-order bits unused. * Using a int rather than a char to eliminate false register dependencies @@ -182,7 +185,7 @@ static inline int rcu_gp_ongoing(unsigned long *value) static inline void _rcu_read_lock(void) { - rcu_assert(rcu_reader_qs_gp & 1); + rcu_assert(rcu_reader_qs_gp); } static inline void _rcu_read_unlock(void) diff --git a/urcu-qsbr.c b/urcu-qsbr.c index c0e643d..5f9e46d 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -42,7 +42,7 @@ pthread_mutex_t urcu_mutex = PTHREAD_MUTEX_INITIALIZER; /* * Global grace period counter. */ -unsigned long urcu_gp_ctr = 1; +unsigned long urcu_gp_ctr = RCU_GP_ONLINE; /* * Written to only by each individual reader. Read by both the reader and the @@ -153,7 +153,7 @@ void synchronize_rcu(void) STORE_SHARED(rcu_reader_qs_gp, 0); internal_urcu_lock(); - STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr + 2); + STORE_SHARED(urcu_gp_ctr, urcu_gp_ctr + RCU_GP_COUNT); wait_for_quiescent_state(); internal_urcu_unlock(); -- 2.34.1