The BP library flavor stands for "bulletproof". It is specifically
designed to help tracing library to hook on applications without
-requiring to modify these applications. `urcu_bp_init()`,
-`urcu_bp_register_thread()` and `urcu_bp_unregister_thread()` all become
-nops. The state is dealt with by the library internally at the expense
-of read-side and write-side performance.
+requiring to modify these applications. `urcu_bp_init()`, and
+`urcu_bp_unregister_thread()` all become nops, whereas calling
+`urcu_bp_register_thread()` becomes optional. The state is dealt with by
+the library internally at the expense of read-side and write-side
+performance.
### Initialization
extern void urcu_bp_after_fork_child(void);
/*
- * In the bulletproof version, the following functions are no-ops.
+ * In the bulletproof version, thread registration is performed lazily,
+ * but it can be forced by issuing an explicit urcu_bp_register_thread().
*/
-static inline void urcu_bp_register_thread(void)
-{
-}
+extern void urcu_bp_register_thread(void);
+/*
+ * In the bulletproof version, the following functions are no-ops.
+ */
static inline void urcu_bp_unregister_thread(void)
{
}
}
URCU_ATTR_ALIAS("urcu_bp_register") void rcu_bp_register();
+void urcu_bp_register_thread(void)
+{
+ if (caa_unlikely(!URCU_TLS(urcu_bp_reader)))
+ urcu_bp_register(); /* If not yet registered. */
+}
+
/* Disable signals, take mutex, remove from registry */
static
void urcu_bp_unregister(struct rcu_reader *rcu_reader_reg)