X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_urcu_bp.c;h=5ba6e49ddf24ae007328c9ca9f08e1bcfcd7155f;hb=9d7e3f89772f08cca26d727f47d44ecd47c94401;hp=fca7ac5d75f7ea4167928b3b22d9fa72c71abda3;hpb=d2835e6f55477acf4833d6a9774f672288a99075;p=urcu.git diff --git a/tests/test_urcu_bp.c b/tests/test_urcu_bp.c index fca7ac5..5ba6e49 100644 --- a/tests/test_urcu_bp.c +++ b/tests/test_urcu_bp.c @@ -21,6 +21,7 @@ */ #define _GNU_SOURCE +#include "../config.h" #include #include #include @@ -32,6 +33,7 @@ #include #include #include +#include #include @@ -95,6 +97,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; @@ -104,6 +112,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"); @@ -115,9 +124,15 @@ static void set_affinity(void) perror("Error in pthread mutex unlock"); exit(-1); } + 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 */ } /*