X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu.c;h=b4346551b2403127da9822f08223f875c991e4ca;hp=5a9c2f0ae761d9a4d7cd97ed7af4bfc42998edb7;hb=541d828d3101283ccdb1e25fa5a885e1d1743c1a;hpb=16aa9ee87cf4364921c36025359be01390338d87 diff --git a/urcu.c b/urcu.c index 5a9c2f0..b434655 100644 --- a/urcu.c +++ b/urcu.c @@ -24,18 +24,39 @@ */ #define _BSD_SOURCE +#define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include #include #include +#include #include #include #include -#include "urcu-static.h" +#include "urcu/wfqueue.h" +#include "urcu/map/urcu.h" +#include "urcu/static/urcu.h" +#include "urcu-pointer.h" + /* Do not #define _LGPL_SOURCE to ensure we can emit the wrapper symbols */ +#undef _LGPL_SOURCE #include "urcu.h" +#define _LGPL_SOURCE + +/* + * If a reader is really non-cooperative and refuses to commit its + * rcu_active_readers count to memory (there is no barrier in the reader + * per-se), kick it after a few loops waiting for it. + */ +#define KICK_READER_LOOPS 10000 + +/* + * Active attempts to check for reader Q.S. before calling futex(). + */ +#define RCU_QS_ACTIVE_ATTEMPTS 100 #ifdef RCU_MEMBARRIER static int init_done; @@ -59,7 +80,7 @@ void __attribute__((destructor)) rcu_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; -int gp_futex; +int32_t gp_futex; /* * Global grace period counter. @@ -99,9 +120,9 @@ static void mutex_lock(pthread_mutex_t *mutex) perror("Error in pthread mutex lock"); exit(-1); } - if (CAA_LOAD_SHARED(rcu_reader.need_mb)) { + if (CMM_LOAD_SHARED(rcu_reader.need_mb)) { cmm_smp_mb(); - _CAA_STORE_SHARED(rcu_reader.need_mb, 0); + _CMM_STORE_SHARED(rcu_reader.need_mb, 0); cmm_smp_mb(); } poll(NULL,0,10); @@ -123,7 +144,7 @@ static void mutex_unlock(pthread_mutex_t *mutex) #ifdef RCU_MEMBARRIER static void smp_mb_master(int group) { - if (likely(has_sys_membarrier)) + if (caa_likely(has_sys_membarrier)) membarrier(MEMBARRIER_EXPEDITED); else cmm_smp_mb(); @@ -155,7 +176,7 @@ static void force_mb_all_readers(void) * cache flush is enforced. */ cds_list_for_each_entry(index, ®istry, node) { - CAA_STORE_SHARED(index->need_mb, 1); + CMM_STORE_SHARED(index->need_mb, 1); pthread_kill(index->tid, SIGRCU); } /* @@ -172,7 +193,7 @@ static void force_mb_all_readers(void) * the Linux Test Project (LTP). */ cds_list_for_each_entry(index, ®istry, node) { - while (CAA_LOAD_SHARED(index->need_mb)) { + while (CMM_LOAD_SHARED(index->need_mb)) { pthread_kill(index->tid, SIGRCU); poll(NULL, 0, 1); } @@ -205,7 +226,7 @@ void update_counter_and_wait(void) struct rcu_reader *index, *tmp; /* Switch parity: 0 -> 1, 1 -> 0 */ - CAA_STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr ^ RCU_GP_CTR_PHASE); + CMM_STORE_SHARED(rcu_gp_ctr, rcu_gp_ctr ^ RCU_GP_CTR_PHASE); /* * Must commit rcu_gp_ctr update to memory before waiting for quiescent @@ -384,7 +405,7 @@ static void sigrcu_handler(int signo, siginfo_t *siginfo, void *context) * executed on. */ cmm_smp_mb(); - _CAA_STORE_SHARED(rcu_reader.need_mb, 0); + _CMM_STORE_SHARED(rcu_reader.need_mb, 0); cmm_smp_mb(); } @@ -428,4 +449,10 @@ void rcu_exit(void) assert(act.sa_sigaction == sigrcu_handler); assert(cds_list_empty(®istry)); } + #endif /* #ifdef RCU_SIGNAL */ + +DEFINE_RCU_FLAVOR() + +#include "urcu-call-rcu-impl.h" +#include "urcu-defer-impl.h"