urcu: make the code of urcu-qsbr as normal urcu
[urcu.git] / urcu / static / urcu.h
index f32f300e599d95b922cbf043cc3a839e234190d5..6c8b92602234b97d27a4cb462ec0ec06c56a62c7 100644 (file)
@@ -96,6 +96,12 @@ extern "C" {
 #define SIGRCU SIGUSR1
 #endif
 
+enum rcu_state {
+       RCU_READER_ACTIVE_CURRENT,
+       RCU_READER_ACTIVE_OLD,
+       RCU_READER_INACTIVE,
+};
+
 #ifdef DEBUG_RCU
 #define rcu_assert(args...)    assert(args)
 #else
@@ -239,7 +245,7 @@ static inline void wake_up_gp(void)
        }
 }
 
-static inline int rcu_gp_ongoing(unsigned long *ctr)
+static inline enum rcu_state rcu_reader_state(unsigned long *ctr)
 {
        unsigned long v;
 
@@ -248,8 +254,11 @@ static inline int rcu_gp_ongoing(unsigned long *ctr)
         * to insure consistency.
         */
        v = CMM_LOAD_SHARED(*ctr);
-       return (v & RCU_GP_CTR_NEST_MASK) &&
-                ((v ^ rcu_gp_ctr) & RCU_GP_CTR_PHASE);
+       if (!(v & RCU_GP_CTR_NEST_MASK))
+               return RCU_READER_INACTIVE;
+       if (!((v ^ rcu_gp_ctr) & RCU_GP_CTR_PHASE))
+               return RCU_READER_ACTIVE_CURRENT;
+       return RCU_READER_ACTIVE_OLD;
 }
 
 /*
@@ -320,6 +329,18 @@ static inline void _rcu_read_unlock(void)
        cmm_barrier();  /* Ensure the compiler does not reorder us with mutex */
 }
 
+/*
+ * Returns whether within a RCU read-side critical section.
+ *
+ * This function is less than 10 lines long.  The intent is that this
+ * function meets the 10-line criterion for LGPL, allowing this function
+ * to be invoked directly from non-LGPL code.
+ */
+static inline int _rcu_read_ongoing(void)
+{
+       return URCU_TLS(rcu_reader).ctr & RCU_GP_CTR_NEST_MASK;
+}
+
 #ifdef __cplusplus
 }
 #endif
This page took 0.022602 seconds and 4 git commands to generate.