Cleanup: fix cppcheck errors
[urcu.git] / tests / test_urcu_qsbr_gc.c
index 0c1c124ae6773e07c203d6e4b219272b8589de39..f8cf784ccd2a455c1afce76ec7dc7449cb671412 100644 (file)
@@ -35,6 +35,7 @@
 #include <errno.h>
 
 #include <urcu/arch.h>
+#include <urcu/tls-compat.h>
 
 #ifdef __linux__
 #include <syscall.h>
@@ -88,9 +89,9 @@ static struct reclaim_queue *pending_reclaims;
 /* write-side C.S. duration, in loops */
 static unsigned long wduration;
 
-static inline void loop_sleep(unsigned long l)
+static inline void loop_sleep(unsigned long loops)
 {
-       while(l-- != 0)
+       while (loops-- != 0)
                caa_cpu_relax();
 }
 
@@ -116,9 +117,10 @@ typedef unsigned long cpu_set_t;
 
 static void set_affinity(void)
 {
+#if HAVE_SCHED_SETAFFINITY
        cpu_set_t mask;
-       int cpu;
-       int ret;
+       int cpu, ret;
+#endif /* HAVE_SCHED_SETAFFINITY */
 
        if (!use_affinity)
                return;
@@ -159,8 +161,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;
@@ -214,20 +216,20 @@ 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++;
+               URCU_TLS(nr_reads)++;
                /* QS each 1024 reads */
-               if (unlikely((nr_reads & ((1 << 10) - 1)) == 0))
+               if (caa_unlikely((URCU_TLS(nr_reads) & ((1 << 10) - 1)) == 0))
                        _rcu_quiescent_state();
-               if (unlikely(!test_duration_read()))
+               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);
@@ -258,7 +260,7 @@ static void rcu_gc_reclaim(unsigned long wtidx, void *old)
        *pending_reclaims[wtidx].head = old;
        pending_reclaims[wtidx].head++;
 
-       if (likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue
+       if (caa_likely(pending_reclaims[wtidx].head - pending_reclaims[wtidx].queue
                        < reclaim_batch))
                return;
 
@@ -290,19 +292,19 @@ void *thr_writer(void *data)
                new->a = 8;
                old = _rcu_xchg_pointer(&test_rcu_pointer, new);
 #endif
-               if (unlikely(wduration))
+               if (caa_unlikely(wduration))
                        loop_sleep(wduration);
                rcu_gc_reclaim(wtidx, old);
-               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());
-       tot_nr_writes[wtidx] = nr_writes;
+       tot_nr_writes[wtidx] = URCU_TLS(nr_writes);
        return ((void*)2);
 }
 
This page took 0.024633 seconds and 4 git commands to generate.