[d42579b] | 1 | Submitted By: William Harrington (kb0iic at cross-lfs dot org)
|
---|
| 2 | Date: 2013-11-11
|
---|
| 3 | Initial Package Version: 3.1.2
|
---|
| 4 | Origin: Upstream
|
---|
| 5 | Upstream Status: Applied
|
---|
| 6 | Description: Contains all upstream patches of mpfr current.
|
---|
| 7 |
|
---|
| 8 | diff -Naur mpfr-3.1.2.orig/PATCHES mpfr-3.1.2/PATCHES
|
---|
| 9 | --- mpfr-3.1.2.orig/PATCHES 2013-03-13 15:37:38.000000000 +0000
|
---|
| 10 | +++ mpfr-3.1.2/PATCHES 2013-11-11 23:55:16.818732551 +0000
|
---|
| 11 | @@ -0,0 +1,3 @@
|
---|
| 12 | +clang-divby0
|
---|
| 13 | +fits-smallneg
|
---|
| 14 | +exp_2
|
---|
| 15 | diff -Naur mpfr-3.1.2.orig/VERSION mpfr-3.1.2/VERSION
|
---|
| 16 | --- mpfr-3.1.2.orig/VERSION 2013-03-13 15:37:28.000000000 +0000
|
---|
| 17 | +++ mpfr-3.1.2/VERSION 2013-11-11 23:55:16.818732551 +0000
|
---|
| 18 | @@ -1 +1 @@
|
---|
| 19 | -3.1.2
|
---|
| 20 | +3.1.2-p3
|
---|
| 21 | diff -Naur mpfr-3.1.2.orig/src/exp_2.c mpfr-3.1.2/src/exp_2.c
|
---|
| 22 | --- mpfr-3.1.2.orig/src/exp_2.c 2013-03-13 15:37:28.000000000 +0000
|
---|
| 23 | +++ mpfr-3.1.2/src/exp_2.c 2013-11-11 23:55:16.810732551 +0000
|
---|
| 24 | @@ -204,7 +204,7 @@
|
---|
| 25 | for (k = 0; k < K; k++)
|
---|
| 26 | {
|
---|
| 27 | mpz_mul (ss, ss, ss);
|
---|
| 28 | - exps <<= 1;
|
---|
| 29 | + exps *= 2;
|
---|
| 30 | exps += mpz_normalize (ss, ss, q);
|
---|
| 31 | }
|
---|
| 32 | mpfr_set_z (s, ss, MPFR_RNDN);
|
---|
| 33 | diff -Naur mpfr-3.1.2.orig/src/fits_u.h mpfr-3.1.2/src/fits_u.h
|
---|
| 34 | --- mpfr-3.1.2.orig/src/fits_u.h 2013-03-13 15:37:35.000000000 +0000
|
---|
| 35 | +++ mpfr-3.1.2/src/fits_u.h 2013-11-11 23:55:16.818732551 +0000
|
---|
| 36 | @@ -32,17 +32,20 @@
|
---|
| 37 | int res;
|
---|
| 38 |
|
---|
| 39 | if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
|
---|
| 40 | - /* Zero always fit */
|
---|
| 41 | - return MPFR_IS_ZERO (f) ? 1 : 0;
|
---|
| 42 | - else if (MPFR_IS_NEG (f))
|
---|
| 43 | - /* Negative numbers don't fit */
|
---|
| 44 | - return 0;
|
---|
| 45 | - /* now it fits if
|
---|
| 46 | - (a) f <= MAXIMUM
|
---|
| 47 | - (b) round(f, prec(slong), rnd) <= MAXIMUM */
|
---|
| 48 | + return MPFR_IS_ZERO (f) ? 1 : 0; /* Zero always fits */
|
---|
| 49 |
|
---|
| 50 | e = MPFR_GET_EXP (f);
|
---|
| 51 |
|
---|
| 52 | + if (MPFR_IS_NEG (f))
|
---|
| 53 | + return e >= 1 ? 0 /* f <= -1 does not fit */
|
---|
| 54 | + : rnd != MPFR_RNDN ? MPFR_IS_LIKE_RNDU (rnd, -1) /* directed mode */
|
---|
| 55 | + : e < 0 ? 1 /* f > -1/2 fits in MPFR_RNDN */
|
---|
| 56 | + : mpfr_powerof2_raw(f); /* -1/2 fits, -1 < f < -1/2 don't */
|
---|
| 57 | +
|
---|
| 58 | + /* Now it fits if
|
---|
| 59 | + (a) f <= MAXIMUM
|
---|
| 60 | + (b) round(f, prec(slong), rnd) <= MAXIMUM */
|
---|
| 61 | +
|
---|
| 62 | /* first compute prec(MAXIMUM); fits in an int */
|
---|
| 63 | for (s = MAXIMUM, prec = 0; s != 0; s /= 2, prec ++);
|
---|
| 64 |
|
---|
| 65 | diff -Naur mpfr-3.1.2.orig/src/fits_uintmax.c mpfr-3.1.2/src/fits_uintmax.c
|
---|
| 66 | --- mpfr-3.1.2.orig/src/fits_uintmax.c 2013-03-13 15:37:33.000000000 +0000
|
---|
| 67 | +++ mpfr-3.1.2/src/fits_uintmax.c 2013-11-11 23:55:16.818732551 +0000
|
---|
| 68 | @@ -27,51 +27,19 @@
|
---|
| 69 | #include "mpfr-intmax.h"
|
---|
| 70 | #include "mpfr-impl.h"
|
---|
| 71 |
|
---|
| 72 | -#ifdef _MPFR_H_HAVE_INTMAX_T
|
---|
| 73 | -
|
---|
| 74 | -/* We can't use fits_u.h <= mpfr_cmp_ui */
|
---|
| 75 | -int
|
---|
| 76 | -mpfr_fits_uintmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
|
---|
| 77 | -{
|
---|
| 78 | - mpfr_exp_t e;
|
---|
| 79 | - int prec;
|
---|
| 80 | - uintmax_t s;
|
---|
| 81 | - mpfr_t x;
|
---|
| 82 | - int res;
|
---|
| 83 | -
|
---|
| 84 | - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
|
---|
| 85 | - /* Zero always fit */
|
---|
| 86 | - return MPFR_IS_ZERO (f) ? 1 : 0;
|
---|
| 87 | - else if (MPFR_IS_NEG (f))
|
---|
| 88 | - /* Negative numbers don't fit */
|
---|
| 89 | - return 0;
|
---|
| 90 | - /* now it fits if
|
---|
| 91 | - (a) f <= MAXIMUM
|
---|
| 92 | - (b) round(f, prec(slong), rnd) <= MAXIMUM */
|
---|
| 93 | -
|
---|
| 94 | - e = MPFR_GET_EXP (f);
|
---|
| 95 | +/* Note: though mpfr-impl.h is included in fits_u.h, we also include it
|
---|
| 96 | + above so that it gets included even when _MPFR_H_HAVE_INTMAX_T is not
|
---|
| 97 | + defined; this is necessary to avoid an empty translation unit, which
|
---|
| 98 | + is forbidden by ISO C. Without this, a failing test can be reproduced
|
---|
| 99 | + by creating an invalid stdint.h somewhere in the default include path
|
---|
| 100 | + and by compiling MPFR with "gcc -ansi -pedantic-errors". */
|
---|
| 101 |
|
---|
| 102 | - /* first compute prec(MAXIMUM); fits in an int */
|
---|
| 103 | - for (s = MPFR_UINTMAX_MAX, prec = 0; s != 0; s /= 2, prec ++);
|
---|
| 104 | -
|
---|
| 105 | - /* MAXIMUM needs prec bits, i.e. MAXIMUM = 2^prec - 1 */
|
---|
| 106 | -
|
---|
| 107 | - /* if e <= prec - 1, then f < 2^(prec-1) < MAXIMUM */
|
---|
| 108 | - if (e <= prec - 1)
|
---|
| 109 | - return 1;
|
---|
| 110 | -
|
---|
| 111 | - /* if e >= prec + 1, then f >= 2^prec > MAXIMUM */
|
---|
| 112 | - if (e >= prec + 1)
|
---|
| 113 | - return 0;
|
---|
| 114 | +#ifdef _MPFR_H_HAVE_INTMAX_T
|
---|
| 115 |
|
---|
| 116 | - MPFR_ASSERTD (e == prec);
|
---|
| 117 | +#define FUNCTION mpfr_fits_uintmax_p
|
---|
| 118 | +#define MAXIMUM MPFR_UINTMAX_MAX
|
---|
| 119 | +#define TYPE uintmax_t
|
---|
| 120 |
|
---|
| 121 | - /* hard case: first round to prec bits, then check */
|
---|
| 122 | - mpfr_init2 (x, prec);
|
---|
| 123 | - mpfr_set (x, f, rnd);
|
---|
| 124 | - res = MPFR_GET_EXP (x) == e;
|
---|
| 125 | - mpfr_clear (x);
|
---|
| 126 | - return res;
|
---|
| 127 | -}
|
---|
| 128 | +#include "fits_u.h"
|
---|
| 129 |
|
---|
| 130 | #endif
|
---|
| 131 | diff -Naur mpfr-3.1.2.orig/src/mpfr-impl.h mpfr-3.1.2/src/mpfr-impl.h
|
---|
| 132 | --- mpfr-3.1.2.orig/src/mpfr-impl.h 2013-03-13 15:37:36.000000000 +0000
|
---|
| 133 | +++ mpfr-3.1.2/src/mpfr-impl.h 2013-11-11 23:55:16.818732551 +0000
|
---|
| 134 | @@ -468,8 +468,16 @@
|
---|
| 135 | #define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1)
|
---|
| 136 |
|
---|
| 137 | /* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0
|
---|
| 138 | - at compile time. */
|
---|
| 139 | -#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
|
---|
| 140 | + at compile time.
|
---|
| 141 | + Clang with -fsanitize=undefined is a bit similar due to a bug:
|
---|
| 142 | + http://llvm.org/bugs/show_bug.cgi?id=17381
|
---|
| 143 | + but even without its sanitizer, it may be better to use the
|
---|
| 144 | + double_zero version until IEEE 754 division by zero is properly
|
---|
| 145 | + supported:
|
---|
| 146 | + http://llvm.org/bugs/show_bug.cgi?id=17000
|
---|
| 147 | +*/
|
---|
| 148 | +#if (defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)) || \
|
---|
| 149 | + defined(__clang__)
|
---|
| 150 | static double double_zero = 0.0;
|
---|
| 151 | # define DBL_NAN (double_zero/double_zero)
|
---|
| 152 | # define DBL_POS_INF ((double) 1.0/double_zero)
|
---|
| 153 | @@ -501,6 +509,8 @@
|
---|
| 154 | (with Xcode 2.4.1, i.e. the latest one). */
|
---|
| 155 | #define LVALUE(x) (&(x) == &(x) || &(x) != &(x))
|
---|
| 156 | #define DOUBLE_ISINF(x) (LVALUE(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
|
---|
| 157 | +/* The DOUBLE_ISNAN(x) macro is also valid on long double x
|
---|
| 158 | + (assuming that the compiler isn't too broken). */
|
---|
| 159 | #ifdef MPFR_NANISNAN
|
---|
| 160 | /* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
|
---|
| 161 | The + must not be replaced by a ||. With gcc -ffast-math, NaN is
|
---|
| 162 | diff -Naur mpfr-3.1.2.orig/src/mpfr.h mpfr-3.1.2/src/mpfr.h
|
---|
| 163 | --- mpfr-3.1.2.orig/src/mpfr.h 2013-03-13 15:37:37.000000000 +0000
|
---|
| 164 | +++ mpfr-3.1.2/src/mpfr.h 2013-11-11 23:55:16.818732551 +0000
|
---|
| 165 | @@ -27,7 +27,7 @@
|
---|
| 166 | #define MPFR_VERSION_MAJOR 3
|
---|
| 167 | #define MPFR_VERSION_MINOR 1
|
---|
| 168 | #define MPFR_VERSION_PATCHLEVEL 2
|
---|
| 169 | -#define MPFR_VERSION_STRING "3.1.2"
|
---|
| 170 | +#define MPFR_VERSION_STRING "3.1.2-p3"
|
---|
| 171 |
|
---|
| 172 | /* Macros dealing with MPFR VERSION */
|
---|
| 173 | #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
|
---|
| 174 | diff -Naur mpfr-3.1.2.orig/src/version.c mpfr-3.1.2/src/version.c
|
---|
| 175 | --- mpfr-3.1.2.orig/src/version.c 2013-03-13 15:37:34.000000000 +0000
|
---|
| 176 | +++ mpfr-3.1.2/src/version.c 2013-11-11 23:55:16.818732551 +0000
|
---|
| 177 | @@ -25,5 +25,5 @@
|
---|
| 178 | const char *
|
---|
| 179 | mpfr_get_version (void)
|
---|
| 180 | {
|
---|
| 181 | - return "3.1.2";
|
---|
| 182 | + return "3.1.2-p3";
|
---|
| 183 | }
|
---|
| 184 | diff -Naur mpfr-3.1.2.orig/tests/tfits.c mpfr-3.1.2/tests/tfits.c
|
---|
| 185 | --- mpfr-3.1.2.orig/tests/tfits.c 2013-03-13 15:37:45.000000000 +0000
|
---|
| 186 | +++ mpfr-3.1.2/tests/tfits.c 2013-11-11 23:55:16.818732551 +0000
|
---|
| 187 | @@ -33,155 +33,176 @@
|
---|
| 188 | #include "mpfr-intmax.h"
|
---|
| 189 | #include "mpfr-test.h"
|
---|
| 190 |
|
---|
| 191 | -#define ERROR1 { printf("Initial error for x="); mpfr_dump(x); exit(1); }
|
---|
| 192 | -#define ERROR2 { printf("Error for x="); mpfr_dump(x); exit(1); }
|
---|
| 193 | +#define ERROR1(N) \
|
---|
| 194 | + do \
|
---|
| 195 | + { \
|
---|
| 196 | + printf("Error %d for rnd = %s and x = ", N, \
|
---|
| 197 | + mpfr_print_rnd_mode ((mpfr_rnd_t) r)); \
|
---|
| 198 | + mpfr_dump(x); \
|
---|
| 199 | + exit(1); \
|
---|
| 200 | + } \
|
---|
| 201 | + while (0)
|
---|
| 202 |
|
---|
| 203 | static void check_intmax (void);
|
---|
| 204 |
|
---|
| 205 | int
|
---|
| 206 | main (void)
|
---|
| 207 | {
|
---|
| 208 | - mpfr_t x;
|
---|
| 209 | + mpfr_t x, y;
|
---|
| 210 | + int i, r;
|
---|
| 211 |
|
---|
| 212 | tests_start_mpfr ();
|
---|
| 213 |
|
---|
| 214 | mpfr_init2 (x, 256);
|
---|
| 215 | + mpfr_init2 (y, 8);
|
---|
| 216 |
|
---|
| 217 | - /* Check NAN */
|
---|
| 218 | - mpfr_set_nan (x);
|
---|
| 219 | - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 220 | - ERROR1;
|
---|
| 221 | - if (mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 222 | - ERROR1;
|
---|
| 223 | - if (mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 224 | - ERROR1;
|
---|
| 225 | - if (mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 226 | - ERROR1;
|
---|
| 227 | - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 228 | - ERROR1;
|
---|
| 229 | - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 230 | - ERROR1;
|
---|
| 231 | -
|
---|
| 232 | - /* Check INF */
|
---|
| 233 | - mpfr_set_inf (x, 1);
|
---|
| 234 | - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 235 | - ERROR1;
|
---|
| 236 | - if (mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 237 | - ERROR1;
|
---|
| 238 | - if (mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 239 | - ERROR1;
|
---|
| 240 | - if (mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 241 | - ERROR1;
|
---|
| 242 | - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 243 | - ERROR1;
|
---|
| 244 | - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 245 | - ERROR1;
|
---|
| 246 | -
|
---|
| 247 | - /* Check Zero */
|
---|
| 248 | - MPFR_SET_ZERO (x);
|
---|
| 249 | - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 250 | - ERROR2;
|
---|
| 251 | - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 252 | - ERROR2;
|
---|
| 253 | - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 254 | - ERROR2;
|
---|
| 255 | - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 256 | - ERROR2;
|
---|
| 257 | - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 258 | - ERROR2;
|
---|
| 259 | - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 260 | - ERROR2;
|
---|
| 261 | -
|
---|
| 262 | - /* Check small op */
|
---|
| 263 | - mpfr_set_str1 (x, "1@-1");
|
---|
| 264 | - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 265 | - ERROR2;
|
---|
| 266 | - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 267 | - ERROR2;
|
---|
| 268 | - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 269 | - ERROR2;
|
---|
| 270 | - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 271 | - ERROR2;
|
---|
| 272 | - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 273 | - ERROR2;
|
---|
| 274 | - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 275 | - ERROR2;
|
---|
| 276 | -
|
---|
| 277 | - /* Check 17 */
|
---|
| 278 | - mpfr_set_ui (x, 17, MPFR_RNDN);
|
---|
| 279 | - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 280 | - ERROR2;
|
---|
| 281 | - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 282 | - ERROR2;
|
---|
| 283 | - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 284 | - ERROR2;
|
---|
| 285 | - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 286 | - ERROR2;
|
---|
| 287 | - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 288 | - ERROR2;
|
---|
| 289 | - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 290 | - ERROR2;
|
---|
| 291 | -
|
---|
| 292 | - /* Check all other values */
|
---|
| 293 | - mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
|
---|
| 294 | - mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
|
---|
| 295 | - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 296 | - ERROR1;
|
---|
| 297 | - if (mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 298 | - ERROR1;
|
---|
| 299 | - mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
|
---|
| 300 | - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 301 | - ERROR1;
|
---|
| 302 | - if (mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 303 | - ERROR1;
|
---|
| 304 | - if (mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 305 | - ERROR1;
|
---|
| 306 | - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 307 | - ERROR1;
|
---|
| 308 | - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 309 | - ERROR1;
|
---|
| 310 | -
|
---|
| 311 | - mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
|
---|
| 312 | - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 313 | - ERROR2;
|
---|
| 314 | - mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
|
---|
| 315 | - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 316 | - ERROR2;
|
---|
| 317 | - mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
|
---|
| 318 | - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 319 | - ERROR2;
|
---|
| 320 | - mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
|
---|
| 321 | - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 322 | - ERROR2;
|
---|
| 323 | - mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
|
---|
| 324 | - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 325 | - ERROR2;
|
---|
| 326 | - mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
|
---|
| 327 | - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 328 | - ERROR2;
|
---|
| 329 | -
|
---|
| 330 | - mpfr_set_si (x, 1, MPFR_RNDN);
|
---|
| 331 | - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 332 | - ERROR2;
|
---|
| 333 | - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 334 | - ERROR2;
|
---|
| 335 | -
|
---|
| 336 | - /* Check negative value */
|
---|
| 337 | - mpfr_set_si (x, -1, MPFR_RNDN);
|
---|
| 338 | - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
|
---|
| 339 | - ERROR2;
|
---|
| 340 | - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
|
---|
| 341 | - ERROR2;
|
---|
| 342 | - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
|
---|
| 343 | - ERROR2;
|
---|
| 344 | - if (mpfr_fits_uint_p (x, MPFR_RNDN))
|
---|
| 345 | - ERROR1;
|
---|
| 346 | - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
|
---|
| 347 | - ERROR1;
|
---|
| 348 | - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
|
---|
| 349 | - ERROR1;
|
---|
| 350 | + RND_LOOP (r)
|
---|
| 351 | + {
|
---|
| 352 | +
|
---|
| 353 | + /* Check NAN */
|
---|
| 354 | + mpfr_set_nan (x);
|
---|
| 355 | + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 356 | + ERROR1 (1);
|
---|
| 357 | + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 358 | + ERROR1 (2);
|
---|
| 359 | + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 360 | + ERROR1 (3);
|
---|
| 361 | + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 362 | + ERROR1 (4);
|
---|
| 363 | + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 364 | + ERROR1 (5);
|
---|
| 365 | + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 366 | + ERROR1 (6);
|
---|
| 367 | +
|
---|
| 368 | + /* Check INF */
|
---|
| 369 | + mpfr_set_inf (x, 1);
|
---|
| 370 | + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 371 | + ERROR1 (7);
|
---|
| 372 | + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 373 | + ERROR1 (8);
|
---|
| 374 | + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 375 | + ERROR1 (9);
|
---|
| 376 | + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 377 | + ERROR1 (10);
|
---|
| 378 | + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 379 | + ERROR1 (11);
|
---|
| 380 | + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 381 | + ERROR1 (12);
|
---|
| 382 | +
|
---|
| 383 | + /* Check Zero */
|
---|
| 384 | + MPFR_SET_ZERO (x);
|
---|
| 385 | + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 386 | + ERROR1 (13);
|
---|
| 387 | + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 388 | + ERROR1 (14);
|
---|
| 389 | + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 390 | + ERROR1 (15);
|
---|
| 391 | + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 392 | + ERROR1 (16);
|
---|
| 393 | + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 394 | + ERROR1 (17);
|
---|
| 395 | + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 396 | + ERROR1 (18);
|
---|
| 397 | +
|
---|
| 398 | + /* Check small positive op */
|
---|
| 399 | + mpfr_set_str1 (x, "1@-1");
|
---|
| 400 | + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 401 | + ERROR1 (19);
|
---|
| 402 | + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 403 | + ERROR1 (20);
|
---|
| 404 | + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 405 | + ERROR1 (21);
|
---|
| 406 | + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 407 | + ERROR1 (22);
|
---|
| 408 | + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 409 | + ERROR1 (23);
|
---|
| 410 | + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 411 | + ERROR1 (24);
|
---|
| 412 | +
|
---|
| 413 | + /* Check 17 */
|
---|
| 414 | + mpfr_set_ui (x, 17, MPFR_RNDN);
|
---|
| 415 | + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 416 | + ERROR1 (25);
|
---|
| 417 | + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 418 | + ERROR1 (26);
|
---|
| 419 | + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 420 | + ERROR1 (27);
|
---|
| 421 | + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 422 | + ERROR1 (28);
|
---|
| 423 | + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 424 | + ERROR1 (29);
|
---|
| 425 | + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 426 | + ERROR1 (30);
|
---|
| 427 | +
|
---|
| 428 | + /* Check all other values */
|
---|
| 429 | + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
|
---|
| 430 | + mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
|
---|
| 431 | + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 432 | + ERROR1 (31);
|
---|
| 433 | + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 434 | + ERROR1 (32);
|
---|
| 435 | + mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
|
---|
| 436 | + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 437 | + ERROR1 (33);
|
---|
| 438 | + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 439 | + ERROR1 (34);
|
---|
| 440 | + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 441 | + ERROR1 (35);
|
---|
| 442 | + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 443 | + ERROR1 (36);
|
---|
| 444 | + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 445 | + ERROR1 (37);
|
---|
| 446 | +
|
---|
| 447 | + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
|
---|
| 448 | + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
|
---|
| 449 | + ERROR1 (38);
|
---|
| 450 | + mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
|
---|
| 451 | + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 452 | + ERROR1 (39);
|
---|
| 453 | + mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
|
---|
| 454 | + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
|
---|
| 455 | + ERROR1 (40);
|
---|
| 456 | + mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
|
---|
| 457 | + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 458 | + ERROR1 (41);
|
---|
| 459 | + mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
|
---|
| 460 | + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
|
---|
| 461 | + ERROR1 (42);
|
---|
| 462 | + mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
|
---|
| 463 | + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 464 | + ERROR1 (43);
|
---|
| 465 | +
|
---|
| 466 | + mpfr_set_si (x, 1, MPFR_RNDN);
|
---|
| 467 | + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 468 | + ERROR1 (44);
|
---|
| 469 | + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 470 | + ERROR1 (45);
|
---|
| 471 | +
|
---|
| 472 | + /* Check negative op */
|
---|
| 473 | + for (i = 1; i <= 4; i++)
|
---|
| 474 | + {
|
---|
| 475 | + int inv;
|
---|
| 476 | +
|
---|
| 477 | + mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
|
---|
| 478 | + mpfr_rint (y, x, (mpfr_rnd_t) r);
|
---|
| 479 | + inv = MPFR_NOTZERO (y);
|
---|
| 480 | + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r) ^ inv)
|
---|
| 481 | + ERROR1 (46);
|
---|
| 482 | + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
|
---|
| 483 | + ERROR1 (47);
|
---|
| 484 | + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r) ^ inv)
|
---|
| 485 | + ERROR1 (48);
|
---|
| 486 | + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
|
---|
| 487 | + ERROR1 (49);
|
---|
| 488 | + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r) ^ inv)
|
---|
| 489 | + ERROR1 (50);
|
---|
| 490 | + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
|
---|
| 491 | + ERROR1 (51);
|
---|
| 492 | + }
|
---|
| 493 | + }
|
---|
| 494 |
|
---|
| 495 | mpfr_clear (x);
|
---|
| 496 | + mpfr_clear (y);
|
---|
| 497 |
|
---|
| 498 | check_intmax ();
|
---|
| 499 |
|
---|
| 500 | @@ -189,85 +210,98 @@
|
---|
| 501 | return 0;
|
---|
| 502 | }
|
---|
| 503 |
|
---|
| 504 | -static void check_intmax (void)
|
---|
| 505 | +static void
|
---|
| 506 | +check_intmax (void)
|
---|
| 507 | {
|
---|
| 508 | #ifdef _MPFR_H_HAVE_INTMAX_T
|
---|
| 509 | - mpfr_t x;
|
---|
| 510 | + mpfr_t x, y;
|
---|
| 511 | + int i, r;
|
---|
| 512 |
|
---|
| 513 | - mpfr_init2 (x, sizeof (uintmax_t)*CHAR_BIT);
|
---|
| 514 | + mpfr_init2 (x, sizeof (uintmax_t) * CHAR_BIT);
|
---|
| 515 | + mpfr_init2 (y, 8);
|
---|
| 516 |
|
---|
| 517 | - /* Check NAN */
|
---|
| 518 | - mpfr_set_nan (x);
|
---|
| 519 | - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 520 | - ERROR1;
|
---|
| 521 | - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 522 | - ERROR1;
|
---|
| 523 | -
|
---|
| 524 | - /* Check INF */
|
---|
| 525 | - mpfr_set_inf (x, 1);
|
---|
| 526 | - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 527 | - ERROR1;
|
---|
| 528 | - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 529 | - ERROR1;
|
---|
| 530 | -
|
---|
| 531 | - /* Check Zero */
|
---|
| 532 | - MPFR_SET_ZERO (x);
|
---|
| 533 | - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 534 | - ERROR2;
|
---|
| 535 | - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 536 | - ERROR2;
|
---|
| 537 | -
|
---|
| 538 | - /* Check small op */
|
---|
| 539 | - mpfr_set_str1 (x, "1@-1");
|
---|
| 540 | - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 541 | - ERROR2;
|
---|
| 542 | - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 543 | - ERROR2;
|
---|
| 544 | -
|
---|
| 545 | - /* Check 17 */
|
---|
| 546 | - mpfr_set_ui (x, 17, MPFR_RNDN);
|
---|
| 547 | - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 548 | - ERROR2;
|
---|
| 549 | - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 550 | - ERROR2;
|
---|
| 551 | -
|
---|
| 552 | - /* Check hugest */
|
---|
| 553 | - mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
|
---|
| 554 | - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 555 | - ERROR1;
|
---|
| 556 | - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 557 | - ERROR1;
|
---|
| 558 | -
|
---|
| 559 | - /* Check all other values */
|
---|
| 560 | - mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
|
---|
| 561 | - mpfr_add_ui (x, x, 1, MPFR_RNDN);
|
---|
| 562 | - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 563 | - ERROR1;
|
---|
| 564 | - mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
|
---|
| 565 | - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 566 | - ERROR2;
|
---|
| 567 | - mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
|
---|
| 568 | - mpfr_add_ui (x, x, 1, MPFR_RNDN);
|
---|
| 569 | - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 570 | - ERROR1;
|
---|
| 571 | - mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
|
---|
| 572 | - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 573 | - ERROR2;
|
---|
| 574 | - mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
|
---|
| 575 | - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 576 | - ERROR2;
|
---|
| 577 | - mpfr_sub_ui (x, x, 1, MPFR_RNDN);
|
---|
| 578 | - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 579 | - ERROR1;
|
---|
| 580 | -
|
---|
| 581 | - /* Check negative value */
|
---|
| 582 | - mpfr_set_si (x, -1, MPFR_RNDN);
|
---|
| 583 | - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
|
---|
| 584 | - ERROR2;
|
---|
| 585 | - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
|
---|
| 586 | - ERROR1;
|
---|
| 587 | + RND_LOOP (r)
|
---|
| 588 | + {
|
---|
| 589 | + /* Check NAN */
|
---|
| 590 | + mpfr_set_nan (x);
|
---|
| 591 | + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 592 | + ERROR1 (52);
|
---|
| 593 | + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 594 | + ERROR1 (53);
|
---|
| 595 | +
|
---|
| 596 | + /* Check INF */
|
---|
| 597 | + mpfr_set_inf (x, 1);
|
---|
| 598 | + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 599 | + ERROR1 (54);
|
---|
| 600 | + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 601 | + ERROR1 (55);
|
---|
| 602 | +
|
---|
| 603 | + /* Check Zero */
|
---|
| 604 | + MPFR_SET_ZERO (x);
|
---|
| 605 | + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 606 | + ERROR1 (56);
|
---|
| 607 | + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 608 | + ERROR1 (57);
|
---|
| 609 | +
|
---|
| 610 | + /* Check positive small op */
|
---|
| 611 | + mpfr_set_str1 (x, "1@-1");
|
---|
| 612 | + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 613 | + ERROR1 (58);
|
---|
| 614 | + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 615 | + ERROR1 (59);
|
---|
| 616 | +
|
---|
| 617 | + /* Check 17 */
|
---|
| 618 | + mpfr_set_ui (x, 17, MPFR_RNDN);
|
---|
| 619 | + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 620 | + ERROR1 (60);
|
---|
| 621 | + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 622 | + ERROR1 (61);
|
---|
| 623 | +
|
---|
| 624 | + /* Check hugest */
|
---|
| 625 | + mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
|
---|
| 626 | + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 627 | + ERROR1 (62);
|
---|
| 628 | + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 629 | + ERROR1 (63);
|
---|
| 630 | +
|
---|
| 631 | + /* Check all other values */
|
---|
| 632 | + mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
|
---|
| 633 | + mpfr_add_ui (x, x, 1, MPFR_RNDN);
|
---|
| 634 | + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 635 | + ERROR1 (64);
|
---|
| 636 | + mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
|
---|
| 637 | + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
|
---|
| 638 | + ERROR1 (65);
|
---|
| 639 | + mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
|
---|
| 640 | + mpfr_add_ui (x, x, 1, MPFR_RNDN);
|
---|
| 641 | + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 642 | + ERROR1 (66);
|
---|
| 643 | + mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
|
---|
| 644 | + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 645 | + ERROR1 (67);
|
---|
| 646 | + mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
|
---|
| 647 | + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 648 | + ERROR1 (68);
|
---|
| 649 | + mpfr_sub_ui (x, x, 1, MPFR_RNDN);
|
---|
| 650 | + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 651 | + ERROR1 (69);
|
---|
| 652 | +
|
---|
| 653 | + /* Check negative op */
|
---|
| 654 | + for (i = 1; i <= 4; i++)
|
---|
| 655 | + {
|
---|
| 656 | + int inv;
|
---|
| 657 | +
|
---|
| 658 | + mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
|
---|
| 659 | + mpfr_rint (y, x, (mpfr_rnd_t) r);
|
---|
| 660 | + inv = MPFR_NOTZERO (y);
|
---|
| 661 | + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r) ^ inv)
|
---|
| 662 | + ERROR1 (70);
|
---|
| 663 | + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
|
---|
| 664 | + ERROR1 (71);
|
---|
| 665 | + }
|
---|
| 666 | + }
|
---|
| 667 |
|
---|
| 668 | mpfr_clear (x);
|
---|
| 669 | + mpfr_clear (y);
|
---|
| 670 | #endif
|
---|
| 671 | }
|
---|
| 672 | -
|
---|
| 673 | diff -Naur mpfr-3.1.2.orig/tests/tget_flt.c mpfr-3.1.2/tests/tget_flt.c
|
---|
| 674 | --- mpfr-3.1.2.orig/tests/tget_flt.c 2013-03-13 15:37:44.000000000 +0000
|
---|
| 675 | +++ mpfr-3.1.2/tests/tget_flt.c 2013-11-11 23:55:16.818732551 +0000
|
---|
| 676 | @@ -28,9 +28,17 @@
|
---|
| 677 | main (void)
|
---|
| 678 | {
|
---|
| 679 | mpfr_t x, y;
|
---|
| 680 | - float f, g, infp;
|
---|
| 681 | + float f, g;
|
---|
| 682 | int i;
|
---|
| 683 | +#if !defined(MPFR_ERRDIVZERO)
|
---|
| 684 | + float infp;
|
---|
| 685 | +#endif
|
---|
| 686 |
|
---|
| 687 | + tests_start_mpfr ();
|
---|
| 688 | +
|
---|
| 689 | +#if !defined(MPFR_ERRDIVZERO)
|
---|
| 690 | + /* The definition of DBL_POS_INF involves a division by 0. This makes
|
---|
| 691 | + "clang -O2 -fsanitize=undefined -fno-sanitize-recover" fail. */
|
---|
| 692 | infp = (float) DBL_POS_INF;
|
---|
| 693 | if (infp * 0.5 != infp)
|
---|
| 694 | {
|
---|
| 695 | @@ -38,8 +46,7 @@
|
---|
| 696 | fprintf (stderr, "(this is probably a compiler bug, please report)\n");
|
---|
| 697 | exit (1);
|
---|
| 698 | }
|
---|
| 699 | -
|
---|
| 700 | - tests_start_mpfr ();
|
---|
| 701 | +#endif
|
---|
| 702 |
|
---|
| 703 | mpfr_init2 (x, 24);
|
---|
| 704 | mpfr_init2 (y, 24);
|
---|
| 705 | @@ -353,6 +360,7 @@
|
---|
| 706 | printf ("expected %.8e, got %.8e\n", g, f);
|
---|
| 707 | exit (1);
|
---|
| 708 | }
|
---|
| 709 | +#if !defined(MPFR_ERRDIVZERO)
|
---|
| 710 | f = mpfr_get_flt (x, MPFR_RNDN); /* first round to 2^128 (even rule),
|
---|
| 711 | thus we should get +Inf */
|
---|
| 712 | g = infp;
|
---|
| 713 | @@ -376,6 +384,7 @@
|
---|
| 714 | printf ("expected %.8e, got %.8e\n", g, f);
|
---|
| 715 | exit (1);
|
---|
| 716 | }
|
---|
| 717 | +#endif
|
---|
| 718 |
|
---|
| 719 | mpfr_clear (x);
|
---|
| 720 | mpfr_clear (y);
|
---|
| 721 | diff -Naur mpfr-3.1.2.orig/tests/tset_ld.c mpfr-3.1.2/tests/tset_ld.c
|
---|
| 722 | --- mpfr-3.1.2.orig/tests/tset_ld.c 2013-03-13 15:37:44.000000000 +0000
|
---|
| 723 | +++ mpfr-3.1.2/tests/tset_ld.c 2013-11-11 23:55:16.818732551 +0000
|
---|
| 724 | @@ -47,8 +47,11 @@
|
---|
| 725 | static int
|
---|
| 726 | Isnan_ld (long double d)
|
---|
| 727 | {
|
---|
| 728 | - double e = (double) d;
|
---|
| 729 | - if (DOUBLE_ISNAN (e))
|
---|
| 730 | + /* Do not convert d to double as this can give an overflow, which
|
---|
| 731 | + may confuse compilers without IEEE 754 support (such as clang
|
---|
| 732 | + -fsanitize=undefined), or trigger a trap if enabled.
|
---|
| 733 | + The DOUBLE_ISNAN macro should work fine on long double. */
|
---|
| 734 | + if (DOUBLE_ISNAN (d))
|
---|
| 735 | return 1;
|
---|
| 736 | LONGDOUBLE_NAN_ACTION (d, goto yes);
|
---|
| 737 | return 0;
|
---|