Temp save for Monty.
[awesomized/libmemcached] / m4 / pandora_have_gcc_atomics.m4
1 dnl Copyright (C) 2009 Sun Microsystems
2 dnl This file is free software; Sun Microsystems
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 #--------------------------------------------------------------------
7 # Check for GCC Atomic Support
8 #--------------------------------------------------------------------
9
10
11 AC_DEFUN([PANDORA_HAVE_GCC_ATOMICS],[
12
13 AC_CACHE_CHECK(
14 [whether the compiler provides atomic builtins],
15 [ac_cv_gcc_atomic_builtins],
16 [AC_RUN_IFELSE(
17 [AC_LANG_PROGRAM([],[[
18 int foo= -10; int bar= 10;
19 if (!__sync_fetch_and_add(&foo, bar) || foo)
20 return -1;
21 bar= __sync_lock_test_and_set(&foo, bar);
22 if (bar || foo != 10)
23 return -1;
24 bar= __sync_val_compare_and_swap(&bar, foo, 15);
25 if (bar)
26 return -1;
27 return 0;
28 ]])],
29 [ac_cv_gcc_atomic_builtins=yes],
30 [ac_cv_gcc_atomic_builtins=no])])
31
32 AS_IF([test "x$ac_cv_gcc_atomic_builtins" = "xyes"],[
33 AC_DEFINE(HAVE_GCC_ATOMIC_BUILTINS, 1,
34 [Define to 1 if compiler provides atomic builtins.])
35 ])
36
37 ])