Use urcu/tls-compat.h
[urcu.git] / tests / test_urcu_bp.c
index ba80ae60f5129bd172960007b2f019e0ce9c1b7a..41caeb0995d1d19cfc6bab50d2179c5e2399d576 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/tls-compat.h>
 
 #ifdef __linux__
 #include <syscall.h>
@@ -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;
@@ -239,17 +240,17 @@ 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++;
-               if (unlikely(!test_duration_read()))
+               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);
@@ -276,23 +277,23 @@ 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();
                if (old)
                        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);
 }
 
This page took 0.023733 seconds and 4 git commands to generate.