X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_urcu_qsbr.c;h=421fb0739bd8f665d22f25bf9f04a607776ecbf2;hp=1c5a696c03491db909c4c2a23f42df9a0fe4b4b0;hb=bd252a04bbbb163aa4d8864b1e1e5a3a4d9d0892;hpb=9abc187826737149c44ef037ec0b2f3ed0fa36c2 diff --git a/tests/test_urcu_qsbr.c b/tests/test_urcu_qsbr.c index 1c5a696..421fb07 100644 --- a/tests/test_urcu_qsbr.c +++ b/tests/test_urcu_qsbr.c @@ -35,6 +35,7 @@ #include #include +#include #ifdef __linux__ #include @@ -153,8 +154,8 @@ static int test_duration_read(void) return !test_stop; } -static unsigned long long __thread nr_writes; -static unsigned long long __thread nr_reads; +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); static unsigned int nr_readers; static unsigned int nr_writers; @@ -238,14 +239,14 @@ void *thr_reader(void *_count) debug_yield_read(); if (local_ptr) assert(local_ptr->a == 8); - if (unlikely(rduration)) + if (caa_unlikely(rduration)) loop_sleep(rduration); rcu_read_unlock(); - nr_reads++; + URCU_TLS(nr_reads)++; /* QS each 1024 reads */ - if (unlikely((nr_reads & ((1 << 10) - 1)) == 0)) + if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0)) rcu_quiescent_state(); - if (unlikely(!test_duration_read())) + if (caa_unlikely(!test_duration_read())) break; } @@ -255,7 +256,7 @@ void *thr_reader(void *_count) rcu_register_thread(); rcu_unregister_thread(); - *count = nr_reads; + *count = URCU_TLS(nr_reads); printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "reader", pthread_self(), (unsigned long)gettid()); return ((void*)1); @@ -282,7 +283,7 @@ void *thr_writer(void *_count) new = test_array_alloc(); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); - if (unlikely(wduration)) + if (caa_unlikely(wduration)) loop_sleep(wduration); synchronize_rcu(); /* can be done after unlock */ @@ -290,16 +291,16 @@ void *thr_writer(void *_count) old->a = 0; test_array_free(old); rcu_copy_mutex_unlock(); - nr_writes++; - if (unlikely(!test_duration_write())) + URCU_TLS(nr_writes)++; + if (caa_unlikely(!test_duration_write())) break; - if (unlikely(wdelay)) + if (caa_unlikely(wdelay)) loop_sleep(wdelay); } printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "writer", pthread_self(), (unsigned long)gettid()); - *count = nr_writes; + *count = URCU_TLS(nr_writes); return ((void*)2); }