Commit 120010cb authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo

tools build: Add test for sched_getcpu()

Instead of trying to go on adding more ifdef conditions, do a feature
test and define HAVE_SCHED_GETCPU_SUPPORT instead, then use it to
provide the prototype. No need to change the stub, as it is already a
__weak symbol.

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-yge89er9g90sc0v6k0a0r5tr@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e3ba76de
...@@ -63,6 +63,7 @@ FEATURE_TESTS_BASIC := \ ...@@ -63,6 +63,7 @@ FEATURE_TESTS_BASIC := \
lzma \ lzma \
get_cpuid \ get_cpuid \
bpf \ bpf \
sched_getcpu \
sdt sdt
# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
......
...@@ -48,7 +48,8 @@ FILES= \ ...@@ -48,7 +48,8 @@ FILES= \
test-get_cpuid.bin \ test-get_cpuid.bin \
test-sdt.bin \ test-sdt.bin \
test-cxx.bin \ test-cxx.bin \
test-jvmti.bin test-jvmti.bin \
test-sched_getcpu.bin
FILES := $(addprefix $(OUTPUT),$(FILES)) FILES := $(addprefix $(OUTPUT),$(FILES))
...@@ -91,6 +92,9 @@ $(OUTPUT)test-libelf.bin: ...@@ -91,6 +92,9 @@ $(OUTPUT)test-libelf.bin:
$(OUTPUT)test-glibc.bin: $(OUTPUT)test-glibc.bin:
$(BUILD) $(BUILD)
$(OUTPUT)test-sched_getcpu.bin:
$(BUILD)
DWARFLIBS := -ldw DWARFLIBS := -ldw
ifeq ($(findstring -static,${LDFLAGS}),-static) ifeq ($(findstring -static,${LDFLAGS}),-static)
DWARFLIBS += -lelf -lebl -lz -llzma -lbz2 DWARFLIBS += -lelf -lebl -lz -llzma -lbz2
......
...@@ -117,6 +117,10 @@ ...@@ -117,6 +117,10 @@
# include "test-pthread-attr-setaffinity-np.c" # include "test-pthread-attr-setaffinity-np.c"
#undef main #undef main
#define main main_test_sched_getcpu
# include "test-sched_getcpu.c"
#undef main
# if 0 # if 0
/* /*
* Disable libbabeltrace check for test-all, because the requested * Disable libbabeltrace check for test-all, because the requested
...@@ -182,6 +186,7 @@ int main(int argc, char *argv[]) ...@@ -182,6 +186,7 @@ int main(int argc, char *argv[])
main_test_get_cpuid(); main_test_get_cpuid();
main_test_bpf(); main_test_bpf();
main_test_libcrypto(); main_test_libcrypto();
main_test_sched_getcpu();
main_test_sdt(); main_test_sdt();
return 0; return 0;
......
#define _GNU_SOURCE
#include <sched.h>
int main(void)
{
return sched_getcpu();
}
...@@ -317,6 +317,10 @@ ifdef NO_DWARF ...@@ -317,6 +317,10 @@ ifdef NO_DWARF
NO_LIBDW_DWARF_UNWIND := 1 NO_LIBDW_DWARF_UNWIND := 1
endif endif
ifeq ($(feature-sched_getcpu), 1)
CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT
endif
ifndef NO_LIBELF ifndef NO_LIBELF
CFLAGS += -DHAVE_LIBELF_SUPPORT CFLAGS += -DHAVE_LIBELF_SUPPORT
EXTLIBS += -lelf EXTLIBS += -lelf
......
...@@ -3,10 +3,4 @@ ...@@ -3,10 +3,4 @@
unsigned long perf_event_open_cloexec_flag(void); unsigned long perf_event_open_cloexec_flag(void);
#ifdef __GLIBC_PREREQ
#if !__GLIBC_PREREQ(2, 6) && !defined(__UCLIBC__)
int sched_getcpu(void) __THROW;
#endif
#endif
#endif /* __PERF_CLOEXEC_H */ #endif /* __PERF_CLOEXEC_H */
...@@ -355,8 +355,8 @@ void print_binary(unsigned char *data, size_t len, ...@@ -355,8 +355,8 @@ void print_binary(unsigned char *data, size_t len,
size_t bytes_per_line, print_binary_t printer, size_t bytes_per_line, print_binary_t printer,
void *extra); void *extra);
#if !defined(__GLIBC__) && !defined(__ANDROID__) #ifndef HAVE_SCHED_GETCPU_SUPPORT
extern int sched_getcpu(void); int sched_getcpu(void);
#endif #endif
int is_printable_array(char *p, unsigned int len); int is_printable_array(char *p, unsigned int len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment