Skip to content

Commit f6d3136

Browse files
ahunter6acmel
authored andcommitted
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>
1 parent a8a8f3e commit f6d3136

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎tools/perf/config/Makefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ CORE_FEATURE_TESTS = \
164164
backtrace \
165165
dwarf \
166166
fortify-source \
167+
sync-compare-and-swap \
167168
glibc \
168169
gtk2 \
169170
gtk2-infobar \
@@ -199,6 +200,7 @@ LIB_FEATURE_TESTS = \
199200
VF_FEATURE_TESTS = \
200201
backtrace \
201202
fortify-source \
203+
sync-compare-and-swap \
202204
gtk2-infobar \
203205
libelf-getphdrnum \
204206
libelf-mmap \
@@ -272,6 +274,10 @@ CFLAGS += -I$(LIB_INCLUDE)
272274

273275
CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
274276

277+
ifeq ($(feature-sync-compare-and-swap), 1)
278+
CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
279+
endif
280+
275281
ifndef NO_BIONIC
276282
$(call feature_check,bionic)
277283
ifeq ($(feature-bionic), 1)

‎tools/perf/config/feature-checks/Makefile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ FILES= \
55
test-bionic.bin \
66
test-dwarf.bin \
77
test-fortify-source.bin \
8+
test-sync-compare-and-swap.bin \
89
test-glibc.bin \
910
test-gtk2.bin \
1011
test-gtk2-infobar.bin \
@@ -141,6 +142,9 @@ test-timerfd.bin:
141142
test-libdw-dwarf-unwind.bin:
142143
$(BUILD)
143144

145+
test-sync-compare-and-swap.bin:
146+
$(BUILD) -Werror
147+
144148
-include *.d
145149

146150
###############################

‎tools/perf/config/feature-checks/test-all.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@
8989
# include "test-libdw-dwarf-unwind.c"
9090
#undef main
9191

92+
#define main main_test_sync_compare_and_swap
93+
# include "test-sync-compare-and-swap.c"
94+
#undef main
95+
9296
int main(int argc, char *argv[])
9397
{
9498
main_test_libpython();
@@ -111,6 +115,7 @@ int main(int argc, char *argv[])
111115
main_test_timerfd();
112116
main_test_stackprotector_all();
113117
main_test_libdw_dwarf_unwind();
118+
main_test_sync_compare_and_swap(argc, argv);
114119

115120
return 0;
116121
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdint.h>
2+
3+
volatile uint64_t x;
4+
5+
int 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+
}

0 commit comments

Comments
 (0)