From: Mathieu Desnoyers Date: Fri, 22 Feb 2013 14:05:32 +0000 (-0500) Subject: Fix tests: finer-grained use of CPU_SET, CPU_ZERO and cpu_set_t X-Git-Tag: v0.8.0~104 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2953b501ab1dcf908d07de9b414a08397519f5b6;p=urcu.git Fix tests: finer-grained use of CPU_SET, CPU_ZERO and cpu_set_t Noticed build failure at https://buildd.debian.org/status/package.php?p=liburcu : Tail of log for liburcu on hurd-i386: test_urcu.c:110:0: warning: "CPU_SET" redefined [enabled by default] In file included from /usr/include/pthread/pthread.h:50:0, from /usr/include/pthread.h:2, from test_urcu.c:26: /usr/include/sched.h:80:0: note: this is the location of the previous definition make[3]: *** [test_urcu.o] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all] Error 2 dh_auto_build: make -j1 returned exit code 2 make: *** [build-arch] Error 2 dpkg-buildpackage: error: debian/rules build-arch gave error exit status 2 make[3]: Entering directory `/build/buildd-liburcu_0.7.6-1-hurd-i386-wGBAtt/liburcu-0.7.6/tests' CC test_urcu.o make[3]: Leaving directory `/build/buildd-liburcu_0.7.6-1-hurd-i386-wGBAtt/liburcu-0.7.6/tests' make[2]: Leaving directory `/build/buildd-liburcu_0.7.6-1-hurd-i386-wGBAtt/liburcu-0.7.6' Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 0e15a4c..bbaa18f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,7 +22,7 @@ noinst_PROGRAMS = test_urcu test_urcu_dynamic_link test_urcu_timing \ test_urcu_lfs_rcu_dynlink \ test_urcu_multiflavor test_urcu_multiflavor_dynlink \ test_urcu_fork -noinst_HEADERS = rcutorture.h test_urcu_multiflavor.h +noinst_HEADERS = rcutorture.h test_urcu_multiflavor.h cpuset.h if COMPAT_ARCH COMPAT=$(top_srcdir)/compat_arch_@ARCHTYPE@.c diff --git a/tests/cpuset.h b/tests/cpuset.h new file mode 100644 index 0000000..3f1587d --- /dev/null +++ b/tests/cpuset.h @@ -0,0 +1,45 @@ +#ifndef _URCU_TESTS_CPUSET_H +#define _URCU_TESTS_CPUSET_H + +/* + * cpuset.h + * + * Userspace RCU library - test cpuset header + * + * Copyright 2009-2013 - Mathieu Desnoyers + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "../config.h" + +#if defined(HAVE_SCHED_SETAFFINITY) || defined(HAVE_CPU_SET_T) \ + || defined(HAVE_CPU_ZERO) || defined(HAVE_CPU_SET) +# include +#endif + +#ifndef HAVE_CPU_SET_T +typedef unsigned long cpu_set_t; +#endif + +#ifndef HAVE_CPU_ZERO +# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0) +#endif + +#ifndef HAVE_CPU_SET +# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0) +#endif + +#endif /* _URCU_TESTS_CPUSET_H */ diff --git a/tests/test_mutex.c b/tests/test_mutex.c index 451ab1c..1230934 100644 --- a/tests/test_mutex.c +++ b/tests/test_mutex.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -106,12 +106,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_perthreadlock.c b/tests/test_perthreadlock.c index cfde1b6..2a8b0c3 100644 --- a/tests/test_perthreadlock.c +++ b/tests/test_perthreadlock.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -110,12 +110,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_rwlock.c b/tests/test_rwlock.c index b787364..ae1eaf4 100644 --- a/tests/test_rwlock.c +++ b/tests/test_rwlock.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -106,12 +106,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu.c b/tests/test_urcu.c index 87972aa..3c5c492 100644 --- a/tests/test_urcu.c +++ b/tests/test_urcu.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -100,12 +100,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_assign.c b/tests/test_urcu_assign.c index 489a4c2..fa4afbf 100644 --- a/tests/test_urcu_assign.c +++ b/tests/test_urcu_assign.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -104,12 +104,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_bp.c b/tests/test_urcu_bp.c index 58afe90..8cb74ff 100644 --- a/tests/test_urcu_bp.c +++ b/tests/test_urcu_bp.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -100,12 +100,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index c799437..9fea8c1 100644 --- a/tests/test_urcu_defer.c +++ b/tests/test_urcu_defer.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -105,12 +105,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_gc.c b/tests/test_urcu_gc.c index ca8c45b..c452afb 100644 --- a/tests/test_urcu_gc.c +++ b/tests/test_urcu_gc.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -113,12 +113,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_hash.h b/tests/test_urcu_hash.h index 4af34f7..50e720a 100644 --- a/tests/test_urcu_hash.h +++ b/tests/test_urcu_hash.h @@ -33,11 +33,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -195,12 +195,6 @@ extern int use_affinity; extern pthread_mutex_t affinity_mutex; -#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 - void set_affinity(void); /* diff --git a/tests/test_urcu_lfq.c b/tests/test_urcu_lfq.c index 2291f4f..9d6535c 100644 --- a/tests/test_urcu_lfq.c +++ b/tests/test_urcu_lfq.c @@ -34,11 +34,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -97,12 +97,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_lfs.c b/tests/test_urcu_lfs.c index 28e3e06..45ed062 100644 --- a/tests/test_urcu_lfs.c +++ b/tests/test_urcu_lfs.c @@ -34,11 +34,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -109,12 +109,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_lfs_rcu.c b/tests/test_urcu_lfs_rcu.c index b5d1794..b6d830c 100644 --- a/tests/test_urcu_lfs_rcu.c +++ b/tests/test_urcu_lfs_rcu.c @@ -34,11 +34,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -101,12 +101,6 @@ 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; diff --git a/tests/test_urcu_qsbr.c b/tests/test_urcu_qsbr.c index d5d893c..065557a 100644 --- a/tests/test_urcu_qsbr.c +++ b/tests/test_urcu_qsbr.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -100,12 +100,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_qsbr_gc.c b/tests/test_urcu_qsbr_gc.c index 54797dc..ed7d596 100644 --- a/tests/test_urcu_qsbr_gc.c +++ b/tests/test_urcu_qsbr_gc.c @@ -31,11 +31,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -109,12 +109,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_wfcq.c b/tests/test_urcu_wfcq.c index 91285a5..124968d 100644 --- a/tests/test_urcu_wfcq.c +++ b/tests/test_urcu_wfcq.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -109,12 +109,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_wfq.c b/tests/test_urcu_wfq.c index b4138ea..f26708b 100644 --- a/tests/test_urcu_wfq.c +++ b/tests/test_urcu_wfq.c @@ -34,11 +34,11 @@ #include #include #include -#include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -101,12 +101,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY diff --git a/tests/test_urcu_wfs.c b/tests/test_urcu_wfs.c index 259ca24..90b2c38 100644 --- a/tests/test_urcu_wfs.c +++ b/tests/test_urcu_wfs.c @@ -34,12 +34,12 @@ #include #include #include -#include #include #include #include #include +#include "cpuset.h" #ifdef __linux__ #include @@ -112,12 +112,6 @@ 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) { #if HAVE_SCHED_SETAFFINITY