summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorJonathon Anderson <jma14@rice.edu>2019-08-25 10:01:51 -0500
committerMark Wielaard <mark@klomp.org>2019-10-22 18:27:30 +0200
commit77b66a71adaff5b445c3a5bb43b6d5742265df14 (patch)
tree4b8d792ba9969be78236b5d0dd2add05649ad048 /configure.ac
parent47780c9e4cbd312da6d93c9d70c554d34d83dd05 (diff)
Add some supporting framework for C11-style atomics.
Uses the stdatomic.h provided by FreeBSD when GCC doesn't (ie. GCC < 4.9) Signed-off-by: Jonathon Anderson <jma14@rice.edu> Signed-off-by: Srđan Milaković <sm108@rice.edu>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac12
1 files changed, 12 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index d380d016..9be34d12 100644
--- a/configure.ac
+++ b/configure.ac
@@ -226,6 +226,18 @@ LDFLAGS="$save_LDFLAGS"])
AS_IF([test "x$ac_cv_tls" != xyes],
AC_MSG_ERROR([__thread support required]))
+dnl Before 4.9 gcc doesn't ship stdatomic.h, but the nessesary atomics are
+dnl available by (at least) 4.7. So if the system doesn't have a stdatomic.h we
+dnl fall back on one copied from FreeBSD that handles the difference.
+AC_CACHE_CHECK([whether gcc provides stdatomic.h], ac_cv_has_stdatomic,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdatomic.h>]])],
+ ac_cv_has_stdatomic=yes, ac_cv_has_stdatomic=no)])
+AM_CONDITIONAL(HAVE_STDATOMIC_H, test "x$ac_cv_has_stdatomic" = xyes)
+AS_IF([test "x$ac_cv_has_stdatomic" = xyes], [AC_DEFINE(HAVE_STDATOMIC_H)])
+
+AH_TEMPLATE([HAVE_STDATOMIC_H], [Define to 1 if `stdatomic.h` is provided by the
+ system, 0 otherwise.])
+
dnl This test must come as early as possible after the compiler configuration
dnl tests, because the choice of the file model can (in principle) affect
dnl whether functions and headers are available, whether they work, etc.