diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2014-01-21 13:57:50 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2014-01-21 13:57:50 +0000 |
commit | fffef3b0937b1f0d7b92039226051f16987298ad (patch) | |
tree | 182392093f4c4d526bd04c8dcef80319d5b2acb2 | |
parent | 1a3a4c42a2ba863fa556ed5a182ad969cde2b76f (diff) | |
download | mpfr-fffef3b0937b1f0d7b92039226051f16987298ad.tar.gz |
[src/*.c] Replaced mpfr_set_divby0 by the faster MPFR_SET_DIVBY0,
and so on (except for src/exceptions.c).
[tools/mpfrlint] Update for flags related functions: check that
the macros are used in src (except for exceptions.c and mpfr.h)
instead of the functions.
[src/mpfr-impl.h] Removed some useless parentheses in comments,
for mpfrlint.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8833 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/atanh.c | 2 | ||||
-rw-r--r-- | src/cot.c | 2 | ||||
-rw-r--r-- | src/coth.c | 2 | ||||
-rw-r--r-- | src/csc.c | 2 | ||||
-rw-r--r-- | src/csch.c | 2 | ||||
-rw-r--r-- | src/digamma.c | 2 | ||||
-rw-r--r-- | src/div.c | 2 | ||||
-rw-r--r-- | src/div_ui.c | 2 | ||||
-rw-r--r-- | src/eint.c | 2 | ||||
-rw-r--r-- | src/erfc.c | 2 | ||||
-rw-r--r-- | src/gamma.c | 2 | ||||
-rw-r--r-- | src/hypot.c | 2 | ||||
-rw-r--r-- | src/lngamma.c | 6 | ||||
-rw-r--r-- | src/log.c | 2 | ||||
-rw-r--r-- | src/log10.c | 2 | ||||
-rw-r--r-- | src/log1p.c | 2 | ||||
-rw-r--r-- | src/log2.c | 2 | ||||
-rw-r--r-- | src/mpfr-impl.h | 4 | ||||
-rw-r--r-- | src/pow.c | 2 | ||||
-rw-r--r-- | src/pow_si.c | 2 | ||||
-rw-r--r-- | src/pow_z.c | 2 | ||||
-rw-r--r-- | src/rec_sqrt.c | 2 | ||||
-rw-r--r-- | src/round_near_x.c | 4 | ||||
-rw-r--r-- | src/subnormal.c | 2 | ||||
-rw-r--r-- | src/ui_div.c | 2 | ||||
-rw-r--r-- | src/yn.c | 2 | ||||
-rw-r--r-- | src/zeta.c | 2 | ||||
-rw-r--r-- | src/zeta_ui.c | 2 | ||||
-rwxr-xr-x | tools/mpfrlint | 6 |
29 files changed, 37 insertions, 33 deletions
diff --git a/src/atanh.c b/src/atanh.c index 40b0f27dd..6eb69a528 100644 --- a/src/atanh.c +++ b/src/atanh.c @@ -67,7 +67,7 @@ mpfr_atanh (mpfr_ptr y, mpfr_srcptr xt , mpfr_rnd_t rnd_mode) { MPFR_SET_INF (y); MPFR_SET_SAME_SIGN (y, xt); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); } MPFR_SET_NAN (y); @@ -32,7 +32,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define ACTION_NAN(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) #define ACTION_INF(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) #define ACTION_ZERO(y,x) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_INF(y); \ - mpfr_set_divby0 (); MPFR_RET(0); } while (1) + MPFR_SET_DIVBY0 (); MPFR_RET(0); } while (1) /* (This analysis is adapted from that for mpfr_coth.) Near x=0, cot(x) = 1/x - x/3 + ..., more precisely we have diff --git a/src/coth.c b/src/coth.c index 46beee2ca..3d751d7ca 100644 --- a/src/coth.c +++ b/src/coth.c @@ -33,7 +33,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define ACTION_NAN(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) #define ACTION_INF(y) return mpfr_set_si (y, MPFR_IS_POS(x) ? 1 : -1, rnd_mode) #define ACTION_ZERO(y,x) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_INF(y); \ - mpfr_set_divby0 (); MPFR_RET(0); } while (1) + MPFR_SET_DIVBY0 (); MPFR_RET(0); } while (1) /* We know |coth(x)| > 1, thus if the approximation z is such that 1 <= z <= 1 + 2^(-p) where p is the target precision, then the @@ -32,7 +32,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define ACTION_NAN(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) #define ACTION_INF(y) do { MPFR_SET_NAN(y); MPFR_RET_NAN; } while (1) #define ACTION_ZERO(y,x) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_INF(y); \ - mpfr_set_divby0 (); MPFR_RET(0); } while (1) + MPFR_SET_DIVBY0 (); MPFR_RET(0); } while (1) /* near x=0, we have csc(x) = 1/x + x/6 + ..., more precisely we have |csc(x) - 1/x| <= 0.2 for |x| <= 1. The analysis is similar to that for gamma(x) near x=0 (see gamma.c), except here the error term has the same diff --git a/src/csch.c b/src/csch.c index 519c14e35..a93b0d3ef 100644 --- a/src/csch.c +++ b/src/csch.c @@ -34,7 +34,7 @@ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define ACTION_INF(y) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_ZERO (y); \ MPFR_RET(0); } while (1) #define ACTION_ZERO(y,x) do { MPFR_SET_SAME_SIGN(y,x); MPFR_SET_INF(y); \ - mpfr_set_divby0 (); MPFR_RET(0); } while (1) + MPFR_SET_DIVBY0 (); MPFR_RET(0); } while (1) /* (This analysis is adapted from that for mpfr_csc.) Near x=0, we have csch(x) = 1/x - x/6 + ..., more precisely we have diff --git a/src/digamma.c b/src/digamma.c index 57dcae865..d3e4ac2ef 100644 --- a/src/digamma.c +++ b/src/digamma.c @@ -324,7 +324,7 @@ mpfr_digamma (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) /* the following works also in case of overlap */ MPFR_SET_INF(y); MPFR_SET_OPPOSITE_SIGN(y, x); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET(0); } } @@ -215,7 +215,7 @@ mpfr_div (mpfr_ptr q, mpfr_srcptr u, mpfr_srcptr v, mpfr_rnd_t rnd_mode) { MPFR_ASSERTD (! MPFR_IS_INF (u)); MPFR_SET_INF(q); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET(0); } } diff --git a/src/div_ui.c b/src/div_ui.c index 187cac087..9a142db39 100644 --- a/src/div_ui.c +++ b/src/div_ui.c @@ -77,7 +77,7 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mpfr_rnd_t rnd_mode /* x/0 is Inf since x != 0*/ MPFR_SET_INF (y); MPFR_SET_SAME_SIGN (y, x); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); } else /* y = x/1 = x */ diff --git a/src/eint.c b/src/eint.c index a57f07a78..9ee948e75 100644 --- a/src/eint.c +++ b/src/eint.c @@ -223,7 +223,7 @@ mpfr_eint (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) { MPFR_SET_INF(y); MPFR_SET_NEG(y); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET(0); } } diff --git a/src/erfc.c b/src/erfc.c index c42ce31d4..2b84aeb4d 100644 --- a/src/erfc.c +++ b/src/erfc.c @@ -185,7 +185,7 @@ mpfr_erfc (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) { near_two: mpfr_set_ui (y, 2, MPFR_RNDN); - mpfr_set_inexflag (); + MPFR_SET_INEXFLAG (); if (rnd == MPFR_RNDZ || rnd == MPFR_RNDD) { mpfr_nextbelow (y); diff --git a/src/gamma.c b/src/gamma.c index e2a67a715..cc03929f0 100644 --- a/src/gamma.c +++ b/src/gamma.c @@ -141,7 +141,7 @@ mpfr_gamma (mpfr_ptr gamma, mpfr_srcptr x, mpfr_rnd_t rnd_mode) MPFR_ASSERTD(MPFR_IS_ZERO(x)); MPFR_SET_INF(gamma); MPFR_SET_SAME_SIGN(gamma, x); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); /* exact */ } } diff --git a/src/hypot.c b/src/hypot.c index 8786e10f2..1eab34d35 100644 --- a/src/hypot.c +++ b/src/hypot.c @@ -205,7 +205,7 @@ mpfr_hypot (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode) MPFR_SAVE_EXPO_FREE (expo); if (MPFR_OVERFLOW (flags)) - mpfr_set_overflow (); + MPFR_SET_OVERFLOW (); /* hypot(x,y) >= |x|, thus underflow is not possible. */ return mpfr_check_range (z, inexact, rnd_mode); diff --git a/src/lngamma.c b/src/lngamma.c index b16230265..e5f3d5f05 100644 --- a/src/lngamma.c +++ b/src/lngamma.c @@ -628,7 +628,7 @@ mpfr_lngamma (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd) else /* lngamma(+Inf) = lngamma(+0) = +Inf */ { if (MPFR_IS_ZERO (x)) - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_SET_INF (y); MPFR_SET_POS (y); MPFR_RET (0); /* exact */ @@ -668,7 +668,7 @@ mpfr_lgamma (mpfr_ptr y, int *signp, mpfr_srcptr x, mpfr_rnd_t rnd) else { if (MPFR_IS_ZERO (x)) - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); *signp = MPFR_INT_SIGN (x); MPFR_SET_INF (y); MPFR_SET_POS (y); @@ -682,7 +682,7 @@ mpfr_lgamma (mpfr_ptr y, int *signp, mpfr_srcptr x, mpfr_rnd_t rnd) { MPFR_SET_INF (y); MPFR_SET_POS (y); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); } @@ -83,7 +83,7 @@ mpfr_log (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode) MPFR_ASSERTD (MPFR_IS_ZERO (a)); MPFR_SET_INF (r); MPFR_SET_NEG (r); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); /* log(0) is an exact -infinity */ } } diff --git a/src/log10.c b/src/log10.c index 25ff71a88..434c0765c 100644 --- a/src/log10.c +++ b/src/log10.c @@ -68,7 +68,7 @@ mpfr_log10 (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode) MPFR_ASSERTD (MPFR_IS_ZERO (a)); MPFR_SET_INF (r); MPFR_SET_NEG (r); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); /* log10(0) is an exact -infinity */ } } diff --git a/src/log1p.c b/src/log1p.c index 43235da91..82d7c376b 100644 --- a/src/log1p.c +++ b/src/log1p.c @@ -89,7 +89,7 @@ mpfr_log1p (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) { MPFR_SET_INF (y); MPFR_SET_NEG (y); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); } MPFR_SET_NAN (y); diff --git a/src/log2.c b/src/log2.c index 6580043a7..0957d99d8 100644 --- a/src/log2.c +++ b/src/log2.c @@ -66,7 +66,7 @@ mpfr_log2 (mpfr_ptr r, mpfr_srcptr a, mpfr_rnd_t rnd_mode) MPFR_ASSERTD (MPFR_IS_ZERO (a)); MPFR_SET_INF (r); MPFR_SET_NEG (r); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); /* log2(0) is an exact -infinity */ } } diff --git a/src/mpfr-impl.h b/src/mpfr-impl.h index 0b026b067..3392c41e9 100644 --- a/src/mpfr-impl.h +++ b/src/mpfr-impl.h @@ -243,7 +243,7 @@ __MPFR_DECLSPEC extern const mpfr_t __gmpfr_four; /* Note: Function-like macros that modify __gmpfr_flags are not defined because of the risk to break the sequence point rules if two such macros are used in the same expression (without a sequence point - between). For instance, mpfr_sgn currently uses mpfr_set_erangeflag(), + between). For instance, mpfr_sgn currently uses mpfr_set_erangeflag, which mustn't be implemented as a macro for this reason. */ #define mpfr_flags_test(mask) \ @@ -268,7 +268,7 @@ __MPFR_DECLSPEC extern const mpfr_t __gmpfr_four; one from using them in an expression, as the sequence point rules could be broken if __gmpfr_flags is assigned twice in the same expression (via macro expansions). For instance, the mpfr_sgn macro currently uses - mpfr_set_erangeflag(), which mustn't be implemented as a function-like + mpfr_set_erangeflag, which mustn't be implemented as a function-like macro for this reason. It is not clear whether an expression with sequence points, like (void) (0, __gmpfr_flags = 0), would avoid UB. */ #define MPFR_CLEAR_FLAGS() \ @@ -503,7 +503,7 @@ mpfr_pow (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y, mpfr_rnd_t rnd_mode) { MPFR_ASSERTD (! MPFR_IS_INF (y)); MPFR_SET_INF (z); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); } else MPFR_SET_ZERO (z); diff --git a/src/pow_si.c b/src/pow_si.c index 264647251..f92ad5dbe 100644 --- a/src/pow_si.c +++ b/src/pow_si.c @@ -56,7 +56,7 @@ mpfr_pow_si (mpfr_ptr y, mpfr_srcptr x, long int n, mpfr_rnd_t rnd) { MPFR_ASSERTD (MPFR_IS_ZERO (x)); MPFR_SET_INF (y); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); } if (positive) MPFR_SET_POS (y); diff --git a/src/pow_z.c b/src/pow_z.c index a71716895..dd9b85503 100644 --- a/src/pow_z.c +++ b/src/pow_z.c @@ -211,7 +211,7 @@ mpfr_pow_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mpfr_rnd_t rnd) { /* 0^(-n) if +/- INF */ MPFR_SET_INF (y); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); } if (MPFR_LIKELY (MPFR_IS_POS (x) || mpz_even_p (z))) MPFR_SET_POS (y); diff --git a/src/rec_sqrt.c b/src/rec_sqrt.c index 405d32b9e..b4d95e3df 100644 --- a/src/rec_sqrt.c +++ b/src/rec_sqrt.c @@ -459,7 +459,7 @@ mpfr_rec_sqrt (mpfr_ptr r, mpfr_srcptr u, mpfr_rnd_t rnd_mode) /* +0 or -0 */ MPFR_SET_INF(r); MPFR_SET_POS(r); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET(0); /* Inf is exact */ } else diff --git a/src/round_near_x.c b/src/round_near_x.c index e4e76799c..2f8e91916 100644 --- a/src/round_near_x.c +++ b/src/round_near_x.c @@ -207,7 +207,7 @@ mpfr_round_near_x (mpfr_ptr y, mpfr_srcptr v, mpfr_uexp_t err, int dir, inexact = -sign; mpfr_nexttozero (y); if (MPFR_UNLIKELY (MPFR_IS_ZERO (y))) - mpfr_set_underflow (); + MPFR_SET_UNDERFLOW (); } } else /* The error term is positive for v positive */ @@ -221,7 +221,7 @@ mpfr_round_near_x (mpfr_ptr y, mpfr_srcptr v, mpfr_uexp_t err, int dir, inexact = sign; mpfr_nexttoinf (y); if (MPFR_UNLIKELY (MPFR_IS_INF (y))) - mpfr_set_overflow (); + MPFR_SET_OVERFLOW (); } } } diff --git a/src/subnormal.c b/src/subnormal.c index 54cc023db..54d4e23fa 100644 --- a/src/subnormal.c +++ b/src/subnormal.c @@ -54,7 +54,7 @@ mpfr_subnormalize (mpfr_ptr y, int old_inexact, mpfr_rnd_t rnd) __gmpfr_emin + (mpfr_exp_t) MPFR_PREC (y) - 1))) MPFR_RET (old_inexact); - mpfr_set_underflow (); + MPFR_SET_UNDERFLOW (); sign = MPFR_SIGN (y); /* We have to emulate one bit rounding if EXP(y) = emin */ diff --git a/src/ui_div.c b/src/ui_div.c index 8dc767d68..1f8345dc9 100644 --- a/src/ui_div.c +++ b/src/ui_div.c @@ -58,7 +58,7 @@ mpfr_ui_div (mpfr_ptr y, unsigned long int u, mpfr_srcptr x, mpfr_rnd_t rnd_mode /* u > 0, so y = sign(x) * Inf */ MPFR_SET_SAME_SIGN(y, x); MPFR_SET_INF(y); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET(0); } else @@ -186,7 +186,7 @@ mpfr_yn (mpfr_ptr res, long n, mpfr_srcptr z, mpfr_rnd_t r) MPFR_SET_NEG(res); else MPFR_SET_POS(res); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET(0); } } diff --git a/src/zeta.c b/src/zeta.c index ecb13f5cd..60faa2130 100644 --- a/src/zeta.c +++ b/src/zeta.c @@ -382,7 +382,7 @@ mpfr_zeta (mpfr_t z, mpfr_srcptr s, mpfr_rnd_t rnd_mode) { MPFR_SET_INF (z); MPFR_SET_POS (z); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); MPFR_RET (0); } diff --git a/src/zeta_ui.c b/src/zeta_ui.c index 7389e2855..1bb462cd4 100644 --- a/src/zeta_ui.c +++ b/src/zeta_ui.c @@ -39,7 +39,7 @@ mpfr_zeta_ui (mpfr_ptr z, unsigned long m, mpfr_rnd_t r) { MPFR_SET_INF (z); MPFR_SET_POS (z); - mpfr_set_divby0 (); + MPFR_SET_DIVBY0 (); return 0; } else /* m >= 2 */ diff --git a/tools/mpfrlint b/tools/mpfrlint index 55ee1cd80..ba00accc3 100755 --- a/tools/mpfrlint +++ b/tools/mpfrlint @@ -8,11 +8,15 @@ dir=`pwd` grep '^# *include *<math\.h>' src/*.c -grep -E 'mpfr_(underflow|overflow|nanflag|inexflag|erangeflag)_p' src/*.{c,h} | \ +flaglist="underflow|overflow|divby0|nanflag|inexflag|erangeflag" +grep -E "mpfr_($flaglist)_p" src/*.{c,h} | \ grep -v -i 'mpfr_clear_' | \ grep -v '^src/exceptions.c:' | \ grep -v '^src/mpfr-impl.h:#define mpfr_.*_p()' | \ grep -v '^src/mpfr.h:__MPFR_DECLSPEC ' +grep -E "mpfr_(clear|set)_($flaglist) *\(" src/*.{c,h} | \ + grep -v '^src/exceptions.c:' | \ + grep -v '^src/mpfr.h:' grconf() { |