Use urcu/tls-compat.h
[urcu.git] / tests / test_urcu_qsbr.c
index b986fd825fabc4d8663ab395f95d875631453133..421fb0739bd8f665d22f25bf9f04a607776ecbf2 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/tls-compat.h>
 
 #ifdef __linux__
 #include <syscall.h>
@@ -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;
@@ -241,9 +242,9 @@ void *thr_reader(void *_count)
                if (caa_unlikely(rduration))
                        loop_sleep(rduration);
                rcu_read_unlock();
-               nr_reads++;
+               URCU_TLS(nr_reads)++;
                /* QS each 1024 reads */
-               if (caa_unlikely((nr_reads & ((1 << 10) - 1)) == 0))
+               if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0))
                        rcu_quiescent_state();
                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);
@@ -290,7 +291,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))
@@ -299,7 +300,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);
 }
 
This page took 0.023745 seconds and 4 git commands to generate.