summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-07-19 00:01:28 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2018-07-19 00:01:28 +0000
commitcaaba304e3745b7f0d224e9b6788bf34c90cdabd (patch)
tree447bfd4549a08522252104166bf7670e41056580
parentba6197451e95612bdc3f2790665b5c2c52193e90 (diff)
downloadmpfr-caaba304e3745b7f0d224e9b6788bf34c90cdabd.tar.gz
Shared caches: fix and minor changes.
* Fixed detection and use of C11 thread support: the C11 header is <threads.h>, not <thread.h>. * Renamed WANT_SHARED_CACHE to MPFR_WANT_SHARED_CACHE for consistency with the other MPFR_WANT_* macros. * Added MPFR_THREAD_LOCK_METHOD macro, giving the thread locking method as a string (when shared caches are enabled). * doc/README.dev: documented 4 macros for shared caches. * tests/tversion.c: output MPFR_WANT_SHARED_CACHE and MPFR_THREAD_LOCK_METHOD information. (merged changeset r12937 from the trunk) git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/4.0@12938 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--acinclude.m42
-rw-r--r--configure.ac2
-rw-r--r--doc/README.dev9
-rw-r--r--src/buildopt.c2
-rw-r--r--src/free_cache.c4
-rw-r--r--src/mpfr-impl.h4
-rw-r--r--src/mpfr-thread.h12
-rw-r--r--tests/tconst_pi.c2
-rw-r--r--tests/tversion.c8
9 files changed, 35 insertions, 10 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 9d6835963..1c17223ae 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1557,7 +1557,7 @@ AC_DEFUN([MPFR_CHECK_C11_THREAD], [
AC_MSG_CHECKING([for ISO C11 thread support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <assert.h>
-#include <thread.h>
+#include <threads.h>
mtx_t lock;
once_flag once = ONCE_FLAG_INIT;
thrd_t thd_idx;
diff --git a/configure.ac b/configure.ac
index 828613614..bea5aed06 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,7 +168,7 @@ AC_ARG_ENABLE(shared-cache,
dependent on PTHREAD [[default=no]]],
[ case $enableval in
yes) mpfr_want_shared_cache=yes
- AC_DEFINE([WANT_SHARED_CACHE],1,[Want shared cache]) ;;
+ AC_DEFINE([MPFR_WANT_SHARED_CACHE],1,[Want shared cache]) ;;
no) ;;
*) AC_MSG_ERROR([bad value for --enable-shared-cache: yes or no]) ;;
esac])
diff --git a/doc/README.dev b/doc/README.dev
index d820a2dbd..2aee84045 100644
--- a/doc/README.dev
+++ b/doc/README.dev
@@ -427,6 +427,9 @@ List of macros used for building MPFR (also used for checking):
+ MPFR_HAVE_INTMAX_MAX: Define if the INTMAX_MAX macro works correctly
(if 'intmax_t' is supported).
++ MPFR_HAVE_C11_LOCK: Define if C11 threads are supported.
++ HAVE_PTHREAD: Define if pthread is available.
+
Format of long double.
+ HAVE_LDOUBLE_IS_DOUBLE: IEEE double.
+ HAVE_LDOUBLE_IEEE_EXT_BIG: IEEE extended, big endian.
@@ -470,6 +473,12 @@ Format of long double.
+ MPFR_USE_C11_THREAD_SAFE:
Define to implement TLS in the C11 way.
++ MPFR_WANT_SHARED_CACHE:
+ Define to have caches shared by all threads.
++ MPFR_THREAD_LOCK_METHOD:
+ When MPFR_WANT_SHARED_CACHE is defined, this macro
+ gives the thread locking method (string).
+
+ MPFR_HAVE_NORETURN: Define if the _Noreturn function specifier is
supported.
+ MPFR_HAVE_BUILTIN_UNREACHABLE:
diff --git a/src/buildopt.c b/src/buildopt.c
index 66eeee040..fdd0e8bb9 100644
--- a/src/buildopt.c
+++ b/src/buildopt.c
@@ -66,7 +66,7 @@ mpfr_buildopt_gmpinternals_p (void)
int
mpfr_buildopt_sharedcache_p (void)
{
-#if defined (WANT_SHARED_CACHE)
+#ifdef MPFR_WANT_SHARED_CACHE
return 1;
#else
return 0;
diff --git a/src/free_cache.c b/src/free_cache.c
index a364be493..a847a1d5d 100644
--- a/src/free_cache.c
+++ b/src/free_cache.c
@@ -63,13 +63,13 @@ mpfr_free_cache2 (mpfr_free_cache_t way)
if ((unsigned int) way & MPFR_FREE_LOCAL_CACHE)
{
mpfr_free_local_cache ();
-#if !defined (WANT_SHARED_CACHE)
+#if !defined(MPFR_WANT_SHARED_CACHE)
mpfr_free_const_caches ();
#endif
}
if ((unsigned int) way & MPFR_FREE_GLOBAL_CACHE)
{
-#if defined (WANT_SHARED_CACHE)
+#if defined(MPFR_WANT_SHARED_CACHE)
mpfr_free_const_caches ();
#endif
}
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h
index c2f810181..d4b27bb9a 100644
--- a/src/mpfr-impl.h
+++ b/src/mpfr-impl.h
@@ -83,7 +83,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
/* For the definition of MPFR_THREAD_ATTR. GCC/ICC detection macros are
no longer used, as they sometimes gave incorrect information about
the support of thread-local variables. A configure check is now done. */
-#if defined (WANT_SHARED_CACHE)
+#if defined(MPFR_WANT_SHARED_CACHE)
# define MPFR_NEED_THREAD_LOCK 1
#endif
#include "mpfr-thread.h"
@@ -207,7 +207,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
extern "C" {
#endif
-#if defined(WANT_SHARED_CACHE)
+#if defined(MPFR_WANT_SHARED_CACHE)
# define MPFR_CACHE_ATTR
#else
# define MPFR_CACHE_ATTR MPFR_THREAD_ATTR
diff --git a/src/mpfr-thread.h b/src/mpfr-thread.h
index 2bc1d525c..d8ca6e4b5 100644
--- a/src/mpfr-thread.h
+++ b/src/mpfr-thread.h
@@ -53,9 +53,13 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
/* ISO C11 version */
/**************************************************************************/
/**************************************************************************/
+
#if defined (MPFR_HAVE_C11_LOCK)
/* NOTE: This version has not been completely tested */
-#include <thread.h>
+
+#define MPFR_THREAD_LOCK_METHOD "C11"
+
+#include <threads.h>
#define MPFR_LOCK_DECL(_lock) \
mtx_t _lock;
@@ -110,8 +114,12 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
/* POSIX version */
/**************************************************************************/
/**************************************************************************/
+
#elif defined (HAVE_PTHREAD)
-# include <pthread.h>
+
+#define MPFR_THREAD_LOCK_METHOD "pthread"
+
+#include <pthread.h>
#define MPFR_LOCK_DECL(_lock) \
pthread_rwlock_t _lock;
diff --git a/tests/tconst_pi.c b/tests/tconst_pi.c
index 1780e3805..8e8390c39 100644
--- a/tests/tconst_pi.c
+++ b/tests/tconst_pi.c
@@ -22,7 +22,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#include "mpfr-test.h"
-#if defined (WANT_SHARED_CACHE) && defined(HAVE_PTHREAD)
+#if defined(MPFR_WANT_SHARED_CACHE) && defined(HAVE_PTHREAD)
# include <pthread.h>
diff --git a/tests/tversion.c b/tests/tversion.c
index 855199c65..01f755c79 100644
--- a/tests/tversion.c
+++ b/tests/tversion.c
@@ -250,6 +250,14 @@ main (void)
mpfr_buildopt_decimal_p () ? "yes" : "no",
mpfr_buildopt_gmpinternals_p () ? "yes" : "no");
+ printf ("[tversion] Shared cache = "
+#if defined(MPFR_WANT_SHARED_CACHE)
+ "yes (" MPFR_THREAD_LOCK_METHOD ")"
+#else
+ "no"
+#endif
+ "\n");
+
printf ("[tversion] intmax_t = "
#if defined(_MPFR_H_HAVE_INTMAX_T)
"yes"