X-Git-Url: https://git.lttng.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Fstatic%2Furcu-bp.h;h=df25393d06d6a1a19b0b281f81cedf767bd2d470;hp=b6d5f132778380c57af501307cf25e017c92c8ec;hb=6ef5ddc9b4e136e250f3c5f292f847e6849e6200;hpb=2650042a5405028da49bfcfb71053b78a56a9ed4 diff --git a/urcu/static/urcu-bp.h b/urcu/static/urcu-bp.h index b6d5f13..df25393 100644 --- a/urcu/static/urcu-bp.h +++ b/urcu/static/urcu-bp.h @@ -39,6 +39,7 @@ #include #include #include +#include /* * This code section can only be included in LGPL 2.1 compatible source code. @@ -52,12 +53,6 @@ extern "C" { #endif -#ifdef DEBUG_RCU -#define rcu_assert(args...) assert(args) -#else -#define rcu_assert(args...) -#endif - enum rcu_state { RCU_READER_ACTIVE_CURRENT, RCU_READER_ACTIVE_OLD, @@ -159,6 +154,7 @@ static inline void _rcu_read_lock(void) rcu_bp_register(); /* If not yet registered. */ cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ tmp = URCU_TLS(rcu_reader)->ctr; + urcu_assert((tmp & RCU_GP_CTR_NEST_MASK) != RCU_GP_CTR_NEST_MASK); _rcu_read_lock_update(tmp); } @@ -169,11 +165,13 @@ static inline void _rcu_read_lock(void) */ static inline void _rcu_read_unlock(void) { - /* - * Finish using rcu before decrementing the pointer. - */ + unsigned long tmp; + + tmp = URCU_TLS(rcu_reader)->ctr; + urcu_assert(tmp & RCU_GP_CTR_NEST_MASK); + /* Finish using rcu before decrementing the pointer. */ cmm_smp_mb(); - _CMM_STORE_SHARED(URCU_TLS(rcu_reader)->ctr, URCU_TLS(rcu_reader)->ctr - RCU_GP_COUNT); + _CMM_STORE_SHARED(URCU_TLS(rcu_reader)->ctr, tmp - RCU_GP_COUNT); cmm_barrier(); /* Ensure the compiler does not reorder us with mutex */ }