Add rcu_read_ongoing() API to each urcu flavor
[urcu.git] / urcu / static / urcu-bp.h
index c7f532640e3c0feab165cb5a699c4c3760df011d..2f365206afad6db4c561654109def617ef559ce5 100644 (file)
@@ -223,6 +223,20 @@ 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)
+{
+       if (caa_unlikely(!URCU_TLS(rcu_reader)))
+               rcu_bp_register(); /* If not yet registered. */
+       return URCU_TLS(rcu_reader)->ctr & RCU_GP_CTR_NEST_MASK;
+}
+
 #ifdef __cplusplus 
 }
 #endif
This page took 0.022506 seconds and 4 git commands to generate.