X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-bp.c;h=bb657d7dc620833d6c7b19cbf0b21e20c3ea78f4;hp=2ae3408c25fd42cc6788c6ec8664c91cf9868d87;hb=bd252a04bbbb163aa4d8864b1e1e5a3a4d9d0892;hpb=9380711ae3803da72aa1c7cf9ade5c3f93757006 diff --git a/urcu-bp.c b/urcu-bp.c index 2ae3408..bb657d7 100644 --- a/urcu-bp.c +++ b/urcu-bp.c @@ -39,6 +39,8 @@ #include "urcu/wfqueue.h" #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 @@ -93,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 /* @@ -108,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); @@ -321,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 */ @@ -362,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); @@ -420,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"