summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorXavier Hernandez <jahernan@redhat.com>2017-11-07 13:45:03 +0100
committerAmar Tumballi <amarts@redhat.com>2017-11-14 05:22:00 +0000
commit3f8d118e48f11f448f35aca0c48ad40e0fd34f5b (patch)
tree8ab76f112fd5323b8820c0b2bf3ac58698981930 /configure.ac
parent87d5fb2ca50ab2812eabc7373216c45a5b4d16df (diff)
libglusterfs/atomic: Improved atomic support
This patch solves a detection problem in configure.ac that prevented that compilation detects builtin __atomic or __sync functions. It also adds more atomic types and support for other atomic functions. An special case has been added to support 64-bit atomics on 32-bit systems. The solution is to fallback to the mutex solution only for 64-bit atomics, but smaller atomic types will still take advantage of builtins if available. Change-Id: I6b9afc7cd6e66b28a33278715583552872278801 BUG: 1510397 Signed-off-by: Xavier Hernandez <jahernan@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac12
1 files changed, 9 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index cc1410f9e8d..45e892741f0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1013,18 +1013,24 @@ AC_SUBST(ARGP_STANDALONE_LDADD)
AC_SUBST(ARGP_STANDALONE_DIR)
dnl Check for atomic operation support
-AC_CHECK_FUNC([__atomic_load], [have_atomic_builtins])
+AC_MSG_CHECKING([for gcc __atomic builtins])
+AC_TRY_LINK([], [int v; __atomic_load_n(&v, __ATOMIC_ACQUIRE);],
+ [have_atomic_builtins=yes], [have_atomic_builtins=no])
if test "x${have_atomic_builtins}" = "xyes"; then
AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [define if __atomic_*() builtins are available])
fi
AC_SUBST(HAVE_ATOMIC_BUILTINS)
+AC_MSG_RESULT([$have_atomic_builtins])
dnl __sync_*() will not be needed if __atomic_*() is available
-AC_CHECK_FUNC([__sync_fetch_and_add], [have_sync_builtins])
-if test "x${have_sync_builtind}" = "xyes"; then
+AC_MSG_CHECKING([for gcc __sync builtins])
+AC_TRY_LINK([], [__sync_synchronize();],
+ [have_sync_builtins=yes], [have_sync_builtins=no])
+if test "x${have_sync_builtins}" = "xyes"; then
AC_DEFINE(HAVE_SYNC_BUILTINS, 1, [define if __sync_*() builtins are available])
fi
AC_SUBST(HAVE_SYNC_BUILTINS)
+AC_MSG_RESULT([$have_sync_builtins])
AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))