diff options
Diffstat (limited to 'Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h')
-rw-r--r-- | Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h | 77 |
1 files changed, 51 insertions, 26 deletions
diff --git a/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h b/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h index 0066f90d360..03e64f4be13 100644 --- a/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h +++ b/Build/source/libs/mpfr/mpfr-src/src/mpfr-impl.h @@ -1,6 +1,6 @@ /* Utilities for MPFR developers, not exported. -Copyright 1999-2016 Free Software Foundation, Inc. +Copyright 1999-2017 Free Software Foundation, Inc. Contributed by the AriC and Caramba projects, INRIA. This file is part of the GNU MPFR Library. @@ -277,23 +277,24 @@ extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_log2; #endif #ifdef MPFR_WIN_THREAD_SAFE_DLL -__MPFR_DECLSPEC unsigned int * __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(); +# define MPFR_MAKE_VARFCT(T,N) T * N ## _f (void) { return &N; } +__MPFR_DECLSPEC unsigned int * __gmpfr_flags_f (void); +__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); +__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 -__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_pi_f(); -__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_log2_f(); +__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_pi_f (void); +__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_cache_const_log2_f (void); # 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(); +__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_normal_pi_f (void); +__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_normal_log2_f (void); +__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_logging_pi_f (void); +__MPFR_DECLSPEC mpfr_cache_t * __gmpfr_logging_log2_f (void); +__MPFR_DECLSPEC mpfr_cache_ptr * __gmpfr_cache_const_pi_f (void); +__MPFR_DECLSPEC mpfr_cache_ptr * __gmpfr_cache_const_log2_f (void); # endif # ifndef __MPFR_WITHIN_MPFR # define __gmpfr_flags (*__gmpfr_flags_f()) @@ -314,8 +315,14 @@ __MPFR_DECLSPEC mpfr_cache_ptr * __gmpfr_cache_const_log2_f(); # define __gmpfr_cache_const_log2 (*__gmpfr_cache_const_log2_f()) # endif # endif +#else +# define MPFR_MAKE_VARFCT(T,N) #endif +# define MPFR_THREAD_VAR(T,N,V) \ + MPFR_THREAD_ATTR T N = (V); \ + MPFR_MAKE_VARFCT (T,N) + #define BASE_MAX 62 __MPFR_DECLSPEC extern const __mpfr_struct __gmpfr_l2b[BASE_MAX-1][2]; @@ -341,11 +348,15 @@ __MPFR_DECLSPEC extern const mpfr_t __gmpfr_four; #define MPFR_FLAGS_DIVBY0 32 #define MPFR_FLAGS_ALL 63 -/* Replace some common functions for direct access to the global vars */ -#define mpfr_get_emin() (__gmpfr_emin + 0) -#define mpfr_get_emax() (__gmpfr_emax + 0) -#define mpfr_get_default_rounding_mode() (__gmpfr_default_rounding_mode + 0) -#define mpfr_get_default_prec() (__gmpfr_default_fp_bit_precision + 0) +/* Replace some common functions for direct access to the global vars. + The casts prevent these macros from being used as a lvalue (and this + method makes sure that the expressions have the correct type). */ +#define mpfr_get_emin() ((mpfr_exp_t) __gmpfr_emin) +#define mpfr_get_emax() ((mpfr_exp_t) __gmpfr_emax) +#define mpfr_get_default_rounding_mode() \ + ((mpfr_rnd_t) __gmpfr_default_rounding_mode) +#define mpfr_get_default_prec() \ + ((mpfr_prec_t) __gmpfr_default_fp_bit_precision) #define mpfr_clear_flags() \ ((void) (__gmpfr_flags = 0)) @@ -872,7 +883,7 @@ typedef intmax_t mpfr_eexp_t; following two macros, unless the flag comes from another function returning the ternary inexact value */ #define MPFR_RET(I) return \ - (I) ? ((__gmpfr_flags |= MPFR_FLAGS_INEXACT), (I)) : 0 + (I) != 0 ? ((__gmpfr_flags |= MPFR_FLAGS_INEXACT), (I)) : 0 #define MPFR_RET_NAN return (__gmpfr_flags |= MPFR_FLAGS_NAN), 0 #define MPFR_SET_ERANGE() (__gmpfr_flags |= MPFR_FLAGS_ERANGE) @@ -1044,7 +1055,8 @@ extern unsigned char *mpfr_stack; #define MPFR_DECL_INIT_CACHE(_cache,_func) \ MPFR_THREAD_ATTR mpfr_cache_t _cache = \ - {{{{0,MPFR_SIGN_POS,0,(mp_limb_t*)0}},0,_func}} + {{{{0,MPFR_SIGN_POS,0,(mp_limb_t*)0}},0,_func}}; \ + MPFR_MAKE_VARFCT (mpfr_cache_t,_cache) @@ -1197,15 +1209,28 @@ do { \ # endif #endif +/* FIXME: Add support for multibyte decimal_point and thousands_sep since + this can be found in practice: https://reviews.llvm.org/D27167 says: + "I found this problem on FreeBSD 11, where thousands_sep in fr_FR.UTF-8 + is a no-break space (U+00A0)." + Note, however, that this is not allowed by the C standard, which just + says "character" and not "multibyte character". + In the mean time, in case of non-single-byte character, revert to the + default value. */ #if MPFR_LCONV_DPTS #include <locale.h> /* Warning! In case of signed char, the value of MPFR_DECIMAL_POINT may be negative (the ISO C99 does not seem to forbid negative values). */ -#define MPFR_DECIMAL_POINT (localeconv()->decimal_point[0]) -#define MPFR_THOUSANDS_SEPARATOR (localeconv()->thousands_sep[0]) +#define MPFR_DECIMAL_POINT \ + (localeconv()->decimal_point[1] != '\0' ? \ + (char) '.' : localeconv()->decimal_point[0]) +#define MPFR_THOUSANDS_SEPARATOR \ + (localeconv()->thousands_sep[0] == '\0' || \ + localeconv()->thousands_sep[1] != '\0' ? \ + (char) '\0' : localeconv()->thousands_sep[0]) #else #define MPFR_DECIMAL_POINT ((char) '.') -#define MPFR_THOUSANDS_SEPARATOR ('\0') +#define MPFR_THOUSANDS_SEPARATOR ((char) '\0') #endif |