Use urcu/tls-compat.h
[urcu.git] / tests / test_urcu_defer.c
index 1575e9c3523a45e07d96e4eae59af99acad54d63..cd9780b6f02f0b44d6f08e5ce5961590ebcde04a 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/tls-compat.h>
 
 #ifdef __linux__
 #include <syscall.h>
@@ -155,8 +156,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 long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes;
@@ -213,14 +214,14 @@ 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;
        }
 
        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);
@@ -271,7 +272,7 @@ void *thr_writer(void *data)
                defer_rcu(test_cb2, (void *)-2L);
                defer_rcu(test_cb2, (void *)-4L);
                defer_rcu(test_cb2, (void *)-2L);
-               nr_writes++;
+               URCU_TLS(nr_writes)++;
                if (caa_unlikely(!test_duration_write()))
                        break;
                if (caa_unlikely(wdelay))
@@ -282,7 +283,7 @@ void *thr_writer(void *data)
 
        printf_verbose("thread_end %s, thread id : %lx, tid %lu\n",
                        "writer", pthread_self(), (unsigned long)gettid());
-       tot_nr_writes[wtidx] = nr_writes;
+       tot_nr_writes[wtidx] = URCU_TLS(nr_writes);
        return ((void*)2);
 }
 
This page took 0.023721 seconds and 4 git commands to generate.