From: Michael Jeanson Date: Tue, 13 Apr 2021 20:19:06 +0000 (-0400) Subject: fix: HAVE_SCHED_SETAFFINITY is not defined X-Git-Tag: v0.13.0~18 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2388c075d46055bd33ee824c399d72c219b98d90;p=urcu.git fix: HAVE_SCHED_SETAFFINITY is not defined Use '#ifdef' instead of '#if' to test if HAVE_SCHED_SETAFFINITY is defined. Both work but using '#if' on an undefined macro will generate a warning with '-Wundef'. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Change-Id: Ieb46ddab9ba033a5c552dbe78ac398cea0a641e8 --- diff --git a/src/urcu-call-rcu-impl.h b/src/urcu-call-rcu-impl.h index c49084f..59ab333 100644 --- a/src/urcu-call-rcu-impl.h +++ b/src/urcu-call-rcu-impl.h @@ -199,7 +199,7 @@ static void call_rcu_unlock(pthread_mutex_t *pmp) * Losing affinity can be caused by CPU hotunplug/hotplug, or by * cpuset(7). */ -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY static int set_thread_cpu_affinity(struct call_rcu_data *crdp) { diff --git a/src/workqueue.c b/src/workqueue.c index 1e045fb..7217001 100644 --- a/src/workqueue.c +++ b/src/workqueue.c @@ -92,7 +92,7 @@ struct urcu_workqueue_completion_work { * Losing affinity can be caused by CPU hotunplug/hotplug, or by * cpuset(7). */ -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY static int set_thread_cpu_affinity(struct urcu_workqueue *workqueue) { cpu_set_t mask; diff --git a/tests/benchmark/test_mutex.c b/tests/benchmark/test_mutex.c index e06b902..6c4e8c7 100644 --- a/tests/benchmark/test_mutex.c +++ b/tests/benchmark/test_mutex.c @@ -85,7 +85,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -93,7 +93,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_perthreadlock.c b/tests/benchmark/test_perthreadlock.c index 7a0b79a..76cdee9 100644 --- a/tests/benchmark/test_perthreadlock.c +++ b/tests/benchmark/test_perthreadlock.c @@ -89,7 +89,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -97,7 +97,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { errno = ret; diff --git a/tests/benchmark/test_rwlock.c b/tests/benchmark/test_rwlock.c index 7ba72e0..7ee73b4 100644 --- a/tests/benchmark/test_rwlock.c +++ b/tests/benchmark/test_rwlock.c @@ -89,7 +89,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -97,7 +97,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu.c b/tests/benchmark/test_urcu.c index 75e6161..2f41a82 100644 --- a/tests/benchmark/test_urcu.c +++ b/tests/benchmark/test_urcu.c @@ -80,7 +80,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -88,7 +88,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_assign.c b/tests/benchmark/test_urcu_assign.c index 7f04927..dcb5d1e 100644 --- a/tests/benchmark/test_urcu_assign.c +++ b/tests/benchmark/test_urcu_assign.c @@ -84,7 +84,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -92,7 +92,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_bp.c b/tests/benchmark/test_urcu_bp.c index 9fcfd24..1bf62bd 100644 --- a/tests/benchmark/test_urcu_bp.c +++ b/tests/benchmark/test_urcu_bp.c @@ -80,7 +80,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -88,7 +88,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_defer.c b/tests/benchmark/test_urcu_defer.c index 283edf4..3635f1a 100644 --- a/tests/benchmark/test_urcu_defer.c +++ b/tests/benchmark/test_urcu_defer.c @@ -85,7 +85,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -93,7 +93,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_gc.c b/tests/benchmark/test_urcu_gc.c index f0dff78..50c5b76 100644 --- a/tests/benchmark/test_urcu_gc.c +++ b/tests/benchmark/test_urcu_gc.c @@ -93,7 +93,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -101,7 +101,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_hash.c b/tests/benchmark/test_urcu_hash.c index 2313a88..8838bc0 100644 --- a/tests/benchmark/test_urcu_hash.c +++ b/tests/benchmark/test_urcu_hash.c @@ -140,7 +140,7 @@ static pthread_mutex_t rcu_copy_mutex = PTHREAD_MUTEX_INITIALIZER; void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -148,7 +148,7 @@ void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_lfq.c b/tests/benchmark/test_urcu_lfq.c index eb97b1a..708e29b 100644 --- a/tests/benchmark/test_urcu_lfq.c +++ b/tests/benchmark/test_urcu_lfq.c @@ -78,7 +78,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -86,7 +86,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_lfs.c b/tests/benchmark/test_urcu_lfs.c index a585041..1d1ae52 100644 --- a/tests/benchmark/test_urcu_lfs.c +++ b/tests/benchmark/test_urcu_lfs.c @@ -92,7 +92,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -100,7 +100,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_lfs_rcu.c b/tests/benchmark/test_urcu_lfs_rcu.c index 9d4c5ee..7b5c055 100644 --- a/tests/benchmark/test_urcu_lfs_rcu.c +++ b/tests/benchmark/test_urcu_lfs_rcu.c @@ -82,7 +82,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -90,7 +90,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_qsbr.c b/tests/benchmark/test_urcu_qsbr.c index f772baf..6a51744 100644 --- a/tests/benchmark/test_urcu_qsbr.c +++ b/tests/benchmark/test_urcu_qsbr.c @@ -80,7 +80,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -88,7 +88,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_qsbr_gc.c b/tests/benchmark/test_urcu_qsbr_gc.c index 8079a43..8eaf8d4 100644 --- a/tests/benchmark/test_urcu_qsbr_gc.c +++ b/tests/benchmark/test_urcu_qsbr_gc.c @@ -91,7 +91,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -99,7 +99,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_wfcq.c b/tests/benchmark/test_urcu_wfcq.c index 175f289..3cae9b7 100644 --- a/tests/benchmark/test_urcu_wfcq.c +++ b/tests/benchmark/test_urcu_wfcq.c @@ -90,7 +90,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -98,7 +98,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_wfq.c b/tests/benchmark/test_urcu_wfq.c index e8474b8..173a567 100644 --- a/tests/benchmark/test_urcu_wfq.c +++ b/tests/benchmark/test_urcu_wfq.c @@ -82,7 +82,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -90,7 +90,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/benchmark/test_urcu_wfs.c b/tests/benchmark/test_urcu_wfs.c index 544b074..64731b3 100644 --- a/tests/benchmark/test_urcu_wfs.c +++ b/tests/benchmark/test_urcu_wfs.c @@ -93,7 +93,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -101,7 +101,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); diff --git a/tests/common/api.h b/tests/common/api.h index 67c388e..cadbcb8 100644 --- a/tests/common/api.h +++ b/tests/common/api.h @@ -230,7 +230,7 @@ static void wait_all_threads(void) static void run_on(int cpu) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; CPU_ZERO(&mask);