Merge lp:~tangent-org/libmemcached/1.0-build/ Build: jenkins-Libmemcached-187
[m6w6/libmemcached] / m4 / ax_gcc_atomic_builtins.m4
1 # serial 1
2 #
3 AC_DEFUN([HAVE_GCC_ATOMICS],
4 [AC_CACHE_CHECK([whether the compiler provides atomic builtins],
5 [ax_cv_gcc_atomic_builtins],
6 [AX_SAVE_FLAGS
7 AC_LANG_PUSH([C])
8 AC_RUN_IFELSE([AC_LANG_PROGRAM([],
9 [[
10 int foo= -10; int bar= 10;
11 if (!__sync_fetch_and_add(&foo, bar) || foo)
12 {
13 return -1;
14 }
15 bar= __sync_lock_test_and_set(&foo, bar);
16 if (bar || foo != 10)
17 {
18 return -1;
19 }
20 bar= __sync_val_compare_and_swap(&bar, foo, 15);
21 if (bar)
22 {
23 return -1;
24 }
25 ]])],
26 [ax_cv_gcc_atomic_builtins=yes],
27 [ax_cv_gcc_atomic_builtins=no],
28 [AC_MSG_WARN([test program execution failed])])
29 AC_LANG_POP
30 AX_RESTORE_FLAGS
31 ])
32
33 AS_IF([test "x$ax_cv_gcc_atomic_builtins" = "xyes"],
34 [AC_DEFINE([HAVE_GCC_ATOMIC_BUILTINS],[1],
35 [Define to 1 if compiler provides atomic builtins.])
36 ])
37 ])