[lttng-dev] [liburcu PATCH 3/3] Add configure check for GCC atomic builtins

Alexandre Montplaisir alexandre.montplaisir at gmail.com
Thu Jan 5 22:42:37 EST 2012


I tested it on x86_64, this should be tested on other arches before
merging, namely to make sure it catches GCC version below 4.4 on ARM.

Signed-off-by: Alexandre Montplaisir <alexandre.montplaisir at gmail.com>
---
 configure.ac |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0311246..d49666d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,22 @@ AS_IF([test "$host_cpu" = "armv7l"],[
 	CFLAGS="$CFLAGS -mcpu=cortex-a9 -mtune=cortex-a9 -O1"
 ])
 
+# Check for GCC's __sync_* atomic operations.
+# Those are only available with GCC 4.1+ on most architectures but
+# require GCC 4.4+ on ARM.
+AC_MSG_CHECKING([for GCC atomic builtins])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[
+		int i, x = 0;
+		i = __sync_add_and_fetch(&x, 1);
+	]])
+],[
+	AC_MSG_RESULT([yes])
+],[
+	AC_MSG_RESULT([no])
+	AC_MSG_ERROR([cannot find the __sync_* atomic functions.
+Please upgrade your version of GCC. GCC 4.4 or above is required on ARM.])
+])
+
 # ARM-specific checks
 AS_IF([test "x$ARCHTYPE" = "xarm"],[
 	AC_MSG_CHECKING([for dmb instruction])
-- 
1.7.7.3




More information about the lttng-dev mailing list