diff options
-rw-r--r-- | get_exp.c | 1 | ||||
-rw-r--r-- | mpfr.h | 19 | ||||
-rw-r--r-- | set_dfl_prec.c | 1 | ||||
-rw-r--r-- | set_prec.c | 9 | ||||
-rw-r--r-- | set_rnd.c | 1 | ||||
-rw-r--r-- | set_ui.c | 1 |
6 files changed, 24 insertions, 8 deletions
@@ -21,6 +21,7 @@ MA 02111-1307, USA. */ #include "mpfr-impl.h" +#undef mpfr_get_exp mp_exp_t mpfr_get_exp (mpfr_srcptr x) { @@ -478,8 +478,12 @@ int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, char **, #define mpfr_const_euler(_d,_r) mpfr_cache(_d, __gmpfr_cache_const_euler, _r) /* Prevent from using mpfr_get_e{min,max} as lvalues */ +#define mpfr_get_prec(_x) ((_x)->_mpfr_prec + 0) +#define mpfr_get_exp(_x) ((_x)->_mpfr_exp + 0) #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) #define mpfr_clear_flags() \ ((void) (__gmpfr_flags = 0)) @@ -538,10 +542,11 @@ int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, char **, # define mpz_set_fr mpfr_get_z #endif -/* When using GCC, optimize certain common comparisons. - Remove ICC since it defines __GNUC__, but produces a - huge number of warnings if you use this code - Remove C++ too, since it complains too much... */ +/* When using GCC, optimize certain common comparisons and affectations. + + Remove ICC since it defines __GNUC__ but produces a + huge number of warnings if you use this code + + Remove C++ too, since it complains too much... + FIXME: Use __extension__? */ #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus) #if (__GNUC__ >= 2) #undef mpfr_cmp_ui @@ -554,6 +559,12 @@ int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, char **, (__builtin_constant_p (_s) && (_s) >= 0 ? \ mpfr_cmp_ui ((_f), (_s)) : \ mpfr_cmp_si_2exp ((_f), (_s), 0)) +#undef mpfr_set_ui +#define mpfr_set_ui(_f,_u,_r) \ + (__builtin_constant_p (_u) && (_u) == 0 ? \ + ((_f)->_mpfr_sign = 1, \ + (_f)->_mpfr_exp = __MPFR_EXP_ZERO, 0): \ + mpfr_set_ui (_f,_u,_r)) #undef mpfr_set_si #define mpfr_set_si(_f,_s,_r) \ (__builtin_constant_p (_s) && (_s) >= 0 ? \ diff --git a/set_dfl_prec.c b/set_dfl_prec.c index 8411fbbe8..8cf31a102 100644 --- a/set_dfl_prec.c +++ b/set_dfl_prec.c @@ -31,6 +31,7 @@ mpfr_set_default_prec (mp_prec_t prec) __gmpfr_default_fp_bit_precision = prec; } +#undef mpfr_get_default_prec mp_prec_t mpfr_get_default_prec (void) { diff --git a/set_prec.c b/set_prec.c index 87ef0c32b..22cf3722e 100644 --- a/set_prec.c +++ b/set_prec.c @@ -28,13 +28,13 @@ mpfr_set_prec (mpfr_ptr x, mpfr_prec_t p) mp_ptr tmp; /* first, check if p is correct */ - MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX); + MPFR_ASSERTN (p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX); /* Calculate the new number of limbs */ xsize = (p - 1) / BITS_PER_MP_LIMB + 1; /* Realloc only if the new size is greater than the old */ - xoldsize = MPFR_GET_ALLOC_SIZE(x); + xoldsize = MPFR_GET_ALLOC_SIZE (x); if (xsize > xoldsize) { tmp = (mp_ptr) (*__gmp_reallocate_func) @@ -42,10 +42,11 @@ mpfr_set_prec (mpfr_ptr x, mpfr_prec_t p) MPFR_SET_MANT_PTR(x, tmp); MPFR_SET_ALLOC_SIZE(x, xsize); } - MPFR_PREC(x) = p; - MPFR_SET_NAN(x); /* initializes to NaN */ + MPFR_PREC (x) = p; + MPFR_SET_NAN (x); /* initializes to NaN */ } +#undef mpfr_get_prec mp_prec_t mpfr_get_prec (mpfr_srcptr x) { @@ -32,6 +32,7 @@ mpfr_set_default_rounding_mode (mp_rnd_t rnd_mode) __gmpfr_default_rounding_mode = rnd_mode; } +#undef mpfr_get_default_rounding_mode mp_rnd_t mpfr_get_default_rounding_mode (void) { @@ -22,6 +22,7 @@ MA 02111-1307, USA. */ #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" +#undef mpfr_set_ui int mpfr_set_ui (mpfr_ptr x, unsigned long i, mp_rnd_t rnd_mode) { |