diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-12 09:29:31 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-12 14:20:34 -0400 |
commit | c7007e983682b31d91e9ad7c3e85c49ffcc3651f (patch) | |
tree | b4ecc87ce9e43a34a2424159bd5e09e26fd2efb3 /tools/perf | |
parent | 4998a1224686d74ab7f7789787f7f7f904c75dfc (diff) |
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')
-rw-r--r-- | tools/perf/util/cloexec.c | 14 | ||||
-rw-r--r-- | tools/perf/util/util.h | 4 |
2 files changed, 14 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 @@ | |||
4 | #include "cloexec.h" | 4 | #include "cloexec.h" |
5 | #include "asm/bug.h" | 5 | #include "asm/bug.h" |
6 | #include "debug.h" | 6 | #include "debug.h" |
7 | #include <unistd.h> | ||
8 | #include <asm/unistd.h> | ||
9 | #include <sys/syscall.h> | ||
7 | 10 | ||
8 | static unsigned long flag = PERF_FLAG_FD_CLOEXEC; | 11 | static unsigned long flag = PERF_FLAG_FD_CLOEXEC; |
9 | 12 | ||
10 | #ifdef __GLIBC_PREREQ | ||
11 | #if !__GLIBC_PREREQ(2, 6) | ||
12 | int __weak sched_getcpu(void) | 13 | int __weak sched_getcpu(void) |
13 | { | 14 | { |
15 | #ifdef __NR_getcpu | ||
16 | unsigned cpu; | ||
17 | int err = syscall(__NR_getcpu, &cpu, NULL, NULL); | ||
18 | if (!err) | ||
19 | return cpu; | ||
20 | #else | ||
14 | errno = ENOSYS; | 21 | errno = ENOSYS; |
22 | #endif | ||
15 | return -1; | 23 | return -1; |
16 | } | 24 | } |
17 | #endif | ||
18 | #endif | ||
19 | 25 | ||
20 | static int perf_flag_probe(void) | 26 | static int perf_flag_probe(void) |
21 | { | 27 | { |
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 2370cfb902b2..d8d41ef8da57 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -361,4 +361,8 @@ void print_binary(unsigned char *data, size_t len, | |||
361 | size_t bytes_per_line, print_binary_t printer, | 361 | size_t bytes_per_line, print_binary_t printer, |
362 | void *extra); | 362 | void *extra); |
363 | 363 | ||
364 | #ifndef __GLIBC__ | ||
365 | extern int sched_getcpu(void); | ||
366 | #endif | ||
367 | |||
364 | #endif /* GIT_COMPAT_UTIL_H */ | 368 | #endif /* GIT_COMPAT_UTIL_H */ |