summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>2011-03-24 20:27:54 +0000
committerbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>2011-03-24 20:27:54 +0000
commite87404275d93e4234cbeba0eeda68426cf57833f (patch)
treee2aafd9a840faf265f852191defe1f52caa6cee8 /configure.in
parent5c6b7dcbe212c4b618abe068a5af8a06bd30fb38 (diff)
Test separately whether g++ and/or gcc support built-in functions for atomic
memory access. Apparently for some distributions gcc 4.2 has that support but g++ 4.2 doesn't. This patch has been supplied by Florian Krohm. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11665 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in29
1 files changed, 28 insertions, 1 deletions
diff --git a/configure.in b/configure.in
index 2c9c472d..88996208 100644
--- a/configure.in
+++ b/configure.in
@@ -1848,7 +1848,7 @@ AC_TRY_LINK(,
[
ac_have_builtin_atomic=yes
AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() a.o.])
+ AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
],
[
ac_have_builtin_atomic=no
@@ -1859,6 +1859,33 @@ CFLAGS=$safe_CFLAGS
AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC], [test x$ac_have_builtin_atomic = xyes])
+# does g++ have built-in functions for atomic memory access ?
+AC_MSG_CHECKING([if g++ supports __sync_bool_compare_and_swap])
+
+safe_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$mflag_primary"
+
+AC_LANG_PUSH(C++)
+AC_TRY_LINK(,
+[
+ int variable = 1;
+ return (__sync_bool_compare_and_swap(&variable, 1, 2)
+ && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
+],
+[
+ ac_have_builtin_atomic_cxx=yes
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
+],
+[
+ ac_have_builtin_atomic_cxx=no
+ AC_MSG_RESULT([no])
+])
+AC_LANG_POP(C++)
+
+CXXFLAGS=$safe_CXXFLAGS
+
+AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
#----------------------------------------------------------------------------
# Ok. We're done checking.