summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2017-03-31 01:26:25 +0300
committerMatt Turner <mattst88@gmail.com>2017-04-03 10:52:41 -0700
commita6a38a038bd62e6d9558905f00bef81b5e7e6fcc (patch)
tree31b279352fe710282572467d6900d1041551952f /configure.ac
parent70c272004f727457e852ba5f2498754b07a7d995 (diff)
util/u_atomic: provide 64bit atomics where they're missing
There are still some distributions trying to support unfortunate people with old or exotic CPUs that don't have 64bit atomic operations. When compiling for such a machine, gcc conveniently inserts a library call to a helper, but it's implementation is missing and we get a linker error. This allows us to provide our own implementation, which is marked weak to prefer a better implementation, should one exist. v2: changed copyright, some style adjustments v3: [mattst88] Print results with AC_MSG_CHECKING/AC_MSG_RESULT Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93089 Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac14
1 files changed, 14 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 016e38fb599..83cd5d1d15e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -415,6 +415,20 @@ if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" = x1; then
fi
AM_CONDITIONAL([GCC_ATOMIC_BUILTINS_SUPPORTED], [test x$GCC_ATOMIC_BUILTINS_SUPPORTED = x1])
+dnl Check if host supports 64-bit atomics
+dnl note that lack of support usually results in link (not compile) error
+AC_MSG_CHECKING(whether __sync_add_and_fetch_8 is supported)
+AC_LINK_IFELSE([AC_LANG_SOURCE([[
+#include <stdint.h>
+uint64_t v;
+int main() {
+ return __sync_add_and_fetch(&v, (uint64_t)1);
+}]])], GCC_64BIT_ATOMICS_SUPPORTED=yes, GCC_64BIT_ATOMICS_SUPPORTED=no)
+if test "x$GCC_64BIT_ATOMICS_SUPPORTED" != xyes; then
+ DEFINES="$DEFINES -DMISSING_64BIT_ATOMICS"
+fi
+AC_MSG_RESULT($GCC_64BIT_ATOMICS_SUPPORTED)
+
dnl Check for Endianness
AC_C_BIGENDIAN(
little_endian=no,