diff options
-rw-r--r-- | src/mpfr-gmp.c | 6 | ||||
-rw-r--r-- | src/mpfr-gmp.h | 9 | ||||
-rw-r--r-- | src/mpfr-impl.h | 15 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/mpfr-gmp.c b/src/mpfr-gmp.c index 738d19e89..faf02e383 100644 --- a/src/mpfr-gmp.c +++ b/src/mpfr-gmp.c @@ -307,9 +307,9 @@ mpfr_assert_fail (const char *filename, int linenum, and http://software.intel.com/en-us/articles/intelr-fortran-compiler-for-mac-os-non_lazy_ptr-unresolved-references-from-linking Note that using ranlib -c or libtool -c is another fix. */ -MPFR_THREAD_ATTR void * (*mpfr_allocate_func) (size_t) = 0; -MPFR_THREAD_ATTR void * (*mpfr_reallocate_func) (void *, size_t, size_t) = 0; -MPFR_THREAD_ATTR void (*mpfr_free_func) (void *, size_t) = 0; +MPFR_THREAD_VAR (mpfr_allocate_func_t, mpfr_allocate_func, 0) +MPFR_THREAD_VAR (mpfr_reallocate_func_t, mpfr_reallocate_func, 0) +MPFR_THREAD_VAR (mpfr_free_func_t, mpfr_free_func, 0) void * mpfr_tmp_allocate (struct tmp_marker **tmp_marker, size_t size) diff --git a/src/mpfr-gmp.h b/src/mpfr-gmp.h index d25157adb..eca05cbb9 100644 --- a/src/mpfr-gmp.h +++ b/src/mpfr-gmp.h @@ -305,9 +305,12 @@ extern void * (*__gmp_reallocate_func) (void *, size_t, size_t); extern void (*__gmp_free_func) (void *, size_t); #endif -__MPFR_DECLSPEC extern MPFR_THREAD_ATTR void * (*mpfr_allocate_func) (size_t); -__MPFR_DECLSPEC extern MPFR_THREAD_ATTR void * (*mpfr_reallocate_func) (void *, size_t, size_t); -__MPFR_DECLSPEC extern MPFR_THREAD_ATTR void (*mpfr_free_func) (void *, size_t); +/* Note: The declaration of the MPFR memory allocation functions had to be + moved to mpfr-impl.h for thread-safe DLL support on MS Windows, because + mpfr-gmp.h is included too early for that. */ +typedef void * (*mpfr_allocate_func_t) (size_t); +typedef void * (*mpfr_reallocate_func_t) (void *, size_t, size_t); +typedef void (*mpfr_free_func_t) (void *, size_t); #if defined(WANT_GMP_INTERNALS) && defined(HAVE___GMPN_SBPI1_DIVAPPR_Q) #ifndef __gmpn_sbpi1_divappr_q diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index a4e80363e..581271c85 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -228,6 +228,11 @@ 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; +# ifndef MPFR_HAVE_GMP_IMPL +extern MPFR_THREAD_ATTR mpfr_allocate_func_t mpfr_allocate_func; +extern MPFR_THREAD_ATTR mpfr_reallocate_func_t mpfr_reallocate_func; +extern MPFR_THREAD_ATTR mpfr_free_func_t mpfr_free_func; +# endif extern MPFR_CACHE_ATTR mpfr_cache_t __gmpfr_cache_const_euler; extern MPFR_CACHE_ATTR mpfr_cache_t __gmpfr_cache_const_catalan; # ifndef MPFR_USE_LOGGING @@ -254,6 +259,11 @@ __MPFR_DECLSPEC mpfr_exp_t * __gmpfr_emin_f (void); __MPFR_DECLSPEC mpfr_exp_t * __gmpfr_emax_f (void); __MPFR_DECLSPEC mpfr_prec_t * __gmpfr_default_fp_bit_precision_f (void); __MPFR_DECLSPEC mpfr_rnd_t * __gmpfr_default_rounding_mode_f (void); +# ifndef MPFR_HAVE_GMP_IMPL +__MPFR_DECLSPEC mpfr_allocate_func_t * __gmpfr_allocate_func_f (void); +__MPFR_DECLSPEC mpfr_reallocate_func_t * __gmpfr_reallocate_func_f (void); +__MPFR_DECLSPEC mpfr_free_func_t * __gmpfr_free_func_f (void); +# endif __MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_euler_f (void); __MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_catalan_f (void); # ifndef MPFR_USE_LOGGING @@ -273,6 +283,11 @@ __MPFR_DECLSPEC mpfr_cache_ptr * __gmpfr_cache_const_log2_f (void); # 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()) +# ifndef MPFR_HAVE_GMP_IMPL +# define mpfr_allocate_func (*__gmpfr_allocate_func_f()) +# define mpfr_reallocate_func (*__gmpfr_reallocate_func_f()) +# define mpfr_free_func (*__gmpfr_free_func_f()) +# endif # define __gmpfr_cache_const_euler (*__gmpfr_cache_const_euler_f()) # define __gmpfr_cache_const_catalan (*__gmpfr_cache_const_catalan_f()) # ifndef MPFR_USE_LOGGING |