aboutsummaryrefslogtreecommitdiffstats
path: root/tools/build/feature
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build/feature')
-rw-r--r--tools/build/feature/.gitignore3
-rw-r--r--tools/build/feature/Makefile160
-rw-r--r--tools/build/feature/test-all.c143
-rw-r--r--tools/build/feature/test-backtrace.c13
-rw-r--r--tools/build/feature/test-bionic.c6
-rw-r--r--tools/build/feature/test-compile.c4
-rw-r--r--tools/build/feature/test-cplus-demangle.c14
-rw-r--r--tools/build/feature/test-dwarf.c10
-rw-r--r--tools/build/feature/test-fortify-source.c6
-rw-r--r--tools/build/feature/test-glibc.c8
-rw-r--r--tools/build/feature/test-gtk2-infobar.c11
-rw-r--r--tools/build/feature/test-gtk2.c10
-rw-r--r--tools/build/feature/test-hello.c6
-rw-r--r--tools/build/feature/test-libaudit.c10
-rw-r--r--tools/build/feature/test-libbabeltrace.c9
-rw-r--r--tools/build/feature/test-libbfd.c15
-rw-r--r--tools/build/feature/test-libdw-dwarf-unwind.c13
-rw-r--r--tools/build/feature/test-libelf-getphdrnum.c8
-rw-r--r--tools/build/feature/test-libelf-mmap.c8
-rw-r--r--tools/build/feature/test-libelf.c8
-rw-r--r--tools/build/feature/test-libnuma.c9
-rw-r--r--tools/build/feature/test-libperl.c9
-rw-r--r--tools/build/feature/test-libpython-version.c10
-rw-r--r--tools/build/feature/test-libpython.c8
-rw-r--r--tools/build/feature/test-libslang.c6
-rw-r--r--tools/build/feature/test-libunwind-debug-frame.c16
-rw-r--r--tools/build/feature/test-libunwind.c27
-rw-r--r--tools/build/feature/test-pthread-attr-setaffinity-np.c17
-rw-r--r--tools/build/feature/test-stackprotector-all.c6
-rw-r--r--tools/build/feature/test-sync-compare-and-swap.c14
-rw-r--r--tools/build/feature/test-timerfd.c18
-rw-r--r--tools/build/feature/test-zlib.c9
32 files changed, 614 insertions, 0 deletions
diff --git a/tools/build/feature/.gitignore b/tools/build/feature/.gitignore
new file mode 100644
index 000000000000..09b335b98842
--- /dev/null
+++ b/tools/build/feature/.gitignore
@@ -0,0 +1,3 @@
1*.d
2*.bin
3*.output
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
new file mode 100644
index 000000000000..0d694a94cda2
--- /dev/null
+++ b/tools/build/feature/Makefile
@@ -0,0 +1,160 @@
1
2FILES= \
3 test-all.bin \
4 test-backtrace.bin \
5 test-bionic.bin \
6 test-dwarf.bin \
7 test-fortify-source.bin \
8 test-sync-compare-and-swap.bin \
9 test-glibc.bin \
10 test-gtk2.bin \
11 test-gtk2-infobar.bin \
12 test-hello.bin \
13 test-libaudit.bin \
14 test-libbfd.bin \
15 test-liberty.bin \
16 test-liberty-z.bin \
17 test-cplus-demangle.bin \
18 test-libelf.bin \
19 test-libelf-getphdrnum.bin \
20 test-libelf-mmap.bin \
21 test-libnuma.bin \
22 test-libperl.bin \
23 test-libpython.bin \
24 test-libpython-version.bin \
25 test-libslang.bin \
26 test-libunwind.bin \
27 test-libunwind-debug-frame.bin \
28 test-pthread-attr-setaffinity-np.bin \
29 test-stackprotector-all.bin \
30 test-timerfd.bin \
31 test-libdw-dwarf-unwind.bin \
32 test-libbabeltrace.bin \
33 test-compile-32.bin \
34 test-compile-x32.bin \
35 test-zlib.bin
36
37CC := $(CROSS_COMPILE)gcc -MD
38PKG_CONFIG := $(CROSS_COMPILE)pkg-config
39
40all: $(FILES)
41
42__BUILD = $(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ $(patsubst %.bin,%.c,$@) $(LDFLAGS)
43 BUILD = $(__BUILD) > $(OUTPUT)$(@:.bin=.make.output) 2>&1
44
45###############################
46
47test-all.bin:
48 $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz
49
50test-hello.bin:
51 $(BUILD)
52
53test-pthread-attr-setaffinity-np.bin:
54 $(BUILD) -D_GNU_SOURCE -lpthread
55
56test-stackprotector-all.bin:
57 $(BUILD) -fstack-protector-all
58
59test-fortify-source.bin:
60 $(BUILD) -O2 -D_FORTIFY_SOURCE=2
61
62test-bionic.bin:
63 $(BUILD)
64
65test-libelf.bin:
66 $(BUILD) -lelf
67
68test-glibc.bin:
69 $(BUILD)
70
71test-dwarf.bin:
72 $(BUILD) -ldw
73
74test-libelf-mmap.bin:
75 $(BUILD) -lelf
76
77test-libelf-getphdrnum.bin:
78 $(BUILD) -lelf
79
80test-libnuma.bin:
81 $(BUILD) -lnuma
82
83test-libunwind.bin:
84 $(BUILD) -lelf
85
86test-libunwind-debug-frame.bin:
87 $(BUILD) -lelf
88
89test-libaudit.bin:
90 $(BUILD) -laudit
91
92test-libslang.bin:
93 $(BUILD) -I/usr/include/slang -lslang
94
95test-gtk2.bin:
96 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
97
98test-gtk2-infobar.bin:
99 $(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null)
100
101grep-libs = $(filter -l%,$(1))
102strip-libs = $(filter-out -l%,$(1))
103
104PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
105PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
106PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
107PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
108FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
109
110test-libperl.bin:
111 $(BUILD) $(FLAGS_PERL_EMBED)
112
113test-libpython.bin:
114 $(BUILD)
115
116test-libpython-version.bin:
117 $(BUILD)
118
119test-libbfd.bin:
120 $(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
121
122test-liberty.bin:
123 $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
124
125test-liberty-z.bin:
126 $(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
127
128test-cplus-demangle.bin:
129 $(BUILD) -liberty
130
131test-backtrace.bin:
132 $(BUILD)
133
134test-timerfd.bin:
135 $(BUILD)
136
137test-libdw-dwarf-unwind.bin:
138 $(BUILD) # -ldw provided by $(FEATURE_CHECK_LDFLAGS-libdw-dwarf-unwind)
139
140test-libbabeltrace.bin:
141 $(BUILD) # -lbabeltrace provided by $(FEATURE_CHECK_LDFLAGS-libbabeltrace)
142
143test-sync-compare-and-swap.bin:
144 $(BUILD)
145
146test-compile-32.bin:
147 $(CC) -m32 -o $(OUTPUT)$@ test-compile.c
148
149test-compile-x32.bin:
150 $(CC) -mx32 -o $(OUTPUT)$@ test-compile.c
151
152test-zlib.bin:
153 $(BUILD) -lz
154
155-include *.d
156
157###############################
158
159clean:
160 rm -f $(FILES) *.d $(FILES:.bin=.make.output)
diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c
new file mode 100644
index 000000000000..a61c20456705
--- /dev/null
+++ b/tools/build/feature/test-all.c
@@ -0,0 +1,143 @@
1/*
2 * test-all.c: Try to build all the main testcases at once.
3 *
4 * A well-configured system will have all the prereqs installed, so we can speed
5 * up auto-detection on such systems.
6 */
7
8/*
9 * Quirk: Python and Perl headers cannot be in arbitrary places, so keep
10 * these 3 testcases at the top:
11 */
12#define main main_test_libpython
13# include "test-libpython.c"
14#undef main
15
16#define main main_test_libpython_version
17# include "test-libpython-version.c"
18#undef main
19
20#define main main_test_libperl
21# include "test-libperl.c"
22#undef main
23
24#define main main_test_hello
25# include "test-hello.c"
26#undef main
27
28#define main main_test_libelf
29# include "test-libelf.c"
30#undef main
31
32#define main main_test_libelf_mmap
33# include "test-libelf-mmap.c"
34#undef main
35
36#define main main_test_glibc
37# include "test-glibc.c"
38#undef main
39
40#define main main_test_dwarf
41# include "test-dwarf.c"
42#undef main
43
44#define main main_test_libelf_getphdrnum
45# include "test-libelf-getphdrnum.c"
46#undef main
47
48#define main main_test_libunwind
49# include "test-libunwind.c"
50#undef main
51
52#define main main_test_libaudit
53# include "test-libaudit.c"
54#undef main
55
56#define main main_test_libslang
57# include "test-libslang.c"
58#undef main
59
60#define main main_test_gtk2
61# include "test-gtk2.c"
62#undef main
63
64#define main main_test_gtk2_infobar
65# include "test-gtk2-infobar.c"
66#undef main
67
68#define main main_test_libbfd
69# include "test-libbfd.c"
70#undef main
71
72#define main main_test_backtrace
73# include "test-backtrace.c"
74#undef main
75
76#define main main_test_libnuma
77# include "test-libnuma.c"
78#undef main
79
80#define main main_test_timerfd
81# include "test-timerfd.c"
82#undef main
83
84#define main main_test_stackprotector_all
85# include "test-stackprotector-all.c"
86#undef main
87
88#define main main_test_libdw_dwarf_unwind
89# include "test-libdw-dwarf-unwind.c"
90#undef main
91
92#define main main_test_sync_compare_and_swap
93# include "test-sync-compare-and-swap.c"
94#undef main
95
96#define main main_test_zlib
97# include "test-zlib.c"
98#undef main
99
100#define main main_test_pthread_attr_setaffinity_np
101# include "test-pthread-attr-setaffinity-np.c"
102#undef main
103
104# if 0
105/*
106 * Disable libbabeltrace check for test-all, because the requested
107 * library version is not released yet in most distributions. Will
108 * reenable later.
109 */
110
111#define main main_test_libbabeltrace
112# include "test-libbabeltrace.c"
113#undef main
114#endif
115
116int main(int argc, char *argv[])
117{
118 main_test_libpython();
119 main_test_libpython_version();
120 main_test_libperl();
121 main_test_hello();
122 main_test_libelf();
123 main_test_libelf_mmap();
124 main_test_glibc();
125 main_test_dwarf();
126 main_test_libelf_getphdrnum();
127 main_test_libunwind();
128 main_test_libaudit();
129 main_test_libslang();
130 main_test_gtk2(argc, argv);
131 main_test_gtk2_infobar(argc, argv);
132 main_test_libbfd();
133 main_test_backtrace();
134 main_test_libnuma();
135 main_test_timerfd();
136 main_test_stackprotector_all();
137 main_test_libdw_dwarf_unwind();
138 main_test_sync_compare_and_swap(argc, argv);
139 main_test_zlib();
140 main_test_pthread_attr_setaffinity_np();
141
142 return 0;
143}
diff --git a/tools/build/feature/test-backtrace.c b/tools/build/feature/test-backtrace.c
new file mode 100644
index 000000000000..7124aa1dc8fb
--- /dev/null
+++ b/tools/build/feature/test-backtrace.c
@@ -0,0 +1,13 @@
1#include <execinfo.h>
2#include <stdio.h>
3
4int main(void)
5{
6 void *backtrace_fns[10];
7 size_t entries;
8
9 entries = backtrace(backtrace_fns, 10);
10 backtrace_symbols_fd(backtrace_fns, entries, 1);
11
12 return 0;
13}
diff --git a/tools/build/feature/test-bionic.c b/tools/build/feature/test-bionic.c
new file mode 100644
index 000000000000..eac24e9513eb
--- /dev/null
+++ b/tools/build/feature/test-bionic.c
@@ -0,0 +1,6 @@
1#include <android/api-level.h>
2
3int main(void)
4{
5 return __ANDROID_API__;
6}
diff --git a/tools/build/feature/test-compile.c b/tools/build/feature/test-compile.c
new file mode 100644
index 000000000000..31dbf45bf99c
--- /dev/null
+++ b/tools/build/feature/test-compile.c
@@ -0,0 +1,4 @@
1int main(void)
2{
3 return 0;
4}
diff --git a/tools/build/feature/test-cplus-demangle.c b/tools/build/feature/test-cplus-demangle.c
new file mode 100644
index 000000000000..610c686e0009
--- /dev/null
+++ b/tools/build/feature/test-cplus-demangle.c
@@ -0,0 +1,14 @@
1extern int printf(const char *format, ...);
2extern char *cplus_demangle(const char *, int);
3
4int main(void)
5{
6 char symbol[4096] = "FieldName__9ClassNameFd";
7 char *tmp;
8
9 tmp = cplus_demangle(symbol, 0);
10
11 printf("demangled symbol: {%s}\n", tmp);
12
13 return 0;
14}
diff --git a/tools/build/feature/test-dwarf.c b/tools/build/feature/test-dwarf.c
new file mode 100644
index 000000000000..3fc1801ce4a9
--- /dev/null
+++ b/tools/build/feature/test-dwarf.c
@@ -0,0 +1,10 @@
1#include <dwarf.h>
2#include <elfutils/libdw.h>
3#include <elfutils/version.h>
4
5int main(void)
6{
7 Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
8
9 return (long)dbg;
10}
diff --git a/tools/build/feature/test-fortify-source.c b/tools/build/feature/test-fortify-source.c
new file mode 100644
index 000000000000..c9f398d87868
--- /dev/null
+++ b/tools/build/feature/test-fortify-source.c
@@ -0,0 +1,6 @@
1#include <stdio.h>
2
3int main(void)
4{
5 return puts("hi");
6}
diff --git a/tools/build/feature/test-glibc.c b/tools/build/feature/test-glibc.c
new file mode 100644
index 000000000000..b0820345cd98
--- /dev/null
+++ b/tools/build/feature/test-glibc.c
@@ -0,0 +1,8 @@
1#include <gnu/libc-version.h>
2
3int main(void)
4{
5 const char *version = gnu_get_libc_version();
6
7 return (long)version;
8}
diff --git a/tools/build/feature/test-gtk2-infobar.c b/tools/build/feature/test-gtk2-infobar.c
new file mode 100644
index 000000000000..397b4646d066
--- /dev/null
+++ b/tools/build/feature/test-gtk2-infobar.c
@@ -0,0 +1,11 @@
1#pragma GCC diagnostic ignored "-Wstrict-prototypes"
2#include <gtk/gtk.h>
3#pragma GCC diagnostic error "-Wstrict-prototypes"
4
5int main(int argc, char *argv[])
6{
7 gtk_init(&argc, &argv);
8 gtk_info_bar_new();
9
10 return 0;
11}
diff --git a/tools/build/feature/test-gtk2.c b/tools/build/feature/test-gtk2.c
new file mode 100644
index 000000000000..6bd80e509439
--- /dev/null
+++ b/tools/build/feature/test-gtk2.c
@@ -0,0 +1,10 @@
1#pragma GCC diagnostic ignored "-Wstrict-prototypes"
2#include <gtk/gtk.h>
3#pragma GCC diagnostic error "-Wstrict-prototypes"
4
5int main(int argc, char *argv[])
6{
7 gtk_init(&argc, &argv);
8
9 return 0;
10}
diff --git a/tools/build/feature/test-hello.c b/tools/build/feature/test-hello.c
new file mode 100644
index 000000000000..c9f398d87868
--- /dev/null
+++ b/tools/build/feature/test-hello.c
@@ -0,0 +1,6 @@
1#include <stdio.h>
2
3int main(void)
4{
5 return puts("hi");
6}
diff --git a/tools/build/feature/test-libaudit.c b/tools/build/feature/test-libaudit.c
new file mode 100644
index 000000000000..afc019f08641
--- /dev/null
+++ b/tools/build/feature/test-libaudit.c
@@ -0,0 +1,10 @@
1#include <libaudit.h>
2
3extern int printf(const char *format, ...);
4
5int main(void)
6{
7 printf("error message: %s\n", audit_errno_to_name(0));
8
9 return audit_open();
10}
diff --git a/tools/build/feature/test-libbabeltrace.c b/tools/build/feature/test-libbabeltrace.c
new file mode 100644
index 000000000000..9cf802a04885
--- /dev/null
+++ b/tools/build/feature/test-libbabeltrace.c
@@ -0,0 +1,9 @@
1
2#include <babeltrace/ctf-writer/writer.h>
3#include <babeltrace/ctf-ir/stream-class.h>
4
5int main(void)
6{
7 bt_ctf_stream_class_get_packet_context_type((void *) 0);
8 return 0;
9}
diff --git a/tools/build/feature/test-libbfd.c b/tools/build/feature/test-libbfd.c
new file mode 100644
index 000000000000..24059907e990
--- /dev/null
+++ b/tools/build/feature/test-libbfd.c
@@ -0,0 +1,15 @@
1#include <bfd.h>
2
3extern int printf(const char *format, ...);
4
5int main(void)
6{
7 char symbol[4096] = "FieldName__9ClassNameFd";
8 char *tmp;
9
10 tmp = bfd_demangle(0, symbol, 0);
11
12 printf("demangled symbol: {%s}\n", tmp);
13
14 return 0;
15}
diff --git a/tools/build/feature/test-libdw-dwarf-unwind.c b/tools/build/feature/test-libdw-dwarf-unwind.c
new file mode 100644
index 000000000000..f676a3ff442a
--- /dev/null
+++ b/tools/build/feature/test-libdw-dwarf-unwind.c
@@ -0,0 +1,13 @@
1
2#include <elfutils/libdwfl.h>
3
4int main(void)
5{
6 /*
7 * This function is guarded via: __nonnull_attribute__ (1, 2).
8 * Passing '1' as arguments value. This code is never executed,
9 * only compiled.
10 */
11 dwfl_thread_getframes((void *) 1, (void *) 1, NULL);
12 return 0;
13}
diff --git a/tools/build/feature/test-libelf-getphdrnum.c b/tools/build/feature/test-libelf-getphdrnum.c
new file mode 100644
index 000000000000..d710459306c3
--- /dev/null
+++ b/tools/build/feature/test-libelf-getphdrnum.c
@@ -0,0 +1,8 @@
1#include <libelf.h>
2
3int main(void)
4{
5 size_t dst;
6
7 return elf_getphdrnum(0, &dst);
8}
diff --git a/tools/build/feature/test-libelf-mmap.c b/tools/build/feature/test-libelf-mmap.c
new file mode 100644
index 000000000000..564427d7ef18
--- /dev/null
+++ b/tools/build/feature/test-libelf-mmap.c
@@ -0,0 +1,8 @@
1#include <libelf.h>
2
3int main(void)
4{
5 Elf *elf = elf_begin(0, ELF_C_READ_MMAP, 0);
6
7 return (long)elf;
8}
diff --git a/tools/build/feature/test-libelf.c b/tools/build/feature/test-libelf.c
new file mode 100644
index 000000000000..08db322d8957
--- /dev/null
+++ b/tools/build/feature/test-libelf.c
@@ -0,0 +1,8 @@
1#include <libelf.h>
2
3int main(void)
4{
5 Elf *elf = elf_begin(0, ELF_C_READ, 0);
6
7 return (long)elf;
8}
diff --git a/tools/build/feature/test-libnuma.c b/tools/build/feature/test-libnuma.c
new file mode 100644
index 000000000000..4763d9cd587d
--- /dev/null
+++ b/tools/build/feature/test-libnuma.c
@@ -0,0 +1,9 @@
1#include <numa.h>
2#include <numaif.h>
3
4int main(void)
5{
6 numa_available();
7
8 return 0;
9}
diff --git a/tools/build/feature/test-libperl.c b/tools/build/feature/test-libperl.c
new file mode 100644
index 000000000000..8871f6a0fdb4
--- /dev/null
+++ b/tools/build/feature/test-libperl.c
@@ -0,0 +1,9 @@
1#include <EXTERN.h>
2#include <perl.h>
3
4int main(void)
5{
6 perl_alloc();
7
8 return 0;
9}
diff --git a/tools/build/feature/test-libpython-version.c b/tools/build/feature/test-libpython-version.c
new file mode 100644
index 000000000000..facea122d812
--- /dev/null
+++ b/tools/build/feature/test-libpython-version.c
@@ -0,0 +1,10 @@
1#include <Python.h>
2
3#if PY_VERSION_HEX >= 0x03000000
4 #error
5#endif
6
7int main(void)
8{
9 return 0;
10}
diff --git a/tools/build/feature/test-libpython.c b/tools/build/feature/test-libpython.c
new file mode 100644
index 000000000000..b24b28ad6324
--- /dev/null
+++ b/tools/build/feature/test-libpython.c
@@ -0,0 +1,8 @@
1#include <Python.h>
2
3int main(void)
4{
5 Py_Initialize();
6
7 return 0;
8}
diff --git a/tools/build/feature/test-libslang.c b/tools/build/feature/test-libslang.c
new file mode 100644
index 000000000000..22ff22ed94d1
--- /dev/null
+++ b/tools/build/feature/test-libslang.c
@@ -0,0 +1,6 @@
1#include <slang.h>
2
3int main(void)
4{
5 return SLsmg_init_smg();
6}
diff --git a/tools/build/feature/test-libunwind-debug-frame.c b/tools/build/feature/test-libunwind-debug-frame.c
new file mode 100644
index 000000000000..0ef8087a104a
--- /dev/null
+++ b/tools/build/feature/test-libunwind-debug-frame.c
@@ -0,0 +1,16 @@
1#include <libunwind.h>
2#include <stdlib.h>
3
4extern int
5UNW_OBJ(dwarf_find_debug_frame) (int found, unw_dyn_info_t *di_debug,
6 unw_word_t ip, unw_word_t segbase,
7 const char *obj_name, unw_word_t start,
8 unw_word_t end);
9
10#define dwarf_find_debug_frame UNW_OBJ(dwarf_find_debug_frame)
11
12int main(void)
13{
14 dwarf_find_debug_frame(0, NULL, 0, 0, NULL, 0, 0);
15 return 0;
16}
diff --git a/tools/build/feature/test-libunwind.c b/tools/build/feature/test-libunwind.c
new file mode 100644
index 000000000000..43b9369bcab7
--- /dev/null
+++ b/tools/build/feature/test-libunwind.c
@@ -0,0 +1,27 @@
1#include <libunwind.h>
2#include <stdlib.h>
3
4extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
5 unw_word_t ip,
6 unw_dyn_info_t *di,
7 unw_proc_info_t *pi,
8 int need_unwind_info, void *arg);
9
10
11#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
12
13static unw_accessors_t accessors;
14
15int main(void)
16{
17 unw_addr_space_t addr_space;
18
19 addr_space = unw_create_addr_space(&accessors, 0);
20 if (addr_space)
21 return 0;
22
23 unw_init_remote(NULL, addr_space, NULL);
24 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
25
26 return 0;
27}
diff --git a/tools/build/feature/test-pthread-attr-setaffinity-np.c b/tools/build/feature/test-pthread-attr-setaffinity-np.c
new file mode 100644
index 000000000000..fdada5e8d454
--- /dev/null
+++ b/tools/build/feature/test-pthread-attr-setaffinity-np.c
@@ -0,0 +1,17 @@
1#include <stdint.h>
2#include <pthread.h>
3#include <sched.h>
4
5int main(void)
6{
7 int ret = 0;
8 pthread_attr_t thread_attr;
9 cpu_set_t cs;
10
11 pthread_attr_init(&thread_attr);
12 CPU_ZERO(&cs);
13
14 ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
15
16 return ret;
17}
diff --git a/tools/build/feature/test-stackprotector-all.c b/tools/build/feature/test-stackprotector-all.c
new file mode 100644
index 000000000000..c9f398d87868
--- /dev/null
+++ b/tools/build/feature/test-stackprotector-all.c
@@ -0,0 +1,6 @@
1#include <stdio.h>
2
3int main(void)
4{
5 return puts("hi");
6}
diff --git a/tools/build/feature/test-sync-compare-and-swap.c b/tools/build/feature/test-sync-compare-and-swap.c
new file mode 100644
index 000000000000..c34d4ca4af56
--- /dev/null
+++ b/tools/build/feature/test-sync-compare-and-swap.c
@@ -0,0 +1,14 @@
1#include <stdint.h>
2
3volatile uint64_t x;
4
5int main(int argc, char *argv[])
6{
7 uint64_t old, new = argc;
8
9 argv = argv;
10 do {
11 old = __sync_val_compare_and_swap(&x, 0, 0);
12 } while (!__sync_bool_compare_and_swap(&x, old, new));
13 return old == new;
14}
diff --git a/tools/build/feature/test-timerfd.c b/tools/build/feature/test-timerfd.c
new file mode 100644
index 000000000000..8c5c083b4d3c
--- /dev/null
+++ b/tools/build/feature/test-timerfd.c
@@ -0,0 +1,18 @@
1/*
2 * test for timerfd functions used by perf-kvm-stat-live
3 */
4#include <sys/timerfd.h>
5
6int main(void)
7{
8 struct itimerspec new_value;
9
10 int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
11 if (fd < 0)
12 return 1;
13
14 if (timerfd_settime(fd, 0, &new_value, NULL) != 0)
15 return 1;
16
17 return 0;
18}
diff --git a/tools/build/feature/test-zlib.c b/tools/build/feature/test-zlib.c
new file mode 100644
index 000000000000..e111fff6240e
--- /dev/null
+++ b/tools/build/feature/test-zlib.c
@@ -0,0 +1,9 @@
1#include <zlib.h>
2
3int main(void)
4{
5 z_stream zs;
6
7 inflateInit(&zs);
8 return 0;
9}