X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_mutex.c;h=7fb036d1632361f780b6c6281e1704af5cb28605;hb=d8540fc53386cd7ff270085aca621e32772832ba;hp=e94819ac8b3cafe353addb4149ae6ca8587afb93;hpb=833dbdb633ba44bfb71b4b965a83096d8e4e827b;p=urcu.git diff --git a/tests/test_mutex.c b/tests/test_mutex.c index e94819a..7fb036d 100644 --- a/tests/test_mutex.c +++ b/tests/test_mutex.c @@ -21,6 +21,7 @@ */ #define _GNU_SOURCE +#include "../config.h" #include #include #include @@ -32,11 +33,9 @@ #include #include #include +#include -#include "../arch.h" - -/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ -#define CACHE_LINE_SIZE 4096 +#include /* hardcoded number of CPUs */ #define NR_CPUS 16384 @@ -61,7 +60,7 @@ static inline pid_t gettid(void) #else #define debug_yield_read() #endif -#include "../urcu.h" +#include struct test_array { int a; @@ -100,6 +99,12 @@ static int use_affinity = 0; pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; +#ifndef HAVE_CPU_SET_T +typedef unsigned long cpu_set_t; +# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0) +# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0) +#endif + static void set_affinity(void) { cpu_set_t mask; @@ -109,6 +114,7 @@ static void set_affinity(void) if (!use_affinity) return; +#if HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); @@ -122,7 +128,12 @@ static void set_affinity(void) } 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 */ } /*