Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Add a feature test for scandirat(), that is not implemented so far in musl and uclibc

We use it just when listing tracepoint events, and for root, so just
emit a warning about it to get users to ask the library maintainers to
implement it, as suggested in this systemd ticket:

https://github.com/systemd/casync/issues/129

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/lkml/ZCwv4z5Dh%2FdHUMG6@kernel.org/
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+27
+1
tools/build/Makefile.feature
··· 64 64 lzma \ 65 65 get_cpuid \ 66 66 bpf \ 67 + scandirat \ 67 68 sched_getcpu \ 68 69 sdt \ 69 70 setns \
+4
tools/build/feature/Makefile
··· 65 65 test-gettid.bin \ 66 66 test-jvmti.bin \ 67 67 test-jvmti-cmlr.bin \ 68 + test-scandirat.bin \ 68 69 test-sched_getcpu.bin \ 69 70 test-setns.bin \ 70 71 test-libopencsd.bin \ ··· 128 127 $(BUILD) 129 128 130 129 $(OUTPUT)test-glibc.bin: 130 + $(BUILD) 131 + 132 + $(OUTPUT)test-scandirat.bin: 131 133 $(BUILD) 132 134 133 135 $(OUTPUT)test-sched_getcpu.bin:
+5
tools/build/feature/test-all.c
··· 114 114 # include "test-pthread-barrier.c" 115 115 #undef main 116 116 117 + #define main main_test_scandirat 118 + # include "test-scandirat.c" 119 + #undef main 120 + 117 121 #define main main_test_sched_getcpu 118 122 # include "test-sched_getcpu.c" 119 123 #undef main ··· 210 206 main_test_get_cpuid(); 211 207 main_test_bpf(); 212 208 main_test_libcrypto(); 209 + main_test_scandirat(); 213 210 main_test_sched_getcpu(); 214 211 main_test_sdt(); 215 212 main_test_setns();
+13
tools/build/feature/test-scandirat.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #ifndef _GNU_SOURCE 3 + #define _GNU_SOURCE 4 + #endif 5 + #include <dirent.h> 6 + 7 + int main(void) 8 + { 9 + // expects non-NULL, arg3 is 'restrict' so "pointers" have to be different 10 + return scandirat(/*dirfd=*/ 0, /*dirp=*/ (void *)1, /*namelist=*/ (void *)2, /*filter=*/ (void *)3, /*compar=*/ (void *)4); 11 + } 12 + 13 + #undef _GNU_SOURCE
+4
tools/perf/Makefile.config
··· 479 479 NO_LIBDW_DWARF_UNWIND := 1 480 480 endif 481 481 482 + ifeq ($(feature-scandirat), 1) 483 + CFLAGS += -DHAVE_SCANDIRAT_SUPPORT 484 + endif 485 + 482 486 ifeq ($(feature-sched_getcpu), 1) 483 487 CFLAGS += -DHAVE_SCHED_GETCPU_SUPPORT 484 488 endif