From: Mathieu Desnoyers Date: Fri, 22 Feb 2013 13:35:37 +0000 (-0500) Subject: Fix build on architectures with HAVE_SCHED_GETCPU but without HAVE_SYSCONF X-Git-Tag: v0.8.0~106 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=63b495d8b20ff76ba08d823df2e9702acc936beb;p=userspace-rcu.git Fix build on architectures with HAVE_SCHED_GETCPU but without HAVE_SYSCONF Noticed on: https://buildd.debian.org/status/package.php?p=liburcu Tail of log for liburcu on kfreebsd-amd64: CC urcu.lo In file included from urcu.c:450:0: urcu-call-rcu-impl.h:145:12: error: static declaration of 'sched_getcpu' follows non-static declaration In file included from /usr/include/sched.h:43:0, from /usr/include/pthread.h:20, from urcu.c:30: /usr/include/x86_64-kfreebsd-gnu/bits/sched.h:65:12: note: previous declaration of 'sched_getcpu' was here make[3]: *** [urcu.lo] Error 1 make[3]: Leaving directory `/build/buildd-liburcu_0.7.6-1-kfreebsd-amd64-nnkICd/liburcu-0.7.6' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/build/buildd-liburcu_0.7.6-1-kfreebsd-amd64-nnkICd/liburcu-0.7.6' make[1]: *** [all] Error 2 make[1]: Leaving directory `/build/buildd-liburcu_0.7.6-1-kfreebsd-amd64-nnkICd/liburcu-0.7.6' dh_auto_build: make -j1 returned exit code 2 make: *** [build-arch] Error 2 Tail of log for liburcu on kfreebsd-i386: CC urcu.lo In file included from urcu.c:450:0: urcu-call-rcu-impl.h:145:12: error: static declaration of 'sched_getcpu' follows non-static declaration In file included from /usr/include/sched.h:43:0, from /usr/include/pthread.h:20, from urcu.c:30: /usr/include/i386-kfreebsd-gnu/bits/sched.h:65:12: note: previous declaration of 'sched_getcpu' was here make[3]: *** [urcu.lo] Error 1 make[3]: Leaving directory `/build/buildd-liburcu_0.7.6-1-kfreebsd-i386-sWzNKU/liburcu-0.7.6' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/build/buildd-liburcu_0.7.6-1-kfreebsd-i386-sWzNKU/liburcu-0.7.6' make[1]: *** [all] Error 2 make[1]: Leaving directory `/build/buildd-liburcu_0.7.6-1-kfreebsd-i386-sWzNKU/liburcu-0.7.6' dh_auto_build: make -j1 returned exit code 2 make: *** [build-arch] Error 2 Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-call-rcu-impl.h b/urcu-call-rcu-impl.h index f6625ba..f7f0f71 100644 --- a/urcu-call-rcu-impl.h +++ b/urcu-call-rcu-impl.h @@ -90,7 +90,23 @@ static struct call_rcu_data *default_call_rcu_data; * CPUs rather than only to specific threads. */ -#if defined(HAVE_SCHED_GETCPU) && defined(HAVE_SYSCONF) +#ifdef HAVE_SCHED_GETCPU + +static int urcu_sched_getcpu(void) +{ + return sched_getcpu(); +} + +#else /* #ifdef HAVE_SCHED_GETCPU */ + +static int urcu_sched_getcpu(void) +{ + return -1; +} + +#endif /* #else #ifdef HAVE_SCHED_GETCPU */ + +#if defined(HAVE_SYSCONF) && defined(HAVE_SCHED_GETCPU) /* * Pointer to array of pointers to per-CPU call_rcu_data structures @@ -133,7 +149,7 @@ static void alloc_cpu_call_rcu_data(void) } } -#else /* #if defined(HAVE_SCHED_GETCPU) && defined(HAVE_SYSCONF) */ +#else /* #if defined(HAVE_SYSCONF) && defined(HAVE_SCHED_GETCPU) */ /* * per_cpu_call_rcu_data should be constant, but some functions below, used both @@ -151,12 +167,7 @@ static void alloc_cpu_call_rcu_data(void) { } -static int sched_getcpu(void) -{ - return -1; -} - -#endif /* #else #if defined(HAVE_SCHED_GETCPU) && defined(HAVE_SYSCONF) */ +#endif /* #else #if defined(HAVE_SYSCONF) && defined(HAVE_SCHED_GETCPU) */ /* Acquire the specified pthread mutex. */ @@ -357,7 +368,7 @@ static void call_rcu_data_init(struct call_rcu_data **crdpp, * Return a pointer to the call_rcu_data structure for the specified * CPU, returning NULL if there is none. We cannot automatically * created it because the platform we are running on might not define - * sched_getcpu(). + * urcu_sched_getcpu(). * * The call to this function and use of the returned call_rcu_data * should be protected by RCU read-side lock. @@ -499,7 +510,7 @@ struct call_rcu_data *get_call_rcu_data(void) return URCU_TLS(thread_call_rcu_data); if (maxcpus > 0) { - crd = get_cpu_call_rcu_data(sched_getcpu()); + crd = get_cpu_call_rcu_data(urcu_sched_getcpu()); if (crd) return crd; }