summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/cloexec.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-07-12 15:29:31 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-07-12 20:20:34 +0200
commitc7007e983682b31d91e9ad7c3e85c49ffcc3651f (patch)
treeb4ecc87ce9e43a34a2424159bd5e09e26fd2efb3 /tools/perf/util/cloexec.c
parenttools: Copy uapi/linux/hw_breakpoint.h from the kernel (diff)
downloadlinux-c7007e983682b31d91e9ad7c3e85c49ffcc3651f.tar.xz
linux-c7007e983682b31d91e9ad7c3e85c49ffcc3651f.zip
perf tools: Introduce weak alternative to sched_getcpu()
Which is just a wrapper for sys_getcpu and is not present in at least musl libc. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-kblef7svmhr0g93kkx78envg@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/cloexec.c')
-rw-r--r--tools/perf/util/cloexec.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index fde772db1d5c..f0dcd0ee0afa 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -4,18 +4,24 @@
#include "cloexec.h"
#include "asm/bug.h"
#include "debug.h"
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <sys/syscall.h>
static unsigned long flag = PERF_FLAG_FD_CLOEXEC;
-#ifdef __GLIBC_PREREQ
-#if !__GLIBC_PREREQ(2, 6)
int __weak sched_getcpu(void)
{
+#ifdef __NR_getcpu
+ unsigned cpu;
+ int err = syscall(__NR_getcpu, &cpu, NULL, NULL);
+ if (!err)
+ return cpu;
+#else
errno = ENOSYS;
+#endif
return -1;
}
-#endif
-#endif
static int perf_flag_probe(void)
{