aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2014-07-14 06:02:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-07-16 16:57:36 -0400
commitf6d313699a9612a30fabe05bf2c9302c1408b5cf (patch)
tree4889e88c61aa7c9bf3ad682503b26ddff57b9ffa /tools/perf
parenta8a8f3eb5de55aeaf007c18572668e8ec463547b (diff)
perf tools: Add feature test for __sync_val_compare_and_swap
Add a feature test for __sync_val_compare_and_swap() and __sync_bool_compare_and_swap() Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1405332185-4050-30-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/config/Makefile6
-rw-r--r--tools/perf/config/feature-checks/Makefile4
-rw-r--r--tools/perf/config/feature-checks/test-all.c5
-rw-r--r--tools/perf/config/feature-checks/test-sync-compare-and-swap.c14
4 files changed, 29 insertions, 0 deletions
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index b7f42d577c4e..1f67aa02d240 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -164,6 +164,7 @@ CORE_FEATURE_TESTS = \
164 backtrace \ 164 backtrace \
165 dwarf \ 165 dwarf \
166 fortify-source \ 166 fortify-source \
167 sync-compare-and-swap \
167 glibc \ 168 glibc \
168 gtk2 \ 169 gtk2 \
169 gtk2-infobar \ 170 gtk2-infobar \
@@ -199,6 +200,7 @@ LIB_FEATURE_TESTS = \
199VF_FEATURE_TESTS = \ 200VF_FEATURE_TESTS = \
200 backtrace \ 201 backtrace \
201 fortify-source \ 202 fortify-source \
203 sync-compare-and-swap \
202 gtk2-infobar \ 204 gtk2-infobar \
203 libelf-getphdrnum \ 205 libelf-getphdrnum \
204 libelf-mmap \ 206 libelf-mmap \
@@ -272,6 +274,10 @@ CFLAGS += -I$(LIB_INCLUDE)
272 274
273CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 275CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
274 276
277ifeq ($(feature-sync-compare-and-swap), 1)
278 CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
279endif
280
275ifndef NO_BIONIC 281ifndef NO_BIONIC
276 $(call feature_check,bionic) 282 $(call feature_check,bionic)
277 ifeq ($(feature-bionic), 1) 283 ifeq ($(feature-bionic), 1)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 64c84e5f0514..6088f8d8a434 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -5,6 +5,7 @@ FILES= \
5 test-bionic.bin \ 5 test-bionic.bin \
6 test-dwarf.bin \ 6 test-dwarf.bin \
7 test-fortify-source.bin \ 7 test-fortify-source.bin \
8 test-sync-compare-and-swap.bin \
8 test-glibc.bin \ 9 test-glibc.bin \
9 test-gtk2.bin \ 10 test-gtk2.bin \
10 test-gtk2-infobar.bin \ 11 test-gtk2-infobar.bin \
@@ -141,6 +142,9 @@ test-timerfd.bin:
141test-libdw-dwarf-unwind.bin: 142test-libdw-dwarf-unwind.bin:
142 $(BUILD) 143 $(BUILD)
143 144
145test-sync-compare-and-swap.bin:
146 $(BUILD) -Werror
147
144-include *.d 148-include *.d
145 149
146############################### 150###############################
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
index fe5c1e5c952f..a7d022e161c0 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -89,6 +89,10 @@
89# include "test-libdw-dwarf-unwind.c" 89# include "test-libdw-dwarf-unwind.c"
90#undef main 90#undef main
91 91
92#define main main_test_sync_compare_and_swap
93# include "test-sync-compare-and-swap.c"
94#undef main
95
92int main(int argc, char *argv[]) 96int main(int argc, char *argv[])
93{ 97{
94 main_test_libpython(); 98 main_test_libpython();
@@ -111,6 +115,7 @@ int main(int argc, char *argv[])
111 main_test_timerfd(); 115 main_test_timerfd();
112 main_test_stackprotector_all(); 116 main_test_stackprotector_all();
113 main_test_libdw_dwarf_unwind(); 117 main_test_libdw_dwarf_unwind();
118 main_test_sync_compare_and_swap(argc, argv);
114 119
115 return 0; 120 return 0;
116} 121}
diff --git a/tools/perf/config/feature-checks/test-sync-compare-and-swap.c b/tools/perf/config/feature-checks/test-sync-compare-and-swap.c
new file mode 100644
index 000000000000..c34d4ca4af56
--- /dev/null
+++ b/tools/perf/config/feature-checks/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}