Build and run regression and unit tests as C++ programs
[urcu.git] / tests / common / api.h
index 14033596885bce51b77df4e5c958eb7434a6428e..a260463ad09ea212bb7ee4517a2fd995f21b2d74 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _INCLUDE_API_H
 #define _INCLUDE_API_H
 
-#define _GNU_SOURCE
-#include "config.h"
-
 /*
  * common.h: Common Linux kernel-isms.
  *
@@ -29,7 +26,6 @@
 
 #include <urcu/compiler.h>
 #include <urcu/arch.h>
-#include "cpuset.h"
 
 /*
  * Machine parameters.
@@ -111,7 +107,7 @@ static void spin_unlock(spinlock_t *sp)
 
 typedef pthread_t thread_id_t;
 
-#define NR_THREADS 128
+#define NR_THREADS 4096
 
 #define __THREAD_ID_MAP_EMPTY ((thread_id_t) 0)
 #define __THREAD_ID_MAP_WAITING ((thread_id_t) 1)
@@ -169,7 +165,7 @@ static int smp_thread_id(void)
        id = pthread_getspecific(thread_id_key);
        if (id == NULL)
                return __smp_thread_id();
-       return (long)(id - 1);
+       return ((long) id - 1);
 }
 
 static thread_id_t create_thread(void *(*func)(void *), void *arg)
@@ -232,25 +228,26 @@ static void wait_all_threads(void)
        }
 }
 
+#ifdef HAVE_SCHED_SETAFFINITY
 static void run_on(int cpu)
 {
-#if HAVE_SCHED_SETAFFINITY
        cpu_set_t mask;
 
        CPU_ZERO(&mask);
        CPU_SET(cpu, &mask);
-#if SCHED_SETAFFINITY_ARGS == 2
-       sched_setaffinity(0, &mask);
-#else
        sched_setaffinity(0, sizeof(mask), &mask);
-#endif
-#endif /* HAVE_SCHED_SETAFFINITY */
 }
+#else
+
+static void run_on(int cpu __attribute__((unused)))
+{}
+#endif /* HAVE_SCHED_SETAFFINITY */
 
 /*
  * timekeeping -- very crude -- should use MONOTONIC...
  */
 
+static inline
 long long get_microseconds(void)
 {
        struct timeval tv;
@@ -268,7 +265,7 @@ long long get_microseconds(void)
        struct { \
                __typeof__(type) v \
                        __attribute__((__aligned__(CAA_CACHE_LINE_SIZE))); \
-       } __per_thread_##name[NR_THREADS];
+       } __per_thread_##name[NR_THREADS]
 #define DECLARE_PER_THREAD(type, name) extern DEFINE_PER_THREAD(type, name)
 
 #define per_thread(name, thread) __per_thread_##name[thread].v
This page took 0.023269 seconds and 4 git commands to generate.