X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-bp.c;h=bb657d7dc620833d6c7b19cbf0b21e20c3ea78f4;hp=4c0ab54a28e71b47947905d6f5f42354de0135cd;hb=bd252a04bbbb163aa4d8864b1e1e5a3a4d9d0892;hpb=618b25958fec4d76310f0d9c59e42128e73a8719 diff --git a/urcu-bp.c b/urcu-bp.c index 4c0ab54..bb657d7 100644 --- a/urcu-bp.c +++ b/urcu-bp.c @@ -40,6 +40,7 @@ #include "urcu/map/urcu-bp.h" #include "urcu/static/urcu-bp.h" #include "urcu-pointer.h" +#include "urcu/tls-compat.h" /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ #undef _LGPL_SOURCE @@ -94,7 +95,7 @@ static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; #ifdef DEBUG_YIELD unsigned int yield_active; -unsigned int __thread rand_yield; +DEFINE_URCU_TLS(unsigned int, rand_yield); #endif /* @@ -109,7 +110,7 @@ long rcu_gp_ctr = RCU_GP_COUNT; * Pointer to registry elements. Written to only by each individual reader. Read * by both the reader and the writers. */ -struct rcu_reader __thread *rcu_reader; +DEFINE_URCU_TLS(struct rcu_reader *, rcu_reader); static CDS_LIST_HEAD(registry); @@ -322,7 +323,7 @@ static void add_thread(void) rcu_reader_reg->tid = pthread_self(); assert(rcu_reader_reg->ctr == 0); cds_list_add(&rcu_reader_reg->node, ®istry); - rcu_reader = rcu_reader_reg; + URCU_TLS(rcu_reader) = rcu_reader_reg; } /* Called with signals off and mutex locked */ @@ -363,7 +364,7 @@ void rcu_bp_register(void) /* * Check if a signal concurrently registered our thread since * the check in rcu_read_lock(). */ - if (rcu_reader) + if (URCU_TLS(rcu_reader)) goto end; mutex_lock(&rcu_gp_lock); @@ -421,5 +422,30 @@ void rcu_bp_after_fork_child(void) assert(!ret); } +void *rcu_dereference_sym_bp(void *p) +{ + return _rcu_dereference(p); +} + +void *rcu_set_pointer_sym_bp(void **p, void *v) +{ + cmm_wmb(); + return uatomic_set(p, v); +} + +void *rcu_xchg_pointer_sym_bp(void **p, void *v) +{ + cmm_wmb(); + return uatomic_xchg(p, v); +} + +void *rcu_cmpxchg_pointer_sym_bp(void **p, void *old, void *_new) +{ + cmm_wmb(); + return uatomic_cmpxchg(p, old, _new); +} + +DEFINE_RCU_FLAVOR(rcu_flavor); + #include "urcu-call-rcu-impl.h" #include "urcu-defer-impl.h"