X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Furcu.c;h=f5a32317813a1290139e77c397d7d19db73b46c4;hb=440c99a97ddff4d611eb3001ff0d5c2daf0bdc88;hp=e64432f8bb7034cf3ef63cacc03aca7884133b74;hpb=70469b43316ecc8d6053550504858ad8a8ef9b16;p=urcu.git diff --git a/src/urcu.c b/src/urcu.c index e64432f..f5a3231 100644 --- a/src/urcu.c +++ b/src/urcu.c @@ -94,8 +94,6 @@ static int urcu_memb_has_sys_membarrier_private_expedited; * uninitialized variable. */ int urcu_memb_has_sys_membarrier = 0; -URCU_ATTR_ALIAS("urcu_memb_has_sys_membarrier") -extern int rcu_has_sys_membarrier_memb; #endif void __attribute__((constructor)) rcu_init(void); @@ -105,8 +103,6 @@ void __attribute__((constructor)) rcu_init(void); void rcu_init(void) { } -URCU_ATTR_ALIAS(urcu_stringify(rcu_init)) -void alias_rcu_init(void); #endif #ifdef RCU_SIGNAL @@ -132,15 +128,12 @@ static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; */ static pthread_mutex_t rcu_registry_lock = PTHREAD_MUTEX_INITIALIZER; struct urcu_gp rcu_gp = { .ctr = URCU_GP_COUNT }; -URCU_ATTR_ALIAS(urcu_stringify(rcu_gp)) -extern struct urcu_gp alias_rcu_gp; /* * Written to only by each individual reader. Read by both the reader and the * writers. */ DEFINE_URCU_TLS(struct urcu_reader, rcu_reader); -DEFINE_URCU_TLS_ALIAS(struct urcu_reader, rcu_reader, alias_rcu_reader); static CDS_LIST_HEAD(registry); @@ -266,17 +259,25 @@ static void wait_gp(void) smp_mb_master(); /* Temporarily unlock the registry lock. */ mutex_unlock(&rcu_registry_lock); - if (uatomic_read(&rcu_gp.futex) != -1) - goto end; - while (futex_async(&rcu_gp.futex, FUTEX_WAIT, -1, - NULL, NULL, 0)) { + while (uatomic_read(&rcu_gp.futex) == -1) { + if (!futex_async(&rcu_gp.futex, FUTEX_WAIT, -1, NULL, NULL, 0)) { + /* + * Prior queued wakeups queued by unrelated code + * using the same address can cause futex wait to + * return 0 even through the futex value is still + * -1 (spurious wakeups). Check the value again + * in user-space to validate whether it really + * differs from -1. + */ + continue; + } switch (errno) { - case EWOULDBLOCK: + case EAGAIN: /* Value already changed. */ goto end; case EINTR: /* Retry if interrupted by signal. */ - break; /* Get out of switch. */ + break; /* Get out of switch. Check again. */ default: /* Unexpected error. */ urcu_die(errno); @@ -516,8 +517,6 @@ out: */ urcu_wake_all_waiters(&waiters); } -URCU_ATTR_ALIAS(urcu_stringify(synchronize_rcu)) -void alias_synchronize_rcu(); /* * library wrappers to be used by non-LGPL compatible source code. @@ -527,22 +526,16 @@ void rcu_read_lock(void) { _rcu_read_lock(); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_read_lock)) -void alias_rcu_read_lock(); void rcu_read_unlock(void) { _rcu_read_unlock(); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_read_unlock)) -void alias_rcu_read_unlock(); int rcu_read_ongoing(void) { return _rcu_read_ongoing(); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_read_ongoing)) -void alias_rcu_read_ongoing(); void rcu_register_thread(void) { @@ -557,8 +550,6 @@ void rcu_register_thread(void) cds_list_add(&URCU_TLS(rcu_reader).node, ®istry); mutex_unlock(&rcu_registry_lock); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_register_thread)) -void alias_rcu_register_thread(); void rcu_unregister_thread(void) { @@ -568,8 +559,6 @@ void rcu_unregister_thread(void) cds_list_del(&URCU_TLS(rcu_reader).node); mutex_unlock(&rcu_registry_lock); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_unregister_thread)) -void alias_rcu_unregister_thread(); #ifdef RCU_MEMBARRIER @@ -617,8 +606,6 @@ void rcu_init(void) init_done = 1; rcu_sys_membarrier_init(); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_init)) -void alias_rcu_init(void); #endif #ifdef RCU_SIGNAL @@ -660,8 +647,6 @@ void rcu_init(void) if (ret) urcu_die(errno); } -URCU_ATTR_ALIAS(urcu_stringify(rcu_init)) -void alias_rcu_init(void); void rcu_exit(void) { @@ -674,13 +659,10 @@ void rcu_exit(void) * assert(cds_list_empty(®istry)); */ } -URCU_ATTR_ALIAS(urcu_stringify(rcu_exit)) -void alias_rcu_exit(void); #endif /* #ifdef RCU_SIGNAL */ DEFINE_RCU_FLAVOR(rcu_flavor); -DEFINE_RCU_FLAVOR_ALIAS(rcu_flavor, alias_rcu_flavor); #include "urcu-call-rcu-impl.h" #include "urcu-defer-impl.h"