Add a configure test for detecting whether gcc supports atomic operations on
authorbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sat, 17 Dec 2011 12:53:23 +0000 (12:53 +0000)
committerbart <bart@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sat, 17 Dec 2011 12:53:23 +0000 (12:53 +0000)
64-bit integers on 32-bit platforms. Apparently newer gcc versions support
this but older versions not. Thanks to Philippe Waroquiers for reporting this.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12309 a5019735-40e9-0310-863c-91ae7b9d1cf9

configure.in
drd/tests/Makefile.am

index d70344fa8a3b625fa26f268ae85d9781e6de2f45..39097c11164ebe51c70e3debbd4c369bad47b7b6 100644 (file)
@@ -1911,6 +1911,55 @@ fi
 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
                [test x$ac_have_builtin_atomic_secondary = xyes])
 
+# does this compiler have built-in functions for atomic memory access on
+# 64-bit integers for all targets ?
+
+AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
+
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+  #include <stdint.h>
+]], [[
+  uint64_t variable = 1;
+  return __sync_add_and_fetch(&variable, 1)
+]])], [
+  ac_have_builtin_atomic64_primary=yes
+], [
+  ac_have_builtin_atomic64_primary=no
+])
+
+if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="$mflag_secondary"
+
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+  #include <stdint.h>
+]], [[
+  uint64_t variable = 1;
+  return __sync_add_and_fetch(&variable, 1)
+]])], [
+  ac_have_builtin_atomic64_secondary=yes
+], [
+  ac_have_builtin_atomic64_secondary=no
+])
+
+CFLAGS=$safe_CFLAGS
+
+fi
+
+if test x$ac_have_builtin_atomic64_primary = xyes && \
+   test x$VGCONF_PLATFORM_SEC_CAPS = x \
+     -o x$ac_have_builtin_atomic64_secondary = xyes; then
+  AC_MSG_RESULT([yes])
+  ac_have_builtin_atomic64=yes
+else
+  AC_MSG_RESULT([no])
+  ac_have_builtin_atomic64=no
+fi
+
+AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
+               [test x$ac_have_builtin_atomic64 = xyes])
+
 
 # does g++ have built-in functions for atomic memory access ?
 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
index 6411b118da1c081d0ec02d8e3d3ab7920864f923..fe8a6e0796a1016381d36e2bb1d64aee49277639 100644 (file)
@@ -339,11 +339,15 @@ if HAVE_BUILTIN_ATOMIC
 check_PROGRAMS +=        \
   annotate_barrier       \
   annotate_rwlock        \
-  annotate_trace_memory  \
   atomic_var             \
   circular_buffer
 endif
 
+if HAVE_BUILTIN_ATOMIC64
+check_PROGRAMS +=        \
+  annotate_trace_memory
+endif
+
 if HAVE_BUILTIN_ATOMIC_CXX
 check_PROGRAMS +=        \
   annotate_smart_pointer \