X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=tests%2Ftest_rwlock.c;h=ccbc9d170c9e226dab54944881095f8c1599b39d;hp=9c8f97e39cf2232be5f461a655102ba1c3feac07;hb=ae51baf267fc36ccc259f9287e2750c138ff80bc;hpb=bc2433a9853a945a825c244e9ccfe341b73b2ceb diff --git a/tests/test_rwlock.c b/tests/test_rwlock.c index 9c8f97e..ccbc9d1 100644 --- a/tests/test_rwlock.c +++ b/tests/test_rwlock.c @@ -35,6 +35,7 @@ #include #include +#include #ifdef __linux__ #include @@ -156,8 +157,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; @@ -201,15 +202,15 @@ void *thr_reader(void *_count) for (;;) { pthread_rwlock_rdlock(&lock); assert(test_array.a == 8); - if (unlikely(rduration)) + if (caa_unlikely(rduration)) loop_sleep(rduration); pthread_rwlock_unlock(&lock); - nr_reads++; - if (unlikely(!test_duration_read())) + URCU_TLS(nr_reads)++; + if (caa_unlikely(!test_duration_read())) break; } - *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); @@ -234,19 +235,19 @@ void *thr_writer(void *_count) pthread_rwlock_wrlock(&lock); test_array.a = 0; test_array.a = 8; - if (unlikely(wduration)) + if (caa_unlikely(wduration)) loop_sleep(wduration); pthread_rwlock_unlock(&lock); - 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); }