X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_urcu.c;h=1b1b94b5bfcebc77c3fec5481e528858d62ed4f9;hp=870f133ab75f82b03f997cea1518f9e1979e4403;hb=bd252a04bbbb163aa4d8864b1e1e5a3a4d9d0892;hpb=4d0d66bb795d1ed938e11a97a4e5f71326e20c71 diff --git a/tests/test_urcu.c b/tests/test_urcu.c index 870f133..1b1b94b 100644 --- a/tests/test_urcu.c +++ b/tests/test_urcu.c @@ -35,6 +35,7 @@ #include #include +#include #ifdef __linux__ #include @@ -154,8 +155,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; @@ -242,7 +243,7 @@ void *thr_reader(void *_count) if (caa_unlikely(rduration)) loop_sleep(rduration); rcu_read_unlock(); - nr_reads++; + URCU_TLS(nr_reads)++; if (caa_unlikely(!test_duration_read())) break; } @@ -253,7 +254,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); @@ -287,7 +288,7 @@ void *thr_writer(void *_count) old->a = 0; test_array_free(old); rcu_copy_mutex_unlock(); - nr_writes++; + URCU_TLS(nr_writes)++; if (caa_unlikely(!test_duration_write())) break; if (caa_unlikely(wdelay)) @@ -296,7 +297,7 @@ void *thr_writer(void *_count) 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); }