From: Mathieu Desnoyers Date: Thu, 1 Nov 2012 21:49:39 +0000 (-0400) Subject: Fix static linking: fix symbol name namespaces X-Git-Tag: v0.8.0~167 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1de4df4b770e5e90440008becc5e14a15c75c6e0;p=userspace-rcu.git Fix static linking: fix symbol name namespaces gp_futex, yield_active, rand_yield, has_sys_membarrier, rcu_defer_exit, call_rcu_data_free, call_rcu_before_fork, call_rcu_after_fork_parent, call_rcu_after_fork_child are exported by each urcu flavor. In order to fix use-cases where multiple flavors are statically linked into the same application, we need to move these symbols to local namespaces. Ensure that all symbols are prefixed by "rcu_". Also add each of those symbols into urcu/map/*.h headers, so they get mapped to their flavor-specific symbol name by the preprocessor. This requires bumping our .so version from 1.0.0 to 2.0.0, because it changes some symbol names. Signed-off-by: Mathieu Desnoyers --- diff --git a/configure.ac b/configure.ac index 33e8df7..4d0c7f4 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,7 @@ AC_INIT([userspace-rcu],[0.7.4],[mathieu dot desnoyers at efficios dot com]) # Following the numbering scheme proposed by libtool for the library version # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -AC_SUBST([URCU_LIBRARY_VERSION], [1:0:0]) +AC_SUBST([URCU_LIBRARY_VERSION], [2:0:0]) AC_CONFIG_AUX_DIR([config]) AC_CONFIG_MACRO_DIR([config]) diff --git a/tests/test_urcu.c b/tests/test_urcu.c index eed3dfb..373e1d2 100644 --- a/tests/test_urcu.c +++ b/tests/test_urcu.c @@ -62,7 +62,7 @@ static inline pid_t gettid(void) #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE #else -#define debug_yield_read() +#define rcu_debug_yield_read() #endif #include @@ -238,7 +238,7 @@ void *thr_reader(void *_count) for (;;) { rcu_read_lock(); local_ptr = rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -354,10 +354,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/tests/test_urcu_assign.c b/tests/test_urcu_assign.c index 68e84bd..9e10225 100644 --- a/tests/test_urcu_assign.c +++ b/tests/test_urcu_assign.c @@ -62,7 +62,7 @@ static inline pid_t gettid(void) #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE #else -#define debug_yield_read() +#define rcu_debug_yield_read() #endif #include @@ -238,7 +238,7 @@ void *thr_reader(void *_count) for (;;) { rcu_read_lock(); local_ptr = rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -351,10 +351,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/tests/test_urcu_bp.c b/tests/test_urcu_bp.c index afbc1a2..8ab0f5a 100644 --- a/tests/test_urcu_bp.c +++ b/tests/test_urcu_bp.c @@ -62,7 +62,7 @@ static inline pid_t gettid(void) #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE #else -#define debug_yield_read() +#define rcu_debug_yield_read() #endif #include @@ -238,7 +238,7 @@ void *thr_reader(void *_count) for (;;) { rcu_read_lock(); local_ptr = rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -350,10 +350,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index 1fbb154..8d030df 100644 --- a/tests/test_urcu_defer.c +++ b/tests/test_urcu_defer.c @@ -62,7 +62,7 @@ static inline pid_t gettid(void) #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE #else -#define debug_yield_read() +#define rcu_debug_yield_read() #endif #include #include @@ -209,7 +209,7 @@ void *thr_reader(void *_count) for (;;) { rcu_read_lock(); local_ptr = rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -340,10 +340,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/tests/test_urcu_gc.c b/tests/test_urcu_gc.c index f824423..d2c8806 100644 --- a/tests/test_urcu_gc.c +++ b/tests/test_urcu_gc.c @@ -62,7 +62,7 @@ static inline pid_t gettid(void) #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE #else -#define debug_yield_read() +#define rcu_debug_yield_read() #endif #include @@ -217,7 +217,7 @@ void *thr_reader(void *_count) for (;;) { rcu_read_lock(); local_ptr = rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -361,10 +361,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/tests/test_urcu_hash_rw.c b/tests/test_urcu_hash_rw.c index a789236..3eb7292 100644 --- a/tests/test_urcu_hash_rw.c +++ b/tests/test_urcu_hash_rw.c @@ -92,7 +92,7 @@ void *test_hash_rw_thr_reader(void *_count) } else { URCU_TLS(lookup_ok)++; } - debug_yield_read(); + rcu_debug_yield_read(); if (caa_unlikely(rduration)) loop_sleep(rduration); rcu_read_unlock(); diff --git a/tests/test_urcu_hash_unique.c b/tests/test_urcu_hash_unique.c index 610f479..89e2943 100644 --- a/tests/test_urcu_hash_unique.c +++ b/tests/test_urcu_hash_unique.c @@ -95,7 +95,7 @@ void *test_hash_unique_thr_reader(void *_count) } rcu_read_unlock(); - debug_yield_read(); + rcu_debug_yield_read(); if (caa_unlikely(rduration)) loop_sleep(rduration); URCU_TLS(nr_reads)++; diff --git a/tests/test_urcu_qsbr.c b/tests/test_urcu_qsbr.c index 7f27038..2e3e446 100644 --- a/tests/test_urcu_qsbr.c +++ b/tests/test_urcu_qsbr.c @@ -62,7 +62,7 @@ static inline pid_t gettid(void) #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE #else -#define debug_yield_read() +#define rcu_debug_yield_read() #endif #include "urcu-qsbr.h" @@ -237,7 +237,7 @@ void *thr_reader(void *_count) for (;;) { rcu_read_lock(); local_ptr = rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -357,10 +357,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/tests/test_urcu_qsbr_gc.c b/tests/test_urcu_qsbr_gc.c index f8cf784..11668ee 100644 --- a/tests/test_urcu_qsbr_gc.c +++ b/tests/test_urcu_qsbr_gc.c @@ -213,7 +213,7 @@ void *thr_reader(void *_count) for (;;) { _rcu_read_lock(); local_ptr = _rcu_dereference(test_rcu_pointer); - debug_yield_read(); + rcu_debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); if (caa_unlikely(rduration)) @@ -361,10 +361,10 @@ int main(int argc, char **argv) switch (argv[i][1]) { #ifdef DEBUG_YIELD case 'r': - yield_active |= YIELD_READ; + rcu_yield_active |= RCU_YIELD_READ; break; case 'w': - yield_active |= YIELD_WRITE; + rcu_yield_active |= RCU_YIELD_WRITE; break; #endif case 'a': diff --git a/urcu-bp.c b/urcu-bp.c index 5dccbcd..b07a1bb 100644 --- a/urcu-bp.c +++ b/urcu-bp.c @@ -105,8 +105,8 @@ void __attribute__((destructor)) rcu_bp_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; #ifdef DEBUG_YIELD -unsigned int yield_active; -DEFINE_URCU_TLS(unsigned int, rand_yield); +unsigned int rcu_yield_active; +DEFINE_URCU_TLS(unsigned int, rcu_rand_yield); #endif /* diff --git a/urcu-qsbr.c b/urcu-qsbr.c index 19e68d2..c6a1b18 100644 --- a/urcu-qsbr.c +++ b/urcu-qsbr.c @@ -53,7 +53,7 @@ void __attribute__((destructor)) rcu_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; -int32_t gp_futex; +int32_t rcu_gp_futex; /* * Global grace period counter. @@ -72,8 +72,8 @@ unsigned long rcu_gp_ctr = RCU_GP_ONLINE; DEFINE_URCU_TLS(struct rcu_reader, rcu_reader); #ifdef DEBUG_YIELD -unsigned int yield_active; -DEFINE_URCU_TLS(unsigned int, rand_yield); +unsigned int rcu_yield_active; +DEFINE_URCU_TLS(unsigned int, rcu_rand_yield); #endif static CDS_LIST_HEAD(registry); @@ -111,8 +111,8 @@ static void wait_gp(void) { /* Read reader_gp before read futex */ cmm_smp_rmb(); - if (uatomic_read(&gp_futex) == -1) - futex_noasync(&gp_futex, FUTEX_WAIT, -1, + if (uatomic_read(&rcu_gp_futex) == -1) + futex_noasync(&rcu_gp_futex, FUTEX_WAIT, -1, NULL, NULL, 0); } @@ -152,7 +152,7 @@ static void update_counter_and_wait(void) for (;;) { wait_loops++; if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { - uatomic_set(&gp_futex, -1); + uatomic_set(&rcu_gp_futex, -1); /* * Write futex before write waiting (the other side * reads them in the opposite order). @@ -173,7 +173,7 @@ static void update_counter_and_wait(void) if (wait_loops >= RCU_QS_ACTIVE_ATTEMPTS) { /* Read reader_gp before write futex */ cmm_smp_mb(); - uatomic_set(&gp_futex, 0); + uatomic_set(&rcu_gp_futex, 0); } break; } else { diff --git a/urcu.c b/urcu.c index 42a5829..c421846 100644 --- a/urcu.c +++ b/urcu.c @@ -63,7 +63,7 @@ #ifdef RCU_MEMBARRIER static int init_done; -int has_sys_membarrier; +int rcu_has_sys_membarrier; void __attribute__((constructor)) rcu_init(void); #endif @@ -83,7 +83,7 @@ void __attribute__((destructor)) rcu_exit(void); static pthread_mutex_t rcu_gp_lock = PTHREAD_MUTEX_INITIALIZER; -int32_t gp_futex; +int32_t rcu_gp_futex; /* * Global grace period counter. @@ -100,8 +100,8 @@ unsigned long rcu_gp_ctr = RCU_GP_COUNT; DEFINE_URCU_TLS(struct rcu_reader, rcu_reader); #ifdef DEBUG_YIELD -unsigned int yield_active; -DEFINE_URCU_TLS(unsigned int, rand_yield); +unsigned int rcu_yield_active; +DEFINE_URCU_TLS(unsigned int, rcu_rand_yield); #endif static CDS_LIST_HEAD(registry); @@ -140,7 +140,7 @@ static void mutex_unlock(pthread_mutex_t *mutex) #ifdef RCU_MEMBARRIER static void smp_mb_master(int group) { - if (caa_likely(has_sys_membarrier)) + if (caa_likely(rcu_has_sys_membarrier)) membarrier(MEMBARRIER_EXPEDITED); else cmm_smp_mb(); @@ -210,8 +210,8 @@ static void wait_gp(void) { /* Read reader_gp before read futex */ smp_mb_master(RCU_MB_GROUP); - if (uatomic_read(&gp_futex) == -1) - futex_async(&gp_futex, FUTEX_WAIT, -1, + if (uatomic_read(&rcu_gp_futex) == -1) + futex_async(&rcu_gp_futex, FUTEX_WAIT, -1, NULL, NULL, 0); } @@ -246,7 +246,7 @@ static void update_counter_and_wait(void) for (;;) { wait_loops++; if (wait_loops == RCU_QS_ACTIVE_ATTEMPTS) { - uatomic_dec(&gp_futex); + uatomic_dec(&rcu_gp_futex); /* Write futex before read reader_gp */ smp_mb_master(RCU_MB_GROUP); } @@ -261,7 +261,7 @@ static void update_counter_and_wait(void) if (wait_loops == RCU_QS_ACTIVE_ATTEMPTS) { /* Read reader_gp before write futex */ smp_mb_master(RCU_MB_GROUP); - uatomic_set(&gp_futex, 0); + uatomic_set(&rcu_gp_futex, 0); } break; } else { @@ -280,7 +280,7 @@ static void update_counter_and_wait(void) if (wait_loops == RCU_QS_ACTIVE_ATTEMPTS) { /* Read reader_gp before write futex */ smp_mb_master(RCU_MB_GROUP); - uatomic_set(&gp_futex, 0); + uatomic_set(&rcu_gp_futex, 0); } break; } else { @@ -389,7 +389,7 @@ void rcu_init(void) return; init_done = 1; if (!membarrier(MEMBARRIER_EXPEDITED | MEMBARRIER_QUERY)) - has_sys_membarrier = 1; + rcu_has_sys_membarrier = 1; } #endif diff --git a/urcu/map/urcu-bp.h b/urcu/map/urcu-bp.h index 16601a1..63582fd 100644 --- a/urcu/map/urcu-bp.h +++ b/urcu/map/urcu-bp.h @@ -45,6 +45,7 @@ #define synchronize_rcu synchronize_rcu_bp #define rcu_reader rcu_reader_bp #define rcu_gp_ctr rcu_gp_ctr_bp +#define rcu_gp_futex rcu_gp_futex_bp /* unused */ #define get_cpu_call_rcu_data get_cpu_call_rcu_data_bp #define get_call_rcu_thread get_call_rcu_thread_bp @@ -57,13 +58,21 @@ #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_bp #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_bp #define call_rcu call_rcu_bp +#define call_rcu_data_free call_rcu_data_free_bp +#define call_rcu_before_fork call_rcu_before_fork_bp +#define call_rcu_after_fork_parent call_rcu_after_fork_parent_bp +#define call_rcu_after_fork_child call_rcu_after_fork_child_bp #define defer_rcu defer_rcu_bp #define rcu_defer_register_thread rcu_defer_register_thread_bp #define rcu_defer_unregister_thread rcu_defer_unregister_thread_bp #define rcu_defer_barrier rcu_defer_barrier_bp #define rcu_defer_barrier_thread rcu_defer_barrier_thread_bp +#define rcu_defer_exit rcu_defer_exit_bp #define rcu_flavor rcu_flavor_bp +#define rcu_yield_active rcu_yield_active_bp +#define rcu_rand_yield rcu_rand_yield_bp + #endif /* _URCU_BP_MAP_H */ diff --git a/urcu/map/urcu-qsbr.h b/urcu/map/urcu-qsbr.h index a95441d..f0aecc9 100644 --- a/urcu/map/urcu-qsbr.h +++ b/urcu/map/urcu-qsbr.h @@ -48,6 +48,7 @@ #define synchronize_rcu synchronize_rcu_qsbr #define rcu_reader rcu_reader_qsbr #define rcu_gp_ctr rcu_gp_ctr_qsbr +#define rcu_gp_futex rcu_gp_futex_qsbr #define get_cpu_call_rcu_data get_cpu_call_rcu_data_qsbr #define get_call_rcu_thread get_call_rcu_thread_qsbr @@ -59,13 +60,21 @@ #define set_thread_call_rcu_data set_thread_call_rcu_data_qsbr #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_qsbr #define call_rcu call_rcu_qsbr +#define call_rcu_data_free call_rcu_data_free_qsbr +#define call_rcu_before_fork call_rcu_before_fork_qsbr +#define call_rcu_after_fork_parent call_rcu_after_fork_parent_qsbr +#define call_rcu_after_fork_child call_rcu_after_fork_child_qsbr #define defer_rcu defer_rcu_qsbr #define rcu_defer_register_thread rcu_defer_register_thread_qsbr #define rcu_defer_unregister_thread rcu_defer_unregister_thread_qsbr #define rcu_defer_barrier rcu_defer_barrier_qsbr #define rcu_defer_barrier_thread rcu_defer_barrier_thread_qsbr +#define rcu_defer_exit rcu_defer_exit_qsbr #define rcu_flavor rcu_flavor_qsbr +#define rcu_yield_active rcu_yield_active_memb_qsbr +#define rcu_rand_yield rcu_rand_yield_memb_qsbr + #endif /* _URCU_QSBR_MAP_H */ diff --git a/urcu/map/urcu.h b/urcu/map/urcu.h index dd7a691..759cb41 100644 --- a/urcu/map/urcu.h +++ b/urcu/map/urcu.h @@ -76,6 +76,7 @@ #define synchronize_rcu synchronize_rcu_memb #define rcu_reader rcu_reader_memb #define rcu_gp_ctr rcu_gp_ctr_memb +#define rcu_gp_futex rcu_gp_futex_memb #define get_cpu_call_rcu_data get_cpu_call_rcu_data_memb #define get_call_rcu_thread get_call_rcu_thread_memb @@ -88,15 +89,26 @@ #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_memb #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_memb #define call_rcu call_rcu_memb +#define call_rcu_data_free call_rcu_data_free_memb +#define call_rcu_before_fork call_rcu_before_fork_memb +#define call_rcu_after_fork_parent call_rcu_after_fork_parent_memb +#define call_rcu_after_fork_child call_rcu_after_fork_child_memb #define defer_rcu defer_rcu_memb #define rcu_defer_register_thread rcu_defer_register_thread_memb #define rcu_defer_unregister_thread rcu_defer_unregister_thread_memb #define rcu_defer_barrier rcu_defer_barrier_memb #define rcu_defer_barrier_thread rcu_defer_barrier_thread_memb +#define rcu_defer_exit rcu_defer_exit_memb #define rcu_flavor rcu_flavor_memb +#define rcu_yield_active rcu_yield_active_memb +#define rcu_rand_yield rcu_rand_yield_memb + +/* Specific to MEMBARRIER flavor */ +#define rcu_has_sys_membarrier rcu_has_sys_membarrier_memb + #elif defined(RCU_SIGNAL) #define rcu_read_lock rcu_read_lock_sig @@ -110,6 +122,7 @@ #define synchronize_rcu synchronize_rcu_sig #define rcu_reader rcu_reader_sig #define rcu_gp_ctr rcu_gp_ctr_sig +#define rcu_gp_futex rcu_gp_futex_sig #define get_cpu_call_rcu_data get_cpu_call_rcu_data_sig #define get_call_rcu_thread get_call_rcu_thread_sig @@ -122,15 +135,23 @@ #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_sig #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_sig #define call_rcu call_rcu_sig +#define call_rcu_data_free call_rcu_data_free_sig +#define call_rcu_before_fork call_rcu_before_fork_sig +#define call_rcu_after_fork_parent call_rcu_after_fork_parent_sig +#define call_rcu_after_fork_child call_rcu_after_fork_child_sig #define defer_rcu defer_rcu_sig #define rcu_defer_register_thread rcu_defer_register_thread_sig #define rcu_defer_unregister_thread rcu_defer_unregister_thread_sig #define rcu_defer_barrier rcu_defer_barrier_sig #define rcu_defer_barrier_thread rcu_defer_barrier_thread_sig +#define rcu_defer_exit rcu_defer_exit_sig #define rcu_flavor rcu_flavor_sig +#define rcu_yield_active rcu_yield_active_sig +#define rcu_rand_yield rcu_rand_yield_sig + #elif defined(RCU_MB) #define rcu_read_lock rcu_read_lock_mb @@ -144,6 +165,7 @@ #define synchronize_rcu synchronize_rcu_mb #define rcu_reader rcu_reader_mb #define rcu_gp_ctr rcu_gp_ctr_mb +#define rcu_gp_futex rcu_gp_futex_mb #define get_cpu_call_rcu_data get_cpu_call_rcu_data_mb #define get_call_rcu_thread get_call_rcu_thread_mb @@ -156,15 +178,23 @@ #define create_all_cpu_call_rcu_data create_all_cpu_call_rcu_data_mb #define free_all_cpu_call_rcu_data free_all_cpu_call_rcu_data_mb #define call_rcu call_rcu_mb +#define call_rcu_data_free call_rcu_data_free_mb +#define call_rcu_before_fork call_rcu_before_fork_mb +#define call_rcu_after_fork_parent call_rcu_after_fork_parent_mb +#define call_rcu_after_fork_child call_rcu_after_fork_child_mb #define defer_rcu defer_rcu_mb #define rcu_defer_register_thread rcu_defer_register_thread_mb #define rcu_defer_unregister_thread rcu_defer_unregister_thread_mb #define rcu_defer_barrier rcu_defer_barrier_mb #define rcu_defer_barrier_thread rcu_defer_barrier_thread_mb +#define rcu_defer_exit rcu_defer_exit_mb #define rcu_flavor rcu_flavor_mb +#define rcu_yield_active rcu_yield_active_mb +#define rcu_rand_yield rcu_rand_yield_mb + #else #error "Undefined selection" diff --git a/urcu/static/urcu-bp.h b/urcu/static/urcu-bp.h index a2f7368..6187bd3 100644 --- a/urcu/static/urcu-bp.h +++ b/urcu/static/urcu-bp.h @@ -64,8 +64,8 @@ extern "C" { #include #include -#define YIELD_READ (1 << 0) -#define YIELD_WRITE (1 << 1) +#define RCU_YIELD_READ (1 << 0) +#define RCU_YIELD_WRITE (1 << 1) /* * Updates without RCU_MB are much slower. Account this in @@ -74,37 +74,37 @@ extern "C" { /* maximum sleep delay, in us */ #define MAX_SLEEP 50 -extern unsigned int yield_active; -extern DECLARE_URCU_TLS(unsigned int, rand_yield); +extern unsigned int rcu_yield_active; +extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield); -static inline void debug_yield_read(void) +static inline void rcu_debug_yield_read(void) { - if (yield_active & YIELD_READ) - if (rand_r(&URCU_TLS(rand_yield)) & 0x1) - usleep(rand_r(&URCU_TLS(rand_yield)) % MAX_SLEEP); + if (rcu_yield_active & RCU_YIELD_READ) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); } -static inline void debug_yield_write(void) +static inline void rcu_debug_yield_write(void) { - if (yield_active & YIELD_WRITE) - if (rand_r(&URCU_TLS(rand_yield)) & 0x1) - usleep(rand_r(&URCU_TLS(rand_yield)) % MAX_SLEEP); + if (rcu_yield_active & RCU_YIELD_WRITE) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); } -static inline void debug_yield_init(void) +static inline void rcu_debug_yield_init(void) { - URCU_TLS(rand_yield) = time(NULL) ^ pthread_self(); + URCU_TLS(rcu_rand_yield) = time(NULL) ^ pthread_self(); } #else -static inline void debug_yield_read(void) +static inline void rcu_debug_yield_read(void) { } -static inline void debug_yield_write(void) +static inline void rcu_debug_yield_write(void) { } -static inline void debug_yield_init(void) +static inline void rcu_debug_yield_init(void) { } diff --git a/urcu/static/urcu-qsbr.h b/urcu/static/urcu-qsbr.h index 5580092..8b16a4a 100644 --- a/urcu/static/urcu-qsbr.h +++ b/urcu/static/urcu-qsbr.h @@ -68,43 +68,43 @@ extern "C" { #include #include -#define YIELD_READ (1 << 0) -#define YIELD_WRITE (1 << 1) +#define RCU_YIELD_READ (1 << 0) +#define RCU_YIELD_WRITE (1 << 1) /* maximum sleep delay, in us */ #define MAX_SLEEP 50 -extern unsigned int yield_active; -extern DECLARE_URCU_TLS(unsigned int, rand_yield); +extern unsigned int rcu_yield_active; +extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield); -static inline void debug_yield_read(void) +static inline void rcu_debug_yield_read(void) { - if (yield_active & YIELD_READ) - if (rand_r(&URCU_TLS(rand_yield)) & 0x1) - usleep(rand_r(&URCU_TLS(rand_yield)) % MAX_SLEEP); + if (rcu_yield_active & RCU_YIELD_READ) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); } -static inline void debug_yield_write(void) +static inline void rcu_debug_yield_write(void) { - if (yield_active & YIELD_WRITE) - if (rand_r(&URCU_TLS(rand_yield)) & 0x1) - usleep(rand_r(&URCU_TLS(rand_yield)) % MAX_SLEEP); + if (rcu_yield_active & RCU_YIELD_WRITE) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); } -static inline void debug_yield_init(void) +static inline void rcu_debug_yield_init(void) { - URCU_TLS(rand_yield) = time(NULL) ^ pthread_self(); + URCU_TLS(rcu_rand_yield) = time(NULL) ^ pthread_self(); } #else -static inline void debug_yield_read(void) +static inline void rcu_debug_yield_read(void) { } -static inline void debug_yield_write(void) +static inline void rcu_debug_yield_write(void) { } -static inline void debug_yield_init(void) +static inline void rcu_debug_yield_init(void) { } @@ -131,7 +131,7 @@ struct rcu_reader { extern DECLARE_URCU_TLS(struct rcu_reader, rcu_reader); -extern int32_t gp_futex; +extern int32_t rcu_gp_futex; /* * Wake-up waiting synchronize_rcu(). Called from many concurrent threads. @@ -141,10 +141,10 @@ static inline void wake_up_gp(void) if (caa_unlikely(_CMM_LOAD_SHARED(URCU_TLS(rcu_reader).waiting))) { _CMM_STORE_SHARED(URCU_TLS(rcu_reader).waiting, 0); cmm_smp_mb(); - if (uatomic_read(&gp_futex) != -1) + if (uatomic_read(&rcu_gp_futex) != -1) return; - uatomic_set(&gp_futex, 0); - futex_noasync(&gp_futex, FUTEX_WAKE, 1, + uatomic_set(&rcu_gp_futex, 0); + futex_noasync(&rcu_gp_futex, FUTEX_WAKE, 1, NULL, NULL, 0); } } diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h index c517693..f32f300 100644 --- a/urcu/static/urcu.h +++ b/urcu/static/urcu.h @@ -108,8 +108,8 @@ extern "C" { #include #include -#define YIELD_READ (1 << 0) -#define YIELD_WRITE (1 << 1) +#define RCU_YIELD_READ (1 << 0) +#define RCU_YIELD_WRITE (1 << 1) /* * Updates with RCU_SIGNAL are much slower. Account this in the delay. @@ -121,37 +121,37 @@ extern "C" { #define MAX_SLEEP 50 #endif -extern unsigned int yield_active; -extern DECLARE_URCU_TLS(unsigned int, rand_yield); +extern unsigned int rcu_yield_active; +extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield); -static inline void debug_yield_read(void) +static inline void rcu_debug_yield_read(void) { - if (yield_active & YIELD_READ) - if (rand_r(&URCU_TLS(rand_yield)) & 0x1) - usleep(rand_r(&URCU_TLS(rand_yield)) % MAX_SLEEP); + if (rcu_yield_active & RCU_YIELD_READ) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); } -static inline void debug_yield_write(void) +static inline void rcu_debug_yield_write(void) { - if (yield_active & YIELD_WRITE) - if (rand_r(&URCU_TLS(rand_yield)) & 0x1) - usleep(rand_r(&URCU_TLS(rand_yield)) % MAX_SLEEP); + if (rcu_yield_active & RCU_YIELD_WRITE) + if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1) + usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP); } -static inline void debug_yield_init(void) +static inline void rcu_debug_yield_init(void) { - URCU_TLS(rand_yield) = time(NULL) ^ (unsigned long) pthread_self(); + URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self(); } #else -static inline void debug_yield_read(void) +static inline void rcu_debug_yield_read(void) { } -static inline void debug_yield_write(void) +static inline void rcu_debug_yield_write(void) { } -static inline void debug_yield_init(void) +static inline void rcu_debug_yield_init(void) { } @@ -173,11 +173,11 @@ static inline void debug_yield_init(void) #define RCU_MB_GROUP MB_GROUP_ALL #ifdef RCU_MEMBARRIER -extern int has_sys_membarrier; +extern int rcu_has_sys_membarrier; static inline void smp_mb_slave(int group) { - if (caa_likely(has_sys_membarrier)) + if (caa_likely(rcu_has_sys_membarrier)) cmm_barrier(); else cmm_smp_mb(); @@ -225,16 +225,16 @@ struct rcu_reader { extern DECLARE_URCU_TLS(struct rcu_reader, rcu_reader); -extern int32_t gp_futex; +extern int32_t rcu_gp_futex; /* * Wake-up waiting synchronize_rcu(). Called from many concurrent threads. */ static inline void wake_up_gp(void) { - if (caa_unlikely(uatomic_read(&gp_futex) == -1)) { - uatomic_set(&gp_futex, 0); - futex_async(&gp_futex, FUTEX_WAKE, 1, + if (caa_unlikely(uatomic_read(&rcu_gp_futex) == -1)) { + uatomic_set(&rcu_gp_futex, 0); + futex_async(&rcu_gp_futex, FUTEX_WAKE, 1, NULL, NULL, 0); } }