X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu.h;h=27695d495aeeb6388b121a099183949cbbdbac06;hp=01a4c6857d7e6fd31668dec57615be03e94ccc91;hb=e462817ecdce42b00f0cb0825e2425b08943105b;hpb=1430ee0bdca4cb454d534ef7fc84af3e0692f26b diff --git a/urcu.h b/urcu.h index 01a4c68..27695d4 100644 --- a/urcu.h +++ b/urcu.h @@ -169,7 +169,29 @@ static inline void rcu_read_unlock(void) debug_yield_read(); } +/** + * rcu_assign_pointer - assign (publicize) a pointer to a newly + * initialized structure that will be dereferenced by RCU read-side + * critical sections. Returns the value assigned. + * + * Inserts memory barriers on architectures that require them + * (pretty much all of them other than x86), and also prevents + * the compiler from reordering the code that initializes the + * structure after the pointer assignment. More importantly, this + * call documents which pointers will be dereferenced by RCU read-side + * code. + */ + +#define rcu_assign_pointer(p, v) \ + ({ \ + if (!__builtin_constant_p(v) || \ + ((v) != NULL)) \ + wmb(); \ + (p) = (v); \ + }) + extern void *urcu_publish_content(void **ptr, void *new); +extern void synchronize_rcu(void); /* * Reader thread registration.