RCU dereference check if within read-side critical section
[urcu.git] / urcu / static / urcu-qsbr.h
index ef1f600d6c2248d3b1320b2056ef49b661660873..1ef830aba1833fa888ebdfa3ee4daa1034cbdf8c 100644 (file)
@@ -43,6 +43,7 @@
 #include <urcu/list.h>
 #include <urcu/futex.h>
 #include <urcu/tls-compat.h>
+#include <urcu/urcu-checker.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -68,58 +69,10 @@ enum rcu_state {
        RCU_READER_INACTIVE,
 };
 
-#ifdef DEBUG_YIELD
-#include <sched.h>
-#include <time.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#define RCU_YIELD_READ         (1 << 0)
-#define RCU_YIELD_WRITE        (1 << 1)
-
-/* maximum sleep delay, in us */
-#define MAX_SLEEP 50
-
-extern unsigned int rcu_yield_active;
-extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield);
-
-static inline void rcu_debug_yield_read(void)
-{
-       if (rcu_yield_active & RCU_YIELD_READ)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-       if (rcu_yield_active & RCU_YIELD_WRITE)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-       URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self();
-}
-#else
-static inline void rcu_debug_yield_read(void)
-{
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-
-}
-#endif
-
 #define RCU_GP_ONLINE          (1UL << 0)
 #define RCU_GP_CTR             (1UL << 1)
 
-struct urcu_gp {
+struct rcu_gp {
        /*
         * Global quiescent period counter with low-order bits unused.
         * Using a int rather than a char to eliminate false register
@@ -130,7 +83,7 @@ struct urcu_gp {
        int32_t futex;
 } __attribute__((aligned(CAA_CACHE_LINE_SIZE)));
 
-extern struct urcu_gp rcu_gp;
+extern struct rcu_gp rcu_gp;
 
 struct rcu_reader {
        /* Data used by both reader and synchronize_rcu() */
@@ -180,6 +133,7 @@ static inline enum rcu_state rcu_reader_state(unsigned long *ctr)
  */
 static inline void _rcu_read_lock(void)
 {
+       rcu_read_lock_debug();
        rcu_assert(URCU_TLS(rcu_reader).ctr);
 }
 
@@ -192,6 +146,7 @@ static inline void _rcu_read_lock(void)
  */
 static inline void _rcu_read_unlock(void)
 {
+       rcu_read_unlock_debug();
 }
 
 /*
This page took 0.023823 seconds and 4 git commands to generate.