Skip to content

Commit 3f8d118

Browse files
xhernandezamarts
authored andcommitted
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 <[email protected]>
1 parent 87d5fb2 commit 3f8d118

File tree

6 files changed

+456
-97
lines changed

6 files changed

+456
-97
lines changed

configure.ac

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,18 +1013,24 @@ AC_SUBST(ARGP_STANDALONE_LDADD)
10131013
AC_SUBST(ARGP_STANDALONE_DIR)
10141014

10151015
dnl Check for atomic operation support
1016-
AC_CHECK_FUNC([__atomic_load], [have_atomic_builtins])
1016+
AC_MSG_CHECKING([for gcc __atomic builtins])
1017+
AC_TRY_LINK([], [int v; __atomic_load_n(&v, __ATOMIC_ACQUIRE);],
1018+
[have_atomic_builtins=yes], [have_atomic_builtins=no])
10171019
if test "x${have_atomic_builtins}" = "xyes"; then
10181020
AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [define if __atomic_*() builtins are available])
10191021
fi
10201022
AC_SUBST(HAVE_ATOMIC_BUILTINS)
1023+
AC_MSG_RESULT([$have_atomic_builtins])
10211024

10221025
dnl __sync_*() will not be needed if __atomic_*() is available
1023-
AC_CHECK_FUNC([__sync_fetch_and_add], [have_sync_builtins])
1024-
if test "x${have_sync_builtind}" = "xyes"; then
1026+
AC_MSG_CHECKING([for gcc __sync builtins])
1027+
AC_TRY_LINK([], [__sync_synchronize();],
1028+
[have_sync_builtins=yes], [have_sync_builtins=no])
1029+
if test "x${have_sync_builtins}" = "xyes"; then
10251030
AC_DEFINE(HAVE_SYNC_BUILTINS, 1, [define if __sync_*() builtins are available])
10261031
fi
10271032
AC_SUBST(HAVE_SYNC_BUILTINS)
1033+
AC_MSG_RESULT([$have_sync_builtins])
10281034

10291035
AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))
10301036

0 commit comments

Comments
 (0)