summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-09-10 13:45:13 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2015-09-10 13:45:13 +0000
commit1ab275e616dfb3d5d565c98db2e8f5ec1ce4e217 (patch)
treed3530e17d20abbf107f63fe3488085fa7336ce9b
parent268df0f5f40896539ef9436df17191ff184a489d (diff)
parenta61bbe8601aac72fd18d038cbe768bf664ce7bc2 (diff)
downloadmpfr-1ab275e616dfb3d5d565c98db2e8f5ec1ce4e217.tar.gz
Created win-thread-safe-dll branch from the trunk r9674 to support build
as thread-safe DLL on Windows (some problems need to be solved). See MPFR bug 19537 on: https://gforge.inria.fr/tracker/index.php?func=detail&aid=19537&group_id=136&atid=619 git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/win-thread-safe-dll@9679 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--src/const_catalan.c8
-rw-r--r--src/const_euler.c8
-rw-r--r--src/const_log2.c10
-rw-r--r--src/const_pi.c10
-rw-r--r--src/exceptions.c6
-rw-r--r--src/mpfr-impl.h79
-rw-r--r--src/mpfr-thread.h8
-rw-r--r--src/set_dfl_prec.c7
-rw-r--r--src/set_rnd.c8
-rw-r--r--tests/mpfr-test.h5
-rw-r--r--tests/tfprintf.c5
-rw-r--r--tests/tprintf.c5
-rw-r--r--tests/tsprintf.c5
13 files changed, 24 insertions, 140 deletions
diff --git a/src/const_catalan.c b/src/const_catalan.c
index 6cdd98c90..0e4402d76 100644
--- a/src/const_catalan.c
+++ b/src/const_catalan.c
@@ -26,14 +26,6 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
/* Declare the cache */
MPFR_DECL_INIT_CACHE(__gmpfr_cache_const_catalan, mpfr_const_catalan_internal);
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-mpfr_cache_t *
-__gmpfr_cache_const_catalan_f()
-{
- return &__gmpfr_cache_const_catalan;
-}
-#endif
-
/* Set User Interface */
#undef mpfr_const_catalan
int
diff --git a/src/const_euler.c b/src/const_euler.c
index 0d94f58ab..2db943865 100644
--- a/src/const_euler.c
+++ b/src/const_euler.c
@@ -29,14 +29,6 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
/* Declare the cache */
MPFR_DECL_INIT_CACHE(__gmpfr_cache_const_euler, mpfr_const_euler_internal);
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-mpfr_cache_t *
-__gmpfr_cache_const_euler_f()
-{
- return &__gmpfr_cache_const_euler;
-}
-#endif
-
/* Set User Interface */
#undef mpfr_const_euler
int
diff --git a/src/const_log2.c b/src/const_log2.c
index 6255396b3..2d94bdb02 100644
--- a/src/const_log2.c
+++ b/src/const_log2.c
@@ -32,16 +32,6 @@ MPFR_DECL_INIT_CACHE(__gmpfr_logging_log2, mpfr_const_log2_internal);
MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_log2 = __gmpfr_normal_log2;
#endif
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-# ifndef MPFR_USE_LOGGING
-mpfr_cache_t * __gmpfr_cache_const_log2_f() { return &__gmpfr_cache_const_log2; }
-# else
-mpfr_cache_t * __gmpfr_normal_log2_f() { return &__gmpfr_normal_log2; }
-mpfr_cache_t * __gmpfr_logging_log2_f() { return &__gmpfr_logging_log2; }
-mpfr_cache_ptr * __gmpfr_cache_const_log2_f() { return &__gmpfr_cache_const_log2; }
-# endif
-#endif
-
/* Set User interface */
#undef mpfr_const_log2
int
diff --git a/src/const_pi.c b/src/const_pi.c
index cc96dc4a3..6fd4d3834 100644
--- a/src/const_pi.c
+++ b/src/const_pi.c
@@ -31,16 +31,6 @@ MPFR_DECL_INIT_CACHE(__gmpfr_logging_pi, mpfr_const_pi_internal);
MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_pi = __gmpfr_normal_pi;
#endif
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-# ifndef MPFR_USE_LOGGING
-mpfr_cache_t * __gmpfr_cache_const_pi_f() { return &__gmpfr_cache_const_pi; }
-# else
-mpfr_cache_t * __gmpfr_normal_pi_f() { return &__gmpfr_normal_pi; }
-mpfr_cache_t * __gmpfr_logging_pi_f() { return &__gmpfr_logging_pi; }
-mpfr_cache_ptr * __gmpfr_cache_const_pi_f() { return &__gmpfr_cache_const_pi; }
-# endif
-#endif
-
/* Set User Interface */
#undef mpfr_const_pi
int
diff --git a/src/exceptions.c b/src/exceptions.c
index 1ca3f062a..14b57e7e7 100644
--- a/src/exceptions.c
+++ b/src/exceptions.c
@@ -27,12 +27,6 @@ MPFR_THREAD_ATTR mpfr_flags_t __gmpfr_flags = 0;
MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emin = MPFR_EMIN_DEFAULT;
MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emax = MPFR_EMAX_DEFAULT;
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-mpfr_flags_t * __gmpfr_flags_f() { return &__gmpfr_flags; }
-mpfr_exp_t * __gmpfr_emin_f() { return &__gmpfr_emin; }
-mpfr_exp_t * __gmpfr_emax_f() { return &__gmpfr_emax; }
-#endif
-
#undef mpfr_get_emin
MPFR_COLD_FUNCTION_ATTR mpfr_exp_t
diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h
index 1361759eb..97cd869b3 100644
--- a/src/mpfr-impl.h
+++ b/src/mpfr-impl.h
@@ -205,73 +205,28 @@ struct __gmpfr_cache_s {
typedef struct __gmpfr_cache_s mpfr_cache_t[1];
typedef struct __gmpfr_cache_s *mpfr_cache_ptr;
-#if defined(MPFR_USE_THREAD_SAFE) && defined(__GMP_LIBGMP_DLL)
-# define MPFR_WIN_THREAD_SAFE_DLL 1
-#endif
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_flags_t __gmpfr_flags;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emin;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emax;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_prec_t __gmpfr_default_fp_bit_precision;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_rnd_t __gmpfr_default_rounding_mode;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_euler;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_catalan;
-#if defined(__MPFR_WITHIN_MPFR) || !defined(MPFR_WIN_THREAD_SAFE_DLL)
-extern MPFR_THREAD_ATTR mpfr_flags_t __gmpfr_flags;
-extern MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emin;
-extern MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emax;
-extern MPFR_THREAD_ATTR mpfr_prec_t __gmpfr_default_fp_bit_precision;
-extern MPFR_THREAD_ATTR mpfr_rnd_t __gmpfr_default_rounding_mode;
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_euler;
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_catalan;
-# ifndef MPFR_USE_LOGGING
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_pi;
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_log2;
-# else
+#ifndef MPFR_USE_LOGGING
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_pi;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_log2;
+#else
/* Two constants are used by the logging functions (via mpfr_fprintf,
then mpfr_log, for the base conversion): pi and log(2). Since the
mpfr_cache function isn't re-entrant when working on the same cache,
we need to define two caches for each constant. */
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_normal_pi;
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_normal_log2;
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_logging_pi;
-extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_logging_log2;
-extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_pi;
-extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_log2;
-# endif
-#endif
-
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-__MPFR_DECLSPEC mpfr_flags_t * __gmpfr_flags_f();
-__MPFR_DECLSPEC mpfr_exp_t * __gmpfr_emin_f();
-__MPFR_DECLSPEC mpfr_exp_t * __gmpfr_emax_f();
-__MPFR_DECLSPEC mpfr_prec_t * __gmpfr_default_fp_bit_precision_f();
-__MPFR_DECLSPEC mpfr_rnd_t * __gmpfr_default_rounding_mode_f();
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_euler_f();
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_catalan_f();
-# ifndef MPFR_USE_LOGGING
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_pi_f();
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_log2_f();
-# else
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_normal_pi_f();
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_normal_log2_f();
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_logging_pi_f();
-__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_logging_log2_f();
-__MPFR_DECLSPEC mpfr_cache_ptr * __gmpfr_cache_const_pi_f();
-__MPFR_DECLSPEC mpfr_cache_ptr * __gmpfr_cache_const_log2_f();
-# endif
-# ifndef __MPFR_WITHIN_MPFR
-# define __gmpfr_flags (*__gmpfr_flags_f())
-# define __gmpfr_emin (*__gmpfr_emin_f())
-# define __gmpfr_emax (*__gmpfr_emax_f())
-# define __gmpfr_default_fp_bit_precision (*__gmpfr_default_fp_bit_precision_f())
-# define __gmpfr_default_rounding_mode (*__gmpfr_default_rounding_mode_f())
-# define __gmpfr_cache_const_euler (*__gmpfr_cache_const_euler_f())
-# define __gmpfr_cache_const_catalan (*__gmpfr_cache_const_catalan_f())
-# ifndef MPFR_USE_LOGGING
-# define __gmpfr_cache_const_pi (*__gmpfr_cache_const_pi_f())
-# define __gmpfr_cache_const_log2 (*__gmpfr_cache_const_log2_f())
-# else
-# define __gmpfr_normal_pi (*__gmpfr_normal_pi_f())
-# define __gmpfr_logging_pi (*__gmpfr_logging_pi_f())
-# define __gmpfr_logging_log2 (*__gmpfr_logging_log2_f())
-# define __gmpfr_cache_const_pi (*__gmpfr_cache_const_pi_f())
-# define __gmpfr_cache_const_log2 (*__gmpfr_cache_const_log2_f())
-# endif
-# endif
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_normal_pi;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_normal_log2;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_logging_pi;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_logging_log2;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_pi;
+__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_log2;
#endif
#define BASE_MAX 62
diff --git a/src/mpfr-thread.h b/src/mpfr-thread.h
index fb69c826f..c3d7d2bf8 100644
--- a/src/mpfr-thread.h
+++ b/src/mpfr-thread.h
@@ -31,7 +31,13 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#ifndef MPFR_THREAD_ATTR
# ifdef MPFR_USE_THREAD_SAFE
# if defined(_MSC_VER)
-# define MPFR_THREAD_ATTR __declspec( thread )
+# if defined(_WINDLL)
+/* see http://msdn.microsoft.com/en-us/library/9w1sdazb%28v=vs.80%29.aspx */
+# error "Can't build MPFR DLL as thread safe."
+# define MPFR_THREAD_ATTR
+# else
+# define MPFR_THREAD_ATTR __declspec( thread )
+# endif
# elif defined(MPFR_USE_C11_THREAD_SAFE)
# define MPFR_THREAD_ATTR _Thread_local
# else
diff --git a/src/set_dfl_prec.c b/src/set_dfl_prec.c
index b9a720651..537eb37ba 100644
--- a/src/set_dfl_prec.c
+++ b/src/set_dfl_prec.c
@@ -26,13 +26,6 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
MPFR_THREAD_ATTR mpfr_prec_t __gmpfr_default_fp_bit_precision \
= IEEE_DBL_MANT_DIG;
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-mpfr_prec_t * __gmpfr_default_fp_bit_precision_f()
-{
- return &__gmpfr_default_fp_bit_precision;
-}
-#endif
-
void
mpfr_set_default_prec (mpfr_prec_t prec)
{
diff --git a/src/set_rnd.c b/src/set_rnd.c
index 0c8455cf7..1a2cfc065 100644
--- a/src/set_rnd.c
+++ b/src/set_rnd.c
@@ -25,14 +25,6 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
MPFR_THREAD_ATTR mpfr_rnd_t __gmpfr_default_rounding_mode = MPFR_RNDN;
-#ifdef MPFR_WIN_THREAD_SAFE_DLL
-mpfr_rnd_t *
-__gmpfr_default_rounding_mode_f()
-{
- return &__gmpfr_default_rounding_mode;
-}
-#endif
-
void
mpfr_set_default_rounding_mode (mpfr_rnd_t rnd_mode)
{
diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h
index 5e67905af..6e39b7a28 100644
--- a/tests/mpfr-test.h
+++ b/tests/mpfr-test.h
@@ -23,11 +23,6 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
#ifndef __MPFR_TEST_H__
#define __MPFR_TEST_H__
-/* Include config.h before using ANY configure macros if needed. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
/* The no assertion request doesn't apply to the tests */
#if defined(MPFR_WANT_ASSERT)
# if MPFR_WANT_ASSERT < 0
diff --git a/tests/tfprintf.c b/tests/tfprintf.c
index 97de9b9cc..41d067f15 100644
--- a/tests/tfprintf.c
+++ b/tests/tfprintf.c
@@ -20,11 +20,6 @@ along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
-/* Include config.h before using ANY configure macros if needed. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#if defined(HAVE_STDARG) && !defined(MPFR_USE_MINI_GMP)
#include <stdarg.h>
diff --git a/tests/tprintf.c b/tests/tprintf.c
index 07f641ade..7c685264b 100644
--- a/tests/tprintf.c
+++ b/tests/tprintf.c
@@ -20,11 +20,6 @@ along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
-/* Include config.h before using ANY configure macros if needed. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#if defined(HAVE_STDARG) && !defined(MPFR_USE_MINI_GMP)
#include <stdarg.h>
diff --git a/tests/tsprintf.c b/tests/tsprintf.c
index d2c0c541a..bb399323f 100644
--- a/tests/tsprintf.c
+++ b/tests/tsprintf.c
@@ -21,11 +21,6 @@ along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
-/* Include config.h before using ANY configure macros if needed. */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#if defined(HAVE_STDARG) && !defined(MPFR_USE_MINI_GMP)
#include <stdarg.h>