summaryrefslogtreecommitdiff
path: root/acinclude.m4
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-06-25 17:15:04 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2012-06-25 17:15:04 +0000
commita1c9d4ec2988e4999d25e280e6066bdfe6839ba9 (patch)
treea4d02ed933e89078d7cd546310ebf06480e43820 /acinclude.m4
parentba1a92a3772ede772ce5831a5bd0891c100b56e7 (diff)
downloadmpfr-a1c9d4ec2988e4999d25e280e6066bdfe6839ba9.tar.gz
[acinclude.m4] Detect whether _Thread_local (C11) is supported.
[src/mpfr-thread.h] Use _Thread_local if supported, instead of __thread. (Patch from Patrick) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8245 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'acinclude.m4')
-rw-r--r--acinclude.m447
1 files changed, 37 insertions, 10 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index e81a134a9..abc106c3c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -389,11 +389,12 @@ dnl there is some ld configuration problem. One of the effects can
dnl be that thread-local variables always evaluate to 0. So, it is
dnl important to run the test below.
if test "$enable_thread_safe" != no; then
-AC_MSG_CHECKING(for TLS support)
+AC_MSG_CHECKING(for TLS support using C11)
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$srcdir/src"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#define MPFR_USE_THREAD_SAFE 1
+#define MPFR_USE_C11_THREAD_SAFE 1
#include "mpfr-thread.h"
MPFR_THREAD_ATTR int x = 17;
int main() {
@@ -402,20 +403,46 @@ int main() {
]])],
[AC_MSG_RESULT(yes)
AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
+ AC_DEFINE([MPFR_USE_C11_THREAD_SAFE],1,[Build MPFR as thread safe using C11])
+ tls_c11_support=yes
],
[AC_MSG_RESULT(no)
- if test "$enable_thread_safe" = yes; then
- AC_MSG_ERROR([please configure with --disable-thread-safe])
- fi
],
- [if test "$enable_thread_safe" = yes; then
- AC_MSG_RESULT([cannot test, assume yes])
- AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
- else
- AC_MSG_RESULT([cannot test, assume no])
- fi
+ [AC_MSG_RESULT([cannot test, assume no])
])
CPPFLAGS="$saved_CPPFLAGS"
+
+if test "$tls_c11_support" != "yes"
+then
+
+ AC_MSG_CHECKING(for TLS support)
+ saved_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -I$srcdir/src"
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+ #define MPFR_USE_THREAD_SAFE 1
+ #include "mpfr-thread.h"
+ MPFR_THREAD_ATTR int x = 17;
+ int main() {
+ return x != 17;
+ }
+ ]])],
+ [AC_MSG_RESULT(yes)
+ AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
+ ],
+ [AC_MSG_RESULT(no)
+ if test "$enable_thread_safe" = yes; then
+ AC_MSG_ERROR([please configure with --disable-thread-safe])
+ fi
+ ],
+ [if test "$enable_thread_safe" = yes; then
+ AC_MSG_RESULT([cannot test, assume yes])
+ AC_DEFINE([MPFR_USE_THREAD_SAFE],1,[Build MPFR as thread safe])
+ else
+ AC_MSG_RESULT([cannot test, assume no])
+ fi
+ ])
+ CPPFLAGS="$saved_CPPFLAGS"
+ fi
fi
dnl Check if Static Assertions are supported.