Re: [PATCH] perf tools: Work around lack of sched_getcpu in glibc < 2.6.
From: Peter Zijlstra
Date: Wed Mar 18 2015 - 05:15:55 EST
On Tue, Mar 17, 2015 at 04:49:13PM -0700, Vinson Lee wrote:
> On Mon, Feb 16, 2015 at 12:50 PM, Yann Droneaud <ydroneaud@xxxxxxxxxx> wrote:
> >> +#ifdef __GLIBC_PREREQ
> >> +#if __GLIBC_PREREQ(2, 6)
> >> +#define HAVE_SCHED_GETCPU
> >> +#endif
> >> +#endif
> >> @@ -21,9 +27,13 @@ static int perf_flag_probe(void)
> >> pid_t pid = -1;
> >> char sbuf[STRERR_BUFSIZE];
> >>
> >> +#ifdef HAVE_SCHED_GETCPU
> >> cpu = sched_getcpu();
> >> if (cpu < 0)
> >> cpu = 0;
> >> +#else
> >> + cpu = 0;
> >> +#endif
> >>
> >> while (1) {
> >> /* check cloexec flag */
Would it not be much nicer to implement a sched_getcpu() stub that
returns -1 and sets errno to -ENOSYS or something?
That avoids the magic #ifdef mushroom.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/