summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-11-15 11:43:33 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2004-11-15 11:43:33 +0000
commit819dea3a61364b5b5cc1440f98d365078106039c (patch)
tree54cacc171d88287d74574e297fb59e4084ee43b7
parent68bb3d48c0c2a6adbed21aeac1950467fc6d2a76 (diff)
downloadmpfr-819dea3a61364b5b5cc1440f98d365078106039c.tar.gz
Add macro version for small functions:
mpfr_get_prec, mpfr_get_exp, mpfr_get_default_rounding_mode, mpfr_get_default_prec and mpfr_set_ui git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3086 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--get_exp.c1
-rw-r--r--mpfr.h19
-rw-r--r--set_dfl_prec.c1
-rw-r--r--set_prec.c9
-rw-r--r--set_rnd.c1
-rw-r--r--set_ui.c1
6 files changed, 24 insertions, 8 deletions
diff --git a/get_exp.c b/get_exp.c
index 1fbfaf5fb..a1b877794 100644
--- a/get_exp.c
+++ b/get_exp.c
@@ -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)
{
diff --git a/mpfr.h b/mpfr.h
index a8cc6e71b..746ba2680 100644
--- a/mpfr.h
+++ b/mpfr.h
@@ -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)
{
diff --git a/set_rnd.c b/set_rnd.c
index 3d0dc6ff3..b2d7a65ea 100644
--- a/set_rnd.c
+++ b/set_rnd.c
@@ -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)
{
diff --git a/set_ui.c b/set_ui.c
index 192632a06..14909dc59 100644
--- a/set_ui.c
+++ b/set_ui.c
@@ -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)
{