summaryrefslogtreecommitdiff
path: root/configure.in
diff options
context:
space:
mode:
authorTom Lane2012-01-07 20:38:52 +0000
committerTom Lane2012-01-07 20:38:52 +0000
commit0a41e865845bfa5d7aafcc5fe000dafa26573fef (patch)
treed11383fae426e60b58c5fd5a231297a51245b3a6 /configure.in
parent1fc3d18faa8f4476944bc6854be0f7f6adf4aec8 (diff)
Use __sync_lock_test_and_set() for spinlocks on ARM, if available.
Historically we've used the SWPB instruction for TAS() on ARM, but this is deprecated and not available on ARMv6 and later. Instead, make use of a GCC builtin if available. We'll still fall back to SWPB if not, so as not to break existing ports using older GCC versions. Eventually we might want to try using __sync_lock_test_and_set() on some other architectures too, but for now that seems to present only risk and not reward. Back-patch to all supported versions, since people might want to use any of them on more recent ARM chips. Martin Pitt
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in11
1 files changed, 11 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 3f195a65117..9cad43620cc 100644
--- a/configure.in
+++ b/configure.in
@@ -1454,6 +1454,17 @@ fi
AC_CHECK_FUNCS([strtoll strtoq], [break])
AC_CHECK_FUNCS([strtoull strtouq], [break])
+AC_CACHE_CHECK([for builtin locking functions], pgac_cv_gcc_int_atomics,
+[AC_TRY_LINK([],
+ [int lock = 0;
+ __sync_lock_test_and_set(&lock, 1);
+ __sync_lock_release(&lock);],
+ [pgac_cv_gcc_int_atomics="yes"],
+ [pgac_cv_gcc_int_atomics="no"])])
+if test x"$pgac_cv_gcc_int_atomics" = x"yes"; then
+ AC_DEFINE(HAVE_GCC_INT_ATOMICS, 1, [Define to 1 if you have __sync_lock_test_and_set(int *) and friends.])
+fi
+
#
# Pthreads