1 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
2 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:40:40.079363480 +0000
3 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:40:40.119363040 +0000
6 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
7 --- mpfr-4.1.0-a/VERSION 2020-07-10 11:52:33.000000000 +0000
8 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:40:40.119363040 +0000
12 diff -Naurd mpfr-4.1.0-a/src/get_d128.c mpfr-4.1.0-b/src/get_d128.c
13 --- mpfr-4.1.0-a/src/get_d128.c 2020-04-08 22:39:35.000000000 +0000
14 +++ mpfr-4.1.0-b/src/get_d128.c 2021-02-11 12:40:40.103363216 +0000
17 get_decimal128_nan (void)
19 - return (_Decimal128) MPFR_DBL_NAN;
20 + return 0.0dl / 0.0dl;
23 /* construct the decimal128 Inf with given sign */
25 get_decimal128_inf (int negative)
27 - return (_Decimal128) (negative ? MPFR_DBL_INFM : MPFR_DBL_INFP);
28 + return negative ? - 1.0dl / 0.0dl : 1.0dl / 0.0dl;
31 /* construct the decimal128 zero with given sign */
33 get_decimal128_zero (int negative)
35 - _Decimal128 zero = 0;
36 - return (_Decimal128) (negative ? -zero : zero);
37 + return negative ? - 0.0dl : 0.0dl;
40 /* construct the decimal128 smallest non-zero with given sign:
41 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
42 --- mpfr-4.1.0-a/src/mpfr.h 2020-07-10 11:52:33.000000000 +0000
43 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:40:40.115363084 +0000
45 #define MPFR_VERSION_MAJOR 4
46 #define MPFR_VERSION_MINOR 1
47 #define MPFR_VERSION_PATCHLEVEL 0
48 -#define MPFR_VERSION_STRING "4.1.0"
49 +#define MPFR_VERSION_STRING "4.1.0-p1"
52 MPFR_USE_FILE: Define it to make MPFR define functions dealing
53 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
54 --- mpfr-4.1.0-a/src/version.c 2020-07-10 11:52:33.000000000 +0000
55 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:40:40.119363040 +0000
58 mpfr_get_version (void)
63 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
64 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:43:51.761257868 +0000
65 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:43:51.801257430 +0000
68 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
69 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:40:40.119363040 +0000
70 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:43:51.801257430 +0000
74 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
75 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:40:40.115363084 +0000
76 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:43:51.801257430 +0000
78 #define MPFR_VERSION_MAJOR 4
79 #define MPFR_VERSION_MINOR 1
80 #define MPFR_VERSION_PATCHLEVEL 0
81 -#define MPFR_VERSION_STRING "4.1.0-p1"
82 +#define MPFR_VERSION_STRING "4.1.0-p2"
85 MPFR_USE_FILE: Define it to make MPFR define functions dealing
86 diff -Naurd mpfr-4.1.0-a/src/random_deviate.c mpfr-4.1.0-b/src/random_deviate.c
87 --- mpfr-4.1.0-a/src/random_deviate.c 2020-01-08 18:11:13.000000000 +0000
88 +++ mpfr-4.1.0-b/src/random_deviate.c 2021-02-11 12:43:51.789257562 +0000
90 mpfr_random_size_t p = mpfr_get_prec (z); /* Number of bits in result */
98 mpz_setbit (t, 0); /* Set the trailing bit so result is always inexact */
101 - /* Is -x->e representable as a mpfr_exp_t? */
102 - MPFR_ASSERTN (x->e <= (mpfr_uexp_t)(-1) >> 1);
103 + /* Portable version of the negation of x->e, with a check of overflow. */
104 + if (MPFR_UNLIKELY (x->e > MPFR_EXP_MAX))
106 + /* Overflow, except when x->e = MPFR_EXP_MAX + 1 = - MPFR_EXP_MIN. */
107 + MPFR_ASSERTN (MPFR_EXP_MIN + MPFR_EXP_MAX == -1 &&
108 + x->e == (mpfr_random_size_t) MPFR_EXP_MAX + 1);
109 + negxe = MPFR_EXP_MIN;
112 + negxe = - (mpfr_exp_t) x->e;
114 * Let mpfr_set_z_2exp do all the work of rounding to the requested
115 * precision, setting overflow/underflow flags, and returning the right
118 - inex = mpfr_set_z_2exp (z, t, -x->e, rnd);
119 + inex = mpfr_set_z_2exp (z, t, negxe, rnd);
123 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
124 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:40:40.119363040 +0000
125 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:43:51.801257430 +0000
128 mpfr_get_version (void)
133 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
134 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:46:49.075316772 +0000
135 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:46:49.115316335 +0000
138 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
139 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:43:51.801257430 +0000
140 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:46:49.115316335 +0000
144 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
145 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:43:51.801257430 +0000
146 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:46:49.115316335 +0000
148 #define MPFR_VERSION_MAJOR 4
149 #define MPFR_VERSION_MINOR 1
150 #define MPFR_VERSION_PATCHLEVEL 0
151 -#define MPFR_VERSION_STRING "4.1.0-p2"
152 +#define MPFR_VERSION_STRING "4.1.0-p3"
155 MPFR_USE_FILE: Define it to make MPFR define functions dealing
156 diff -Naurd mpfr-4.1.0-a/src/set_z_exp.c mpfr-4.1.0-b/src/set_z_exp.c
157 --- mpfr-4.1.0-a/src/set_z_exp.c 2020-01-08 18:11:13.000000000 +0000
158 +++ mpfr-4.1.0-b/src/set_z_exp.c 2021-02-11 12:46:49.103316466 +0000
161 mpfr_set_z_2exp (mpfr_ptr f, mpz_srcptr z, mpfr_exp_t e, mpfr_rnd_t rnd_mode)
163 - mp_size_t fn, zn, dif, en;
164 + mp_size_t fn, zn, dif;
168 + mpfr_exp_t exp, nmax;
171 sign_z = mpz_sgn (z);
172 if (MPFR_UNLIKELY (sign_z == 0)) /* ignore the exponent for 0 */
174 MPFR_ASSERTD (sign_z == MPFR_SIGN_POS || sign_z == MPFR_SIGN_NEG);
176 zn = ABSIZ(z); /* limb size of z */
177 - /* compute en = floor(e/GMP_NUMB_BITS) */
178 - en = (e >= 0) ? e / GMP_NUMB_BITS : (e + 1) / GMP_NUMB_BITS - 1;
179 MPFR_ASSERTD (zn >= 1);
180 - if (MPFR_UNLIKELY (zn + en > MPFR_EMAX_MAX / GMP_NUMB_BITS + 1))
181 + nmax = MPFR_EMAX_MAX / GMP_NUMB_BITS + 1;
182 + /* Detect early overflow with zn + en > nmax,
183 + where en = floor(e / GMP_NUMB_BITS).
184 + This is checked without an integer overflow (even assuming some
185 + future version of GMP, where limitations may be removed). */
186 + if (MPFR_UNLIKELY (e >= 0 ?
187 + zn > nmax - e / GMP_NUMB_BITS :
188 + zn + (e + 1) / GMP_NUMB_BITS - 1 > nmax))
189 return mpfr_overflow (f, rnd_mode, sign_z);
190 /* because zn + en >= MPFR_EMAX_MAX / GMP_NUMB_BITS + 2
191 implies (zn + en) * GMP_NUMB_BITS >= MPFR_EMAX_MAX + GMP_NUMB_BITS + 1
193 and exp = zn * GMP_NUMB_BITS + e - k
194 <= (zn + en) * GMP_NUMB_BITS - k + GMP_NUMB_BITS - 1
195 <= MPFR_EMAX_MAX + 2 * GMP_NUMB_BITS - 1 */
196 - exp = (mpfr_prec_t) zn * GMP_NUMB_BITS + e - k;
197 + /* We need to compute exp = zn * GMP_NUMB_BITS + e - k with well-defined
198 + operations (no integer overflows / no implementation-defined results).
199 + The mathematical result of zn * GMP_NUMB_BITS may be larger than
200 + the largest value of mpfr_exp_t while exp could still be less than
201 + __gmpfr_emax. Thanks to early overflow detection, we can compute the
202 + result in modular arithmetic, using mpfr_uexp_t, and convert it to
204 + uexp = (mpfr_uexp_t) zn * GMP_NUMB_BITS + (mpfr_uexp_t) e - k;
206 + /* Convert to signed in a portable way (see doc/README.dev).
207 + On most platforms, this can be optimized to identity (no-op). */
208 + exp = uexp > MPFR_EXP_MAX ? -1 - (mpfr_exp_t) ~uexp : (mpfr_exp_t) uexp;
210 /* The exponent will be exp or exp + 1 (due to rounding) */
212 if (MPFR_UNLIKELY (exp > __gmpfr_emax))
213 return mpfr_overflow (f, rnd_mode, sign_z);
214 if (MPFR_UNLIKELY (exp + 1 < __gmpfr_emin))
215 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
216 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:43:51.801257430 +0000
217 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:46:49.115316335 +0000
220 mpfr_get_version (void)
225 diff -Naurd mpfr-4.1.0-a/tests/tset_z_exp.c mpfr-4.1.0-b/tests/tset_z_exp.c
226 --- mpfr-4.1.0-a/tests/tset_z_exp.c 2020-01-08 18:11:13.000000000 +0000
227 +++ mpfr-4.1.0-b/tests/tset_z_exp.c 2021-02-11 12:46:49.103316466 +0000
229 mpfr_get_si is a rather indirect test of a low level routine. */
232 -check (long i, mpfr_rnd_t rnd)
233 +check (long i, mpfr_rnd_t rnd, int reduced)
239 + mpfr_exp_t e, old_emin, old_emax;
241 + mpfr_flags_t flags;
243 + old_emin = mpfr_get_emin ();
244 + old_emax = mpfr_get_emax ();
246 /* using CHAR_BIT * sizeof(long) bits of precision ensures that
247 mpfr_set_z_2exp is exact below */
248 - mpfr_init2 (f, CHAR_BIT * sizeof(long));
249 + mpfr_inits2 (CHAR_BIT * sizeof(long), f1, f2, f3, (mpfr_ptr) 0);
252 /* the following loop ensures that no overflow occurs */
255 while (e > mpfr_get_emax () - CHAR_BIT * sizeof(long));
256 - inex = mpfr_set_z_2exp (f, z, e, rnd);
259 + mpfr_clear_flags ();
260 + inex = mpfr_set_z_2exp (f1, z, e, rnd);
261 + flags = __gmpfr_flags;
263 + if (inex != 0 || flags != 0 ||
264 + (mpfr_div_2si (f2, f1, e, rnd), mpfr_get_si (f2, MPFR_RNDZ) != i))
266 - printf ("Error in mpfr_set_z_2exp for i=%ld, e=%ld,"
267 - " wrong ternary value\n", i, (long) e);
268 - printf ("expected 0, got %d\n", inex);
269 + printf ("Error in mpfr_set_z_2exp for i=%ld e=%" MPFR_EXP_FSPEC
270 + "d rnd_mode=%d\n", i, (mpfr_eexp_t) e, rnd);
271 + mpfr_set_si_2exp (f2, i, e, MPFR_RNDN);
272 + printf ("expected "); mpfr_dump (f2);
273 + printf ("with inex = %d and flags =", 0);
275 + printf ("got "); mpfr_dump (f1);
276 + printf ("with inex = %d and flags =", inex);
280 - mpfr_div_2si (f, f, e, rnd);
281 - if (mpfr_get_si (f, MPFR_RNDZ) != i)
285 - printf ("Error in mpfr_set_z_2exp for i=%ld e=", i);
287 - printf ("(<LONG_MIN)");
288 - else if (e > LONG_MAX)
289 - printf ("(>LONG_MAX)");
291 - printf ("%ld", (long) e);
292 - printf (" rnd_mode=%d\n", rnd);
293 - printf ("expected %ld\n", i);
294 - printf ("got "); mpfr_dump (f);
296 + mpfr_exp_t ef, emin, emax;
298 + mpfr_flags_t flags2, flags3;
300 + ef = i == 0 ? 0 : mpfr_get_exp (f1);
301 + for (emin = ef - 2; emin <= ef + 2; emin++)
302 + for (emax = emin; emax <= ef + 2; emax++)
304 + inex3 = mpfr_set (f3, f1, rnd);
305 + MPFR_ASSERTN (inex3 == 0);
306 + mpfr_set_emin (emin);
307 + mpfr_set_emax (emax);
308 + mpfr_clear_flags ();
309 + inex2 = mpfr_set_z_2exp (f2, z, e, rnd);
310 + flags2 = __gmpfr_flags;
311 + mpfr_clear_flags ();
312 + inex3 = mpfr_check_range (f3, 0, rnd);
313 + flags3 = __gmpfr_flags;
314 + if (!(mpfr_equal_p (f2, f3) &&
315 + SAME_SIGN (inex2, inex3) &&
318 + printf ("Error in mpfr_set_z_2exp for i=%ld e=%"
319 + MPFR_EXP_FSPEC "d rnd_mode=%d\nand emin=%"
320 + MPFR_EXP_FSPEC "d emax=%" MPFR_EXP_FSPEC
321 + "d\n", i, (mpfr_eexp_t) e, rnd,
322 + (mpfr_eexp_t) emin, (mpfr_eexp_t) emax);
323 + printf ("expected "); mpfr_dump (f3);
324 + printf ("with inex = %d and flags =", inex3);
325 + flags_out (flags3);
326 + printf ("got "); mpfr_dump (f2);
327 + printf ("with inex = %d and flags =", inex2);
328 + flags_out (flags2);
332 + mpfr_set_emin (old_emin);
333 + mpfr_set_emax (old_emax);
337 + mpfr_clears (f1, f2, f3, (mpfr_ptr) 0);
344 + if (getenv ("MPFR_CHECK_LARGEMEM") != NULL)
350 + /* Increase tests_memory_limit to the maximum in order to avoid
351 + an obvious failure due to insufficient memory. */
352 + tests_memory_limit = (size_t) -1; /* no memory limit */
354 + mpfr_init2 (x, 32);
356 + /* In r14140, with a 32-bit ABI (GCC's -m32):
357 + - With UBsan (-fsanitize=undefined -fno-sanitize-recover),
359 + set_z_2exp.c:71:26: runtime error: signed integer overflow:
360 + 67108864 * 32 cannot be represented in type 'long int'
361 + - With -D_MPFR_EXP_FORMAT=4, this fails with:
362 + Expected 0.10001000000000000000000000000000E5
365 + mpz_init_set_ui (z, 17);
367 + mpz_mul_2exp (z, z, e);
368 + mpz_add_ui (z, z, 1);
369 + mpfr_set_z_2exp (x, z, -e, MPFR_RNDN);
370 + if (mpfr_cmp_ui0 (x, 17) != 0)
372 + printf ("Error 1 in check_huge\n");
373 + printf ("Expected 0.10001000000000000000000000000000E5\n");
380 + mpz_init_set_ui (z, 17);
381 + mpz_mul_2exp (z, z, 0xffffffb0);
382 + mpz_add_ui (z, z, 1);
383 + mpfr_set_z_2exp (x, z, -1, MPFR_RNDN);
384 + if (! MPFR_IS_INF (x) || MPFR_IS_NEG (x))
386 + printf ("Error 2 in check_huge\n");
387 + printf ("Expected @Inf@\n");
399 main (int argc, char *argv[])
401 @@ -147,11 +247,13 @@
405 - check (0, MPFR_RNDN);
406 + check (0, MPFR_RNDN, 0);
407 for (j = 0; j < 200000; j++)
408 - check (randlimb () & LONG_MAX, RND_RAND ());
409 + check (randlimb () & LONG_MAX, RND_RAND (), j < 200);
417 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
418 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:48:27.322243271 +0000
419 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:48:27.370242746 +0000
422 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
423 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:46:49.115316335 +0000
424 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:48:27.370242746 +0000
428 diff -Naurd mpfr-4.1.0-a/src/atan.c mpfr-4.1.0-b/src/atan.c
429 --- mpfr-4.1.0-a/src/atan.c 2020-04-22 15:27:07.000000000 +0000
430 +++ mpfr-4.1.0-b/src/atan.c 2021-02-11 12:48:27.354242922 +0000
435 -set_table (mpfr_t y, const mp_limb_t x[3])
436 +set_table (mpfr_ptr y, const mp_limb_t x[3])
438 mpfr_prec_t p = MPFR_PREC(y);
439 mp_size_t n = MPFR_PREC2LIMBS(p);
440 diff -Naurd mpfr-4.1.0-a/src/const_euler.c mpfr-4.1.0-b/src/const_euler.c
441 --- mpfr-4.1.0-a/src/const_euler.c 2020-01-08 18:11:13.000000000 +0000
442 +++ mpfr-4.1.0-b/src/const_euler.c 2021-02-11 12:48:27.354242922 +0000
447 -mpfr_const_euler_internal (mpfr_t x, mpfr_rnd_t rnd)
448 +mpfr_const_euler_internal (mpfr_ptr x, mpfr_rnd_t rnd)
450 mpfr_const_euler_bs_t sum;
452 diff -Naurd mpfr-4.1.0-a/src/eint.c mpfr-4.1.0-b/src/eint.c
453 --- mpfr-4.1.0-a/src/eint.c 2020-03-09 15:31:45.000000000 +0000
454 +++ mpfr-4.1.0-b/src/eint.c 2021-02-11 12:48:27.354242922 +0000
456 Return PREC(y) when the truncated series does not converge.
459 -mpfr_eint_aux (mpfr_t y, mpfr_srcptr x)
460 +mpfr_eint_aux (mpfr_ptr y, mpfr_srcptr x)
462 mpfr_t eps; /* dynamic (absolute) error bound on t */
464 diff -Naurd mpfr-4.1.0-a/src/erandom.c mpfr-4.1.0-b/src/erandom.c
465 --- mpfr-4.1.0-a/src/erandom.c 2020-01-08 18:11:13.000000000 +0000
466 +++ mpfr-4.1.0-b/src/erandom.c 2021-02-11 12:48:27.354242922 +0000
469 /* return an exponential random deviate with mean 1 as a MPFR */
471 -mpfr_erandom (mpfr_t z, gmp_randstate_t r, mpfr_rnd_t rnd)
472 +mpfr_erandom (mpfr_ptr z, gmp_randstate_t r, mpfr_rnd_t rnd)
474 mpfr_random_deviate_t x, p, q;
476 diff -Naurd mpfr-4.1.0-a/src/fpif.c mpfr-4.1.0-b/src/fpif.c
477 --- mpfr-4.1.0-a/src/fpif.c 2020-01-08 18:11:13.000000000 +0000
478 +++ mpfr-4.1.0-b/src/fpif.c 2021-02-11 12:48:27.354242922 +0000
480 * until one has integer types larger than 128 bits).
482 static unsigned char*
483 -mpfr_fpif_store_exponent (unsigned char *buffer, size_t *buffer_size, mpfr_t x)
484 +mpfr_fpif_store_exponent (unsigned char *buffer, size_t *buffer_size,
487 unsigned char *result;
493 -mpfr_fpif_read_exponent_from_file (mpfr_t x, FILE * fh)
494 +mpfr_fpif_read_exponent_from_file (mpfr_ptr x, FILE * fh)
501 static unsigned char*
502 -mpfr_fpif_store_limbs (unsigned char *buffer, size_t *buffer_size, mpfr_t x)
503 +mpfr_fpif_store_limbs (unsigned char *buffer, size_t *buffer_size, mpfr_ptr x)
505 unsigned char *result;
506 mpfr_prec_t precision;
508 * Assume buffer is not NULL.
511 -mpfr_fpif_read_limbs (mpfr_t x, unsigned char *buffer, size_t nb_byte)
512 +mpfr_fpif_read_limbs (mpfr_ptr x, unsigned char *buffer, size_t nb_byte)
514 size_t mp_bytes_per_limb;
515 size_t nb_partial_byte;
517 * return 0 if successful
520 -mpfr_fpif_export (FILE *fh, mpfr_t x)
521 +mpfr_fpif_export (FILE *fh, mpfr_ptr x)
526 * Return 0 if the import was successful.
529 -mpfr_fpif_import (mpfr_t x, FILE *fh)
530 +mpfr_fpif_import (mpfr_ptr x, FILE *fh)
533 mpfr_prec_t precision;
534 diff -Naurd mpfr-4.1.0-a/src/li2.c mpfr-4.1.0-b/src/li2.c
535 --- mpfr-4.1.0-a/src/li2.c 2020-01-08 18:11:13.000000000 +0000
536 +++ mpfr-4.1.0-b/src/li2.c 2021-02-11 12:48:27.354242922 +0000
538 for determinating the relative error.
541 -li2_series (mpfr_t sum, mpfr_srcptr z, mpfr_rnd_t rnd_mode)
542 +li2_series (mpfr_ptr sum, mpfr_srcptr z, mpfr_rnd_t rnd_mode)
546 diff -Naurd mpfr-4.1.0-a/src/lngamma.c mpfr-4.1.0-b/src/lngamma.c
547 --- mpfr-4.1.0-a/src/lngamma.c 2020-01-08 18:11:13.000000000 +0000
548 +++ mpfr-4.1.0-b/src/lngamma.c 2021-02-11 12:48:27.354242922 +0000
550 precision should be >= 4.
553 -mpfr_gamma_alpha (mpfr_t s, mpfr_prec_t p)
554 +mpfr_gamma_alpha (mpfr_ptr s, mpfr_prec_t p)
558 diff -Naurd mpfr-4.1.0-a/src/mpfr-impl.h mpfr-4.1.0-b/src/mpfr-impl.h
559 --- mpfr-4.1.0-a/src/mpfr-impl.h 2020-06-10 21:50:12.000000000 +0000
560 +++ mpfr-4.1.0-b/src/mpfr-impl.h 2021-02-11 12:48:27.354242922 +0000
561 @@ -2474,7 +2474,8 @@
562 __MPFR_DECLSPEC mpz_srcptr mpfr_bernoulli_cache (unsigned long);
563 __MPFR_DECLSPEC void mpfr_bernoulli_freecache (void);
565 -__MPFR_DECLSPEC int mpfr_sincos_fast (mpfr_t, mpfr_t, mpfr_srcptr, mpfr_rnd_t);
566 +__MPFR_DECLSPEC int mpfr_sincos_fast (mpfr_ptr, mpfr_ptr, mpfr_srcptr,
569 __MPFR_DECLSPEC double mpfr_scale2 (double, int);
571 @@ -2485,7 +2486,7 @@
574 __MPFR_DECLSPEC void mpfr_mpz_init (mpz_ptr);
575 -__MPFR_DECLSPEC void mpfr_mpz_init2 (mpz_t, mp_bitcnt_t);
576 +__MPFR_DECLSPEC void mpfr_mpz_init2 (mpz_ptr, mp_bitcnt_t);
577 __MPFR_DECLSPEC void mpfr_mpz_clear (mpz_ptr);
579 __MPFR_DECLSPEC int mpfr_odd_p (mpfr_srcptr);
580 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
581 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:46:49.115316335 +0000
582 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:48:27.366242791 +0000
584 #define MPFR_VERSION_MAJOR 4
585 #define MPFR_VERSION_MINOR 1
586 #define MPFR_VERSION_PATCHLEVEL 0
587 -#define MPFR_VERSION_STRING "4.1.0-p3"
588 +#define MPFR_VERSION_STRING "4.1.0-p4"
591 MPFR_USE_FILE: Define it to make MPFR define functions dealing
593 __MPFR_DECLSPEC int mpfr_strtofr (mpfr_ptr, const char *, char **, int,
596 -__MPFR_DECLSPEC void mpfr_round_nearest_away_begin (mpfr_t);
597 -__MPFR_DECLSPEC int mpfr_round_nearest_away_end (mpfr_t, int);
598 +__MPFR_DECLSPEC void mpfr_round_nearest_away_begin (mpfr_ptr);
599 +__MPFR_DECLSPEC int mpfr_round_nearest_away_end (mpfr_ptr, int);
601 __MPFR_DECLSPEC size_t mpfr_custom_get_size (mpfr_prec_t);
602 __MPFR_DECLSPEC void mpfr_custom_init (void *, mpfr_prec_t);
603 @@ -1080,10 +1080,12 @@
604 #define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
605 #define mpfr_get_sj __gmpfr_mpfr_get_sj
606 #define mpfr_get_uj __gmpfr_mpfr_get_uj
607 -__MPFR_DECLSPEC int mpfr_set_sj (mpfr_t, intmax_t, mpfr_rnd_t);
608 -__MPFR_DECLSPEC int mpfr_set_sj_2exp (mpfr_t, intmax_t, intmax_t, mpfr_rnd_t);
609 -__MPFR_DECLSPEC int mpfr_set_uj (mpfr_t, uintmax_t, mpfr_rnd_t);
610 -__MPFR_DECLSPEC int mpfr_set_uj_2exp (mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t);
611 +__MPFR_DECLSPEC int mpfr_set_sj (mpfr_ptr, intmax_t, mpfr_rnd_t);
612 +__MPFR_DECLSPEC int mpfr_set_sj_2exp (mpfr_ptr, intmax_t, intmax_t,
614 +__MPFR_DECLSPEC int mpfr_set_uj (mpfr_ptr, uintmax_t, mpfr_rnd_t);
615 +__MPFR_DECLSPEC int mpfr_set_uj_2exp (mpfr_ptr, uintmax_t, intmax_t,
617 __MPFR_DECLSPEC intmax_t mpfr_get_sj (mpfr_srcptr, mpfr_rnd_t);
618 __MPFR_DECLSPEC uintmax_t mpfr_get_uj (mpfr_srcptr, mpfr_rnd_t);
620 diff -Naurd mpfr-4.1.0-a/src/nrandom.c mpfr-4.1.0-b/src/nrandom.c
621 --- mpfr-4.1.0-a/src/nrandom.c 2020-01-08 18:11:13.000000000 +0000
622 +++ mpfr-4.1.0-b/src/nrandom.c 2021-02-11 12:48:27.354242922 +0000
625 /* return a normal random deviate with mean 0 and variance 1 as a MPFR */
627 -mpfr_nrandom (mpfr_t z, gmp_randstate_t r, mpfr_rnd_t rnd)
628 +mpfr_nrandom (mpfr_ptr z, gmp_randstate_t r, mpfr_rnd_t rnd)
630 mpfr_random_deviate_t x, p, q;
632 diff -Naurd mpfr-4.1.0-a/src/pool.c mpfr-4.1.0-b/src/pool.c
633 --- mpfr-4.1.0-a/src/pool.c 2020-01-08 18:11:13.000000000 +0000
634 +++ mpfr-4.1.0-b/src/pool.c 2021-02-11 12:48:27.354242922 +0000
636 static MPFR_THREAD_ATTR __mpz_struct mpz_tab[MPFR_POOL_NENTRIES];
638 MPFR_HOT_FUNCTION_ATTR void
639 -mpfr_mpz_init (mpz_t z)
640 +mpfr_mpz_init (mpz_ptr z)
642 if (MPFR_LIKELY (n_alloc > 0))
647 MPFR_HOT_FUNCTION_ATTR void
648 -mpfr_mpz_init2 (mpz_t z, mp_bitcnt_t n)
649 +mpfr_mpz_init2 (mpz_ptr z, mp_bitcnt_t n)
651 /* The condition on n is used below as the argument n will be ignored if
652 the mpz_t is obtained from the MPFR stack of previously used mpz_t.
656 MPFR_HOT_FUNCTION_ATTR void
657 -mpfr_mpz_clear (mpz_t z)
658 +mpfr_mpz_clear (mpz_ptr z)
660 /* We only put objects with at most MPFR_POOL_MAX_SIZE in the mpz_t pool,
661 to avoid it takes too much memory (and anyway the speedup is mainly
662 diff -Naurd mpfr-4.1.0-a/src/random_deviate.c mpfr-4.1.0-b/src/random_deviate.c
663 --- mpfr-4.1.0-a/src/random_deviate.c 2021-02-11 12:43:51.789257562 +0000
664 +++ mpfr-4.1.0-b/src/random_deviate.c 2021-02-11 12:48:27.354242922 +0000
667 /* allocate and set to (0,1) */
669 -mpfr_random_deviate_init (mpfr_random_deviate_t x)
670 +mpfr_random_deviate_init (mpfr_random_deviate_ptr x)
678 -mpfr_random_deviate_reset (mpfr_random_deviate_t x)
679 +mpfr_random_deviate_reset (mpfr_random_deviate_ptr x)
686 -mpfr_random_deviate_clear (mpfr_random_deviate_t x)
687 +mpfr_random_deviate_clear (mpfr_random_deviate_ptr x)
692 /* swap two random deviates */
694 -mpfr_random_deviate_swap (mpfr_random_deviate_t x, mpfr_random_deviate_t y)
695 +mpfr_random_deviate_swap (mpfr_random_deviate_ptr x,
696 + mpfr_random_deviate_ptr y)
698 mpfr_random_size_t s;
702 /* ensure x has at least k bits */
704 -random_deviate_generate (mpfr_random_deviate_t x, mpfr_random_size_t k,
705 +random_deviate_generate (mpfr_random_deviate_ptr x, mpfr_random_size_t k,
706 gmp_randstate_t r, mpz_t t)
708 /* Various compile time checks on mpfr_random_deviate_t */
711 /* return position of leading bit, counting from 1 */
712 static mpfr_random_size_t
713 -random_deviate_leading_bit (mpfr_random_deviate_t x, gmp_randstate_t r)
714 +random_deviate_leading_bit (mpfr_random_deviate_ptr x, gmp_randstate_t r)
716 mpfr_random_size_t l;
717 random_deviate_generate (x, W, r, 0);
720 /* return kth bit of fraction, representing 2^-k */
722 -mpfr_random_deviate_tstbit (mpfr_random_deviate_t x, mpfr_random_size_t k,
723 +mpfr_random_deviate_tstbit (mpfr_random_deviate_ptr x, mpfr_random_size_t k,
729 /* compare two random deviates, x < y */
731 -mpfr_random_deviate_less (mpfr_random_deviate_t x, mpfr_random_deviate_t y,
732 +mpfr_random_deviate_less (mpfr_random_deviate_ptr x,
733 + mpfr_random_deviate_ptr y,
736 mpfr_random_size_t k = 1;
738 /* set mpfr_t z = (neg ? -1 : 1) * (n + x) */
740 mpfr_random_deviate_value (int neg, unsigned long n,
741 - mpfr_random_deviate_t x, mpfr_t z,
742 + mpfr_random_deviate_ptr x, mpfr_ptr z,
743 gmp_randstate_t r, mpfr_rnd_t rnd)
745 /* r is used to add as many bits as necessary to match the precision of z */
746 diff -Naurd mpfr-4.1.0-a/src/random_deviate.h mpfr-4.1.0-b/src/random_deviate.h
747 --- mpfr-4.1.0-a/src/random_deviate.h 2020-01-08 18:11:13.000000000 +0000
748 +++ mpfr-4.1.0-b/src/random_deviate.h 2021-02-11 12:48:27.354242922 +0000
750 /* set mpfr_t z = (neg ? -1 : 1) * (n + x) */
752 mpfr_random_deviate_value (int, unsigned long,
753 - mpfr_random_deviate_ptr, mpfr_t,
754 + mpfr_random_deviate_ptr, mpfr_ptr,
755 gmp_randstate_t, mpfr_rnd_t);
757 #if defined(__cplusplus)
758 diff -Naurd mpfr-4.1.0-a/src/rndna.c mpfr-4.1.0-b/src/rndna.c
759 --- mpfr-4.1.0-a/src/rndna.c 2020-01-08 18:11:13.000000000 +0000
760 +++ mpfr-4.1.0-b/src/rndna.c 2021-02-11 12:48:27.354242922 +0000
762 and prepares rop to give it one more bit of precision
763 and to save its old value within it. */
765 -mpfr_round_nearest_away_begin (mpfr_t rop)
766 +mpfr_round_nearest_away_begin (mpfr_ptr rop)
771 copying it back the result of the applied function
772 and performing additional roundings. */
774 -mpfr_round_nearest_away_end (mpfr_t rop, int inex)
775 +mpfr_round_nearest_away_end (mpfr_ptr rop, int inex)
779 diff -Naurd mpfr-4.1.0-a/src/set_sj.c mpfr-4.1.0-b/src/set_sj.c
780 --- mpfr-4.1.0-a/src/set_sj.c 2020-06-01 10:39:52.000000000 +0000
781 +++ mpfr-4.1.0-b/src/set_sj.c 2021-02-11 12:48:27.354242922 +0000
783 #ifdef _MPFR_H_HAVE_INTMAX_T
786 -mpfr_set_sj (mpfr_t x, intmax_t j, mpfr_rnd_t rnd)
787 +mpfr_set_sj (mpfr_ptr x, intmax_t j, mpfr_rnd_t rnd)
789 return mpfr_set_sj_2exp (x, j, 0, rnd);
793 -mpfr_set_sj_2exp (mpfr_t x, intmax_t j, intmax_t e, mpfr_rnd_t rnd)
794 +mpfr_set_sj_2exp (mpfr_ptr x, intmax_t j, intmax_t e, mpfr_rnd_t rnd)
797 return mpfr_set_uj_2exp (x, j, e, rnd);
798 diff -Naurd mpfr-4.1.0-a/src/set_str.c mpfr-4.1.0-b/src/set_str.c
799 --- mpfr-4.1.0-a/src/set_str.c 2020-01-08 18:11:13.000000000 +0000
800 +++ mpfr-4.1.0-b/src/set_str.c 2021-02-11 12:48:27.354242922 +0000
802 #include "mpfr-impl.h"
805 -mpfr_set_str (mpfr_t x, const char *str, int base, mpfr_rnd_t rnd)
806 +mpfr_set_str (mpfr_ptr x, const char *str, int base, mpfr_rnd_t rnd)
810 diff -Naurd mpfr-4.1.0-a/src/set_uj.c mpfr-4.1.0-b/src/set_uj.c
811 --- mpfr-4.1.0-a/src/set_uj.c 2020-06-01 10:39:52.000000000 +0000
812 +++ mpfr-4.1.0-b/src/set_uj.c 2021-02-11 12:48:27.354242922 +0000
814 #define uintmaxpml (sizeof(uintmax_t) / sizeof(mp_limb_t))
817 -mpfr_set_uj (mpfr_t x, uintmax_t j, mpfr_rnd_t rnd)
818 +mpfr_set_uj (mpfr_ptr x, uintmax_t j, mpfr_rnd_t rnd)
820 return mpfr_set_uj_2exp (x, j, 0, rnd);
824 -mpfr_set_uj_2exp (mpfr_t x, uintmax_t j, intmax_t e, mpfr_rnd_t rnd)
825 +mpfr_set_uj_2exp (mpfr_ptr x, uintmax_t j, intmax_t e, mpfr_rnd_t rnd)
829 diff -Naurd mpfr-4.1.0-a/src/sin_cos.c mpfr-4.1.0-b/src/sin_cos.c
830 --- mpfr-4.1.0-a/src/sin_cos.c 2020-01-08 18:11:13.000000000 +0000
831 +++ mpfr-4.1.0-b/src/sin_cos.c 2021-02-11 12:48:27.354242922 +0000
833 Return err such that the relative error is bounded by 2^err ulps.
836 -sincos_aux (mpfr_t s, mpfr_t c, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
837 +sincos_aux (mpfr_ptr s, mpfr_ptr c, mpfr_srcptr x, mpfr_rnd_t rnd_mode)
839 mpfr_prec_t prec_s, sh;
840 mpz_t Q, S, C, Q2, S2, C2, y;
842 Assumes s differs from c.
845 -mpfr_sincos_fast (mpfr_t s, mpfr_t c, mpfr_srcptr x, mpfr_rnd_t rnd)
846 +mpfr_sincos_fast (mpfr_ptr s, mpfr_ptr c, mpfr_srcptr x, mpfr_rnd_t rnd)
849 mpfr_t x_red, ts, tc;
850 diff -Naurd mpfr-4.1.0-a/src/strtofr.c mpfr-4.1.0-b/src/strtofr.c
851 --- mpfr-4.1.0-a/src/strtofr.c 2020-01-08 18:11:13.000000000 +0000
852 +++ mpfr-4.1.0-b/src/strtofr.c 2021-02-11 12:48:27.354242922 +0000
854 BUT if it returns 0 (NAN or INF), the ternary value is also '0'
855 (ie NAN and INF are exact) */
857 -parse_string (mpfr_t x, struct parsed_string *pstr,
858 +parse_string (mpfr_ptr x, struct parsed_string *pstr,
859 const char **string, int base)
861 const char *str = *string;
863 and the precision of x.
864 Returns the ternary value. */
866 -parsed_string_to_mpfr (mpfr_t x, struct parsed_string *pstr, mpfr_rnd_t rnd)
867 +parsed_string_to_mpfr (mpfr_ptr x, struct parsed_string *pstr, mpfr_rnd_t rnd)
869 mpfr_prec_t precx, prec, ysize_bits, pstr_size;
875 -mpfr_strtofr (mpfr_t x, const char *string, char **end, int base,
876 +mpfr_strtofr (mpfr_ptr x, const char *string, char **end, int base,
880 diff -Naurd mpfr-4.1.0-a/src/vasprintf.c mpfr-4.1.0-b/src/vasprintf.c
881 --- mpfr-4.1.0-a/src/vasprintf.c 2020-06-01 10:39:52.000000000 +0000
882 +++ mpfr-4.1.0-b/src/vasprintf.c 2021-02-11 12:48:27.354242922 +0000
886 MPFR_RETURNS_NONNULL static char *
887 -mpfr_get_str_wrapper (mpfr_exp_t *exp, int base, size_t n, const mpfr_t op,
888 +mpfr_get_str_wrapper (mpfr_exp_t *exp, int base, size_t n, mpfr_srcptr op,
889 const struct printf_spec spec)
892 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
893 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:46:49.115316335 +0000
894 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:48:27.370242746 +0000
897 mpfr_get_version (void)
902 diff -Naurd mpfr-4.1.0-a/src/zeta.c mpfr-4.1.0-b/src/zeta.c
903 --- mpfr-4.1.0-a/src/zeta.c 2020-01-08 18:11:13.000000000 +0000
904 +++ mpfr-4.1.0-b/src/zeta.c 2021-02-11 12:48:27.354242922 +0000
906 sum(tc[i]*product((s+2j)*(s+2j-1)/n^2,j=1..i-1), i=1..p)*s*n^(-s-1)
909 -mpfr_zeta_part_b (mpfr_t b, mpfr_srcptr s, int n, int p, mpfr_t *tc)
910 +mpfr_zeta_part_b (mpfr_ptr b, mpfr_srcptr s, int n, int p, mpfr_t *tc)
916 Output: sum - a floating-point number approximating sum(1/i^s, i=1..n-1) */
918 -mpfr_zeta_part_a (mpfr_t sum, mpfr_srcptr s, int n)
919 +mpfr_zeta_part_a (mpfr_ptr sum, mpfr_srcptr s, int n)
924 Output: z - Zeta(s) rounded to the precision of z with direction rnd_mode
927 -mpfr_zeta_pos (mpfr_t z, mpfr_srcptr s, mpfr_rnd_t rnd_mode)
928 +mpfr_zeta_pos (mpfr_ptr z, mpfr_srcptr s, mpfr_rnd_t rnd_mode)
930 mpfr_t b, c, z_pre, f, s1;
931 double beta, sd, dnep;
933 At input, p is Pi rounded down.
934 The comments in the code are for rnd = RNDD. */
936 -mpfr_reflection_overflow (mpfr_t z, mpfr_t s1, const mpfr_t s, mpfr_t y,
937 - mpfr_t p, mpfr_rnd_t rnd)
938 +mpfr_reflection_overflow (mpfr_ptr z, mpfr_ptr s1, mpfr_srcptr s, mpfr_ptr y,
939 + mpfr_ptr p, mpfr_rnd_t rnd)
947 -mpfr_zeta (mpfr_t z, mpfr_srcptr s, mpfr_rnd_t rnd_mode)
948 +mpfr_zeta (mpfr_ptr z, mpfr_srcptr s, mpfr_rnd_t rnd_mode)
950 mpfr_t z_pre, s1, y, p;
952 diff -Naurd mpfr-4.1.0-a/tests/tcmp2.c mpfr-4.1.0-b/tests/tcmp2.c
953 --- mpfr-4.1.0-a/tests/tcmp2.c 2020-01-08 18:11:13.000000000 +0000
954 +++ mpfr-4.1.0-b/tests/tcmp2.c 2021-02-11 12:48:27.350242965 +0000
957 /* set bit n of x to b, where bit 0 is the most significant one */
959 -set_bit (mpfr_t x, unsigned int n, int b)
960 +set_bit (mpfr_ptr x, unsigned int n, int b)
964 diff -Naurd mpfr-4.1.0-a/tests/tdiv.c mpfr-4.1.0-b/tests/tdiv.c
965 --- mpfr-4.1.0-a/tests/tdiv.c 2020-01-08 18:11:13.000000000 +0000
966 +++ mpfr-4.1.0-b/tests/tdiv.c 2021-02-11 12:48:27.350242965 +0000
968 /* given y = o(x/u), x, u, find the inexact flag by
969 multiplying y by u */
971 -get_inexact (mpfr_t y, mpfr_t x, mpfr_t u)
972 +get_inexact (mpfr_ptr y, mpfr_ptr x, mpfr_ptr u)
976 diff -Naurd mpfr-4.1.0-a/tests/teq.c mpfr-4.1.0-b/tests/teq.c
977 --- mpfr-4.1.0-a/tests/teq.c 2020-01-08 18:11:13.000000000 +0000
978 +++ mpfr-4.1.0-b/tests/teq.c 2021-02-11 12:48:27.350242965 +0000
980 #include "mpfr-test.h"
987 unsigned long k, px, mx;
988 diff -Naurd mpfr-4.1.0-a/tests/terandom_chisq.c mpfr-4.1.0-b/tests/terandom_chisq.c
989 --- mpfr-4.1.0-a/tests/terandom_chisq.c 2020-01-08 18:11:13.000000000 +0000
990 +++ mpfr-4.1.0-b/tests/terandom_chisq.c 2021-02-11 12:48:27.350242965 +0000
992 * exponential distribution. We only take differences of this function so the
993 * offset doesn't matter; here Phi(0) = 0. */
995 -exponential_cumulative (mpfr_t z, mpfr_t x, mpfr_rnd_t rnd)
996 +exponential_cumulative (mpfr_ptr z, mpfr_ptr x, mpfr_rnd_t rnd)
998 mpfr_neg (z, x, rnd);
999 mpfr_expm1 (z, z, rnd);
1001 * TAOCP, Vol 2, 3.3.1, Table 1. It more accurate than the similar formula,
1004 -chisq_prob (mpfr_t q, long nu, mpfr_t chisqp)
1005 +chisq_prob (mpfr_ptr q, long nu, mpfr_ptr chisqp)
1010 * this function. low precision means prec = 2, 3, or 4. High values of
1011 * precision will result in integer overflow. */
1013 -sequential (mpfr_t x)
1014 +sequential (mpfr_ptr x)
1018 diff -Naurd mpfr-4.1.0-a/tests/tfmma.c mpfr-4.1.0-b/tests/tfmma.c
1019 --- mpfr-4.1.0-a/tests/tfmma.c 2020-03-24 13:47:38.000000000 +0000
1020 +++ mpfr-4.1.0-b/tests/tfmma.c 2021-02-11 12:48:27.350242965 +0000
1023 /* check both mpfr_fmma and mpfr_fmms */
1025 -random_test (mpfr_t a, mpfr_t b, mpfr_t c, mpfr_t d, mpfr_rnd_t rnd)
1026 +random_test (mpfr_ptr a, mpfr_ptr b, mpfr_ptr c, mpfr_ptr d, mpfr_rnd_t rnd)
1028 mpfr_t ref, res, ab, cd;
1029 int inex_ref, inex_res;
1030 diff -Naurd mpfr-4.1.0-a/tests/tfmod.c mpfr-4.1.0-b/tests/tfmod.c
1031 --- mpfr-4.1.0-a/tests/tfmod.c 2020-01-08 18:11:13.000000000 +0000
1032 +++ mpfr-4.1.0-b/tests/tfmod.c 2021-02-11 12:48:27.350242965 +0000
1037 -test_failed (mpfr_t erem, mpfr_t grem, int eret, int gret, mpfr_t x, mpfr_t y,
1039 +test_failed (mpfr_ptr erem, mpfr_ptr grem, int eret, int gret,
1040 + mpfr_ptr x, mpfr_ptr y, mpfr_rnd_t rnd)
1042 printf ("error: mpfr_fmod (r, x, y, rnd)\n x = ");
1043 mpfr_out_str (stdout, 10, 0, x, MPFR_RNDD);
1048 -check (mpfr_t r0, mpfr_t x, mpfr_t y, mpfr_rnd_t rnd)
1049 +check (mpfr_ptr r0, mpfr_ptr x, mpfr_ptr y, mpfr_rnd_t rnd)
1053 diff -Naurd mpfr-4.1.0-a/tests/tfprintf.c mpfr-4.1.0-b/tests/tfprintf.c
1054 --- mpfr-4.1.0-a/tests/tfprintf.c 2020-06-01 10:39:52.000000000 +0000
1055 +++ mpfr-4.1.0-b/tests/tfprintf.c 2021-02-11 12:48:27.350242965 +0000
1057 const int prec_max_printf = 5000;
1060 -check (FILE *fout, const char *fmt, mpfr_t x)
1061 +check (FILE *fout, const char *fmt, mpfr_ptr x)
1063 if (mpfr_fprintf (fout, fmt, x) == -1)
1065 diff -Naurd mpfr-4.1.0-a/tests/tgamma.c mpfr-4.1.0-b/tests/tgamma.c
1066 --- mpfr-4.1.0-a/tests/tgamma.c 2020-06-01 00:15:37.000000000 +0000
1067 +++ mpfr-4.1.0-b/tests/tgamma.c 2021-02-11 12:48:27.350242965 +0000
1069 computing with a working precision p2. Assume that x is not an
1072 -exp_lgamma (mpfr_t x, mpfr_prec_t p1, mpfr_prec_t p2)
1073 +exp_lgamma (mpfr_ptr x, mpfr_prec_t p1, mpfr_prec_t p2)
1075 mpfr_t yd, yu, zd, zu;
1076 int inexd, inexu, sign;
1077 diff -Naurd mpfr-4.1.0-a/tests/tnrandom_chisq.c mpfr-4.1.0-b/tests/tnrandom_chisq.c
1078 --- mpfr-4.1.0-a/tests/tnrandom_chisq.c 2020-01-08 18:11:13.000000000 +0000
1079 +++ mpfr-4.1.0-b/tests/tnrandom_chisq.c 2021-02-11 12:48:27.350242965 +0000
1081 * for the normal distribution. We only take differences of this function so
1082 * the offset doesn't matter; here Phi(0) = 0. */
1084 -normal_cumulative (mpfr_t z, mpfr_t x, mpfr_rnd_t rnd)
1085 +normal_cumulative (mpfr_ptr z, mpfr_ptr x, mpfr_rnd_t rnd)
1087 mpfr_sqrt_ui (z, 2, rnd);
1088 mpfr_div (z, x, z, rnd);
1090 * TAOCP, Vol 2, 3.3.1, Table 1. It more accurate than the similar formula,
1093 -chisq_prob (mpfr_t q, long nu, mpfr_t chisqp)
1094 +chisq_prob (mpfr_ptr q, long nu, mpfr_ptr chisqp)
1099 * this function. low precision means prec = 2, 3, or 4. High values of
1100 * precision will result in integer overflow. */
1102 -sequential (mpfr_t x)
1103 +sequential (mpfr_ptr x)
1107 diff -Naurd mpfr-4.1.0-a/tests/tprintf.c mpfr-4.1.0-b/tests/tprintf.c
1108 --- mpfr-4.1.0-a/tests/tprintf.c 2020-06-01 10:39:52.000000000 +0000
1109 +++ mpfr-4.1.0-b/tests/tprintf.c 2021-02-11 12:48:27.350242965 +0000
1111 int stdout_redirect;
1114 -check (const char *fmt, mpfr_t x)
1115 +check (const char *fmt, mpfr_ptr x)
1117 if (mpfr_printf (fmt, x) == -1)
1119 diff -Naurd mpfr-4.1.0-a/tests/trint.c mpfr-4.1.0-b/tests/trint.c
1120 --- mpfr-4.1.0-a/tests/trint.c 2020-02-12 13:04:50.000000000 +0000
1121 +++ mpfr-4.1.0-b/tests/trint.c 2021-02-11 12:48:27.350242965 +0000
1126 -err (const char *str, mp_size_t s, mpfr_t x, mpfr_t y, mpfr_prec_t p,
1127 +err (const char *str, mp_size_t s, mpfr_ptr x, mpfr_ptr y, mpfr_prec_t p,
1128 mpfr_rnd_t r, int trint, int inexact)
1130 printf ("Error: %s\ns = %u, p = %u, r = %s, trint = %d, inexact = %d\nx = ",
1131 diff -Naurd mpfr-4.1.0-a/tests/tsinh_cosh.c mpfr-4.1.0-b/tests/tsinh_cosh.c
1132 --- mpfr-4.1.0-a/tests/tsinh_cosh.c 2020-01-08 18:11:13.000000000 +0000
1133 +++ mpfr-4.1.0-b/tests/tsinh_cosh.c 2021-02-11 12:48:27.350242965 +0000
1135 #include "mpfr-test.h"
1138 -failed (mpfr_t x, mpfr_t esh, mpfr_t gsh, mpfr_t ech, mpfr_t gch)
1139 +failed (mpfr_ptr x, mpfr_ptr esh, mpfr_ptr gsh, mpfr_ptr ech, mpfr_ptr gch)
1141 printf ("error : mpfr_sinh_cosh (x) x = ");
1142 mpfr_out_str (stdout, 10, 0, x, MPFR_RNDD);
1145 /* check against sinh, cosh */
1147 -check (mpfr_t x, mpfr_rnd_t rnd)
1148 +check (mpfr_ptr x, mpfr_rnd_t rnd)
1150 mpfr_t s, c, sx, cx;
1152 diff -Naurd mpfr-4.1.0-a/tests/tsqr.c mpfr-4.1.0-b/tests/tsqr.c
1153 --- mpfr-4.1.0-a/tests/tsqr.c 2020-01-08 18:11:13.000000000 +0000
1154 +++ mpfr-4.1.0-b/tests/tsqr.c 2021-02-11 12:48:27.350242965 +0000
1158 error1 (mpfr_rnd_t rnd, mpfr_prec_t prec,
1159 - mpfr_t in, mpfr_t outmul, mpfr_t outsqr)
1160 + mpfr_t in, mpfr_ptr outmul, mpfr_ptr outsqr)
1162 printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd),
1163 (unsigned long) prec);
1168 -error2 (mpfr_rnd_t rnd, mpfr_prec_t prec, mpfr_t in, mpfr_t out,
1169 +error2 (mpfr_rnd_t rnd, mpfr_prec_t prec, mpfr_ptr in, mpfr_ptr out,
1170 int inexactmul, int inexactsqr)
1172 printf("ERROR: for %s and prec=%lu\nINPUT=", mpfr_print_rnd_mode(rnd),
1173 diff -Naurd mpfr-4.1.0-a/tests/tsum.c mpfr-4.1.0-b/tests/tsum.c
1174 --- mpfr-4.1.0-a/tests/tsum.c 2020-01-08 18:11:13.000000000 +0000
1175 +++ mpfr-4.1.0-b/tests/tsum.c 2021-02-11 12:48:27.350242965 +0000
1180 -get_exact_sum (mpfr_t sum, mpfr_t *tab, int n)
1181 +get_exact_sum (mpfr_ptr sum, mpfr_t *tab, int n)
1185 @@ -1198,7 +1198,7 @@
1189 -mpfr_sum_naive (mpfr_t s, mpfr_t *x, int n, mpfr_rnd_t rnd)
1190 +mpfr_sum_naive (mpfr_ptr s, mpfr_t *x, int n, mpfr_rnd_t rnd)
1194 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
1195 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:50:22.384987438 +0000
1196 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:50:22.424987002 +0000
1199 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
1200 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:48:27.370242746 +0000
1201 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:50:22.424987002 +0000
1205 diff -Naurd mpfr-4.1.0-a/src/digamma.c mpfr-4.1.0-b/src/digamma.c
1206 --- mpfr-4.1.0-a/src/digamma.c 2020-06-18 17:17:18.000000000 +0000
1207 +++ mpfr-4.1.0-b/src/digamma.c 2021-02-11 12:50:22.412987133 +0000
1208 @@ -214,19 +214,27 @@
1209 (("x[%Pu]=%.*Rg rnd=%d", mpfr_get_prec(x), mpfr_log_prec, x, rnd_mode),
1210 ("y[%Pu]=%.*Rg inexact=%d", mpfr_get_prec(y), mpfr_log_prec, y, inex));
1212 - /* compute a precision q such that x+1 is exact */
1213 - if (MPFR_PREC(x) < MPFR_GET_EXP(x))
1216 - q = MPFR_PREC(x) + 1;
1218 - /* for very large x, use |digamma(x) - log(x)| < 1/x < 2^(1-EXP(x)) */
1219 - if (MPFR_PREC(y) + 10 < MPFR_EXP(x))
1220 + /* For very large x, use |digamma(x) - log(x)| < 1/x < 2^(1-EXP(x)).
1221 + However, for a fixed value of GUARD, MPFR_CAN_ROUND() might fail
1222 + with probability 1/2^GUARD, in which case the default code will
1223 + fail since it requires x+1 to be exact, thus a huge precision if
1224 + x is huge. There are two workarounds:
1225 + * either perform a Ziv's loop, by increasing GUARD at each step.
1226 + However, this might fail if x is moderately large, in which case
1227 + more terms of the asymptotic expansion would be needed.
1228 + * implement a full asymptotic expansion (with Ziv's loop). */
1230 + if (MPFR_PREC(y) + GUARD < MPFR_EXP(x))
1232 /* this ensures EXP(x) >= 3, thus x >= 4, thus log(x) > 1 */
1233 - mpfr_init2 (t, MPFR_PREC(y) + 10);
1234 - mpfr_log (t, x, MPFR_RNDZ);
1235 - if (MPFR_CAN_ROUND (t, MPFR_PREC(y) + 10, MPFR_PREC(y), rnd_mode))
1236 + mpfr_init2 (t, MPFR_PREC(y) + GUARD);
1237 + mpfr_log (t, x, MPFR_RNDN);
1238 + /* |t - digamma(x)| <= 1/2*ulp(t) + |digamma(x) - log(x)|
1239 + <= 1/2*ulp(t) + 2^(1-EXP(x))
1240 + <= 1/2*ulp(t) + 2^(-PREC(y)-GUARD)
1242 + since |t| >= 1 thus ulp(t) >= 2^(1-PREC(y)-GUARD) */
1243 + if (MPFR_CAN_ROUND (t, MPFR_PREC(y) + GUARD, MPFR_PREC(y), rnd_mode))
1245 inex = mpfr_set (y, t, rnd_mode);
1247 @@ -235,6 +243,21 @@
1251 + /* compute a precision q such that x+1 is exact */
1252 + if (MPFR_PREC(x) < MPFR_GET_EXP(x))
1254 + /* The goal of the first assertion is to let the compiler ignore
1255 + the second one when MPFR_EMAX_MAX <= MPFR_PREC_MAX. */
1256 + MPFR_ASSERTD (MPFR_EXP(x) <= MPFR_EMAX_MAX);
1257 + MPFR_ASSERTN (MPFR_EXP(x) <= MPFR_PREC_MAX);
1261 + q = MPFR_PREC(x) + 1;
1263 + /* FIXME: q can be much too large, e.g. equal to the maximum exponent! */
1264 + MPFR_LOG_MSG (("q=%Pu\n", q));
1266 mpfr_init2 (x_plus_j, q);
1269 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
1270 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:48:27.366242791 +0000
1271 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:50:22.424987002 +0000
1273 #define MPFR_VERSION_MAJOR 4
1274 #define MPFR_VERSION_MINOR 1
1275 #define MPFR_VERSION_PATCHLEVEL 0
1276 -#define MPFR_VERSION_STRING "4.1.0-p4"
1277 +#define MPFR_VERSION_STRING "4.1.0-p5"
1280 MPFR_USE_FILE: Define it to make MPFR define functions dealing
1281 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
1282 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:48:27.370242746 +0000
1283 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:50:22.424987002 +0000
1286 mpfr_get_version (void)
1288 - return "4.1.0-p4";
1289 + return "4.1.0-p5";
1291 diff -Naurd mpfr-4.1.0-a/tests/tdigamma.c mpfr-4.1.0-b/tests/tdigamma.c
1292 --- mpfr-4.1.0-a/tests/tdigamma.c 2020-06-18 17:17:18.000000000 +0000
1293 +++ mpfr-4.1.0-b/tests/tdigamma.c 2021-02-11 12:50:22.412987133 +0000
1298 +/* With some GMP_CHECK_RANDOMIZE values, test_generic triggers an error
1299 + tests_addsize(): too much memory (576460752303432776 bytes)
1300 + Each time on prec = 200, n = 3, xprec = 140.
1301 + The following test is a more general testcase.
1307 + mpfr_t x, y[NPREC], z;
1308 + mpfr_exp_t emin, emax;
1309 + int i, precx, precy[NPREC] = { 200, 400, 520, 1416 };
1311 + emin = mpfr_get_emin ();
1312 + emax = mpfr_get_emax ();
1313 + set_emin (MPFR_EMIN_MIN);
1314 + set_emax (MPFR_EMAX_MAX);
1316 + for (i = 0; i < NPREC; i++)
1317 + mpfr_init2 (y[i], precy[i]);
1318 + mpfr_init2 (z, precy[0]);
1320 + for (precx = MPFR_PREC_MIN; precx < 150; precx++)
1322 + mpfr_init2 (x, precx);
1323 + mpfr_setmax (x, __gmpfr_emax);
1324 + for (i = 0; i < NPREC; i++)
1325 + mpfr_digamma (y[i], x, MPFR_RNDA);
1326 + mpfr_set (z, y[1], MPFR_RNDA);
1327 + MPFR_ASSERTN (mpfr_equal_p (y[0], z));
1331 + for (i = 0; i < NPREC; i++)
1332 + mpfr_clear (y[i]);
1340 main (int argc, char *argv[])
1342 tests_start_mpfr ();
1347 test_generic (MPFR_PREC_MIN, 200, 20);
1349 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
1350 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:52:52.519350662 +0000
1351 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:52:52.563350183 +0000
1353 +digamma-interm-zero
1354 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
1355 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:50:22.424987002 +0000
1356 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:52:52.563350183 +0000
1360 diff -Naurd mpfr-4.1.0-a/src/digamma.c mpfr-4.1.0-b/src/digamma.c
1361 --- mpfr-4.1.0-a/src/digamma.c 2021-02-11 12:50:22.412987133 +0000
1362 +++ mpfr-4.1.0-b/src/digamma.c 2021-02-11 12:52:52.547350357 +0000
1363 @@ -296,21 +296,26 @@
1364 errt = mpfr_digamma_approx (t, x_plus_j);
1365 expt = MPFR_GET_EXP (t);
1366 mpfr_sub (t, t, u, MPFR_RNDN);
1367 - if (MPFR_GET_EXP (t) < expt)
1368 - errt += expt - MPFR_EXP(t);
1369 - /* Warning: if u is zero (which happens when x_plus_j >= min at the
1370 - beginning of the while loop above), EXP(u) is not defined.
1371 - In this case we have no error from u. */
1372 - if (MPFR_NOTZERO(u) && MPFR_GET_EXP (t) < MPFR_GET_EXP (u))
1373 - erru += MPFR_EXP(u) - MPFR_EXP(t);
1376 - else if (errt == erru)
1380 - if (MPFR_CAN_ROUND (t, p - errt, MPFR_PREC(y), rnd_mode))
1382 + /* Warning! t may be zero (more likely in small precision). Note
1383 + that in this case, this is an exact zero, not an underflow. */
1384 + if (MPFR_NOTZERO(t))
1386 + if (MPFR_GET_EXP (t) < expt)
1387 + errt += expt - MPFR_EXP(t);
1388 + /* Warning: if u is zero (which happens when x_plus_j >= min at the
1389 + beginning of the while loop above), EXP(u) is not defined.
1390 + In this case we have no error from u. */
1391 + if (MPFR_NOTZERO(u) && MPFR_GET_EXP (t) < MPFR_GET_EXP (u))
1392 + erru += MPFR_EXP(u) - MPFR_EXP(t);
1395 + else if (errt == erru)
1399 + if (MPFR_CAN_ROUND (t, p - errt, MPFR_PREC(y), rnd_mode))
1402 MPFR_ZIV_NEXT (loop, p);
1403 mpfr_set_prec (t, p);
1404 mpfr_set_prec (u, p);
1405 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
1406 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:50:22.424987002 +0000
1407 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:52:52.559350226 +0000
1409 #define MPFR_VERSION_MAJOR 4
1410 #define MPFR_VERSION_MINOR 1
1411 #define MPFR_VERSION_PATCHLEVEL 0
1412 -#define MPFR_VERSION_STRING "4.1.0-p5"
1413 +#define MPFR_VERSION_STRING "4.1.0-p6"
1416 MPFR_USE_FILE: Define it to make MPFR define functions dealing
1417 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
1418 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:50:22.424987002 +0000
1419 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:52:52.559350226 +0000
1422 mpfr_get_version (void)
1424 - return "4.1.0-p5";
1425 + return "4.1.0-p6";
1427 diff -Naurd mpfr-4.1.0-a/tests/tdigamma.c mpfr-4.1.0-b/tests/tdigamma.c
1428 --- mpfr-4.1.0-a/tests/tdigamma.c 2021-02-11 12:50:22.412987133 +0000
1429 +++ mpfr-4.1.0-b/tests/tdigamma.c 2021-02-11 12:52:52.547350357 +0000
1434 +/* another test that fails with GMP_CHECK_RANDOMIZE=1612741376857003
1435 + on revision 14398 */
1442 + mpfr_init2 (x, 73);
1443 + mpfr_init2 (y, 1);
1444 + mpfr_set_str (x, "1.4613470547060071827450", 10, MPFR_RNDN);
1445 + mpfr_clear_flags ();
1446 + inex = mpfr_digamma (y, x, MPFR_RNDU);
1447 + MPFR_ASSERTN (mpfr_cmp_si_2exp (y, -1, -12) == 0);
1448 + MPFR_ASSERTN (inex > 0);
1449 + MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_INEXACT);
1455 main (int argc, char *argv[])
1463 test_generic (MPFR_PREC_MIN, 200, 20);
1465 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
1466 --- mpfr-4.1.0-a/PATCHES 2021-02-11 12:53:38.382850990 +0000
1467 +++ mpfr-4.1.0-b/PATCHES 2021-02-11 12:53:38.426850512 +0000
1470 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
1471 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:52:52.563350183 +0000
1472 +++ mpfr-4.1.0-b/VERSION 2021-02-11 12:53:38.426850512 +0000
1476 diff -Naurd mpfr-4.1.0-a/src/jyn_asympt.c mpfr-4.1.0-b/src/jyn_asympt.c
1477 --- mpfr-4.1.0-a/src/jyn_asympt.c 2020-07-10 10:33:32.000000000 +0000
1478 +++ mpfr-4.1.0-b/src/jyn_asympt.c 2021-02-11 12:53:38.410850685 +0000
1480 MPFR_ZIV_INIT (loop, w);
1485 mpfr_set_prec (c, w);
1489 /* now s approximates sin(z)+cos(z), and c approximates sin(z)-cos(z),
1490 with total absolute error bounded by 2^(1-w). */
1492 + /* if s or c is zero, MPFR_GET_EXP will fail below */
1493 + if (MPFR_IS_ZERO(s) || MPFR_IS_ZERO(c))
1499 /* precompute 1/(8|z|) */
1500 mpfr_si_div (iz, MPFR_IS_POS(z) ? 1 : -1, z, MPFR_RNDN); /* err <= 1 */
1501 mpfr_div_2ui (iz, iz, 3, MPFR_RNDN);
1503 err = (err >= err2) ? err + 1 : err2 + 1;
1504 /* the absolute error on c is bounded by 2^(err - w) */
1506 + err -= MPFR_GET_EXP (c);
1516 - err -= MPFR_GET_EXP (c);
1517 - if (MPFR_LIKELY (MPFR_CAN_ROUND (c, w - err, MPFR_PREC(res), r)))
1518 + if (ok && MPFR_LIKELY (MPFR_CAN_ROUND (c, w - err, MPFR_PREC(res), r)))
1522 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
1523 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:52:52.559350226 +0000
1524 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-11 12:53:38.422850555 +0000
1526 #define MPFR_VERSION_MAJOR 4
1527 #define MPFR_VERSION_MINOR 1
1528 #define MPFR_VERSION_PATCHLEVEL 0
1529 -#define MPFR_VERSION_STRING "4.1.0-p6"
1530 +#define MPFR_VERSION_STRING "4.1.0-p7"
1533 MPFR_USE_FILE: Define it to make MPFR define functions dealing
1534 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
1535 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:52:52.559350226 +0000
1536 +++ mpfr-4.1.0-b/src/version.c 2021-02-11 12:53:38.426850512 +0000
1539 mpfr_get_version (void)
1541 - return "4.1.0-p6";
1542 + return "4.1.0-p7";
1544 diff -Naurd mpfr-4.1.0-a/tests/tj0.c mpfr-4.1.0-b/tests/tj0.c
1545 --- mpfr-4.1.0-a/tests/tj0.c 2020-01-08 18:11:13.000000000 +0000
1546 +++ mpfr-4.1.0-b/tests/tj0.c 2021-02-11 12:53:38.410850685 +0000
1548 #define REDUCE_EMAX 262143 /* otherwise arg. reduction is too expensive */
1549 #include "tgeneric.c"
1551 +/* bug found in revision 14399 with GMP_CHECK_RANDOMIZE=1612721106588971 */
1558 + mpfr_init2 (x, 79);
1559 + mpfr_init2 (y, 1);
1560 + mpfr_set_str (x, "2.552495117262005805960565e+02", 10, MPFR_RNDN);
1561 + mpfr_clear_flags ();
1562 + inex = mpfr_j0 (y, x, MPFR_RNDZ);
1563 + MPFR_ASSERTN (mpfr_cmp_si_2exp (y, -1, -5) == 0);
1564 + MPFR_ASSERTN (inex > 0);
1565 + MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_INEXACT);
1571 main (int argc, char *argv[])
1575 tests_start_mpfr ();
1582 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
1583 --- mpfr-4.1.0-a/PATCHES 2021-02-17 17:22:34.594973310 +0000
1584 +++ mpfr-4.1.0-b/PATCHES 2021-02-17 17:22:34.702972090 +0000
1586 +digamma-interm-zero2
1587 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
1588 --- mpfr-4.1.0-a/VERSION 2021-02-11 12:53:38.426850512 +0000
1589 +++ mpfr-4.1.0-b/VERSION 2021-02-17 17:22:34.702972090 +0000
1593 diff -Naurd mpfr-4.1.0-a/src/digamma.c mpfr-4.1.0-b/src/digamma.c
1594 --- mpfr-4.1.0-a/src/digamma.c 2021-02-11 12:52:52.547350357 +0000
1595 +++ mpfr-4.1.0-b/src/digamma.c 2021-02-17 17:22:34.690972226 +0000
1596 @@ -173,16 +173,19 @@
1597 mpfr_digamma (v, u, MPFR_RNDN); /* error <= 1/2 ulp */
1598 expv = MPFR_GET_EXP (v);
1599 mpfr_sub (v, v, t, MPFR_RNDN);
1600 - if (MPFR_GET_EXP (v) < MPFR_GET_EXP (t))
1601 - e1 += MPFR_EXP(t) - MPFR_EXP(v); /* scale error for t wrt new v */
1602 - /* now take into account the 1/2 ulp error for v */
1603 - if (expv - MPFR_EXP(v) - 1 > e1)
1604 - e1 = expv - MPFR_EXP(v) - 1;
1607 - e1 ++; /* rounding error for mpfr_sub */
1608 - if (MPFR_CAN_ROUND (v, p - e1, MPFR_PREC(y), rnd_mode))
1610 + if (MPFR_NOTZERO(v))
1612 + if (MPFR_GET_EXP (v) < MPFR_GET_EXP (t))
1613 + e1 += MPFR_EXP(t) - MPFR_EXP(v); /* scale error for t wrt new v */
1614 + /* now take into account the 1/2 ulp error for v */
1615 + if (expv - MPFR_EXP(v) - 1 > e1)
1616 + e1 = expv - MPFR_EXP(v) - 1;
1619 + e1 ++; /* rounding error for mpfr_sub */
1620 + if (MPFR_CAN_ROUND (v, p - e1, MPFR_PREC(y), rnd_mode))
1623 MPFR_ZIV_NEXT (loop, p);
1624 mpfr_set_prec (t, p);
1625 mpfr_set_prec (v, p);
1626 @@ -416,10 +419,8 @@
1630 - if (MPFR_IS_NEG(x))
1631 - inex = mpfr_digamma_reflection (y, x, rnd_mode);
1632 /* if x < 1/2 we use the reflection formula */
1633 - else if (MPFR_EXP(x) < 0)
1634 + if (MPFR_IS_NEG(x) || MPFR_EXP(x) < 0)
1635 inex = mpfr_digamma_reflection (y, x, rnd_mode);
1637 inex = mpfr_digamma_positive (y, x, rnd_mode);
1638 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
1639 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-11 12:53:38.422850555 +0000
1640 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-17 17:22:34.702972090 +0000
1642 #define MPFR_VERSION_MAJOR 4
1643 #define MPFR_VERSION_MINOR 1
1644 #define MPFR_VERSION_PATCHLEVEL 0
1645 -#define MPFR_VERSION_STRING "4.1.0-p7"
1646 +#define MPFR_VERSION_STRING "4.1.0-p8"
1649 MPFR_USE_FILE: Define it to make MPFR define functions dealing
1650 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
1651 --- mpfr-4.1.0-a/src/version.c 2021-02-11 12:53:38.426850512 +0000
1652 +++ mpfr-4.1.0-b/src/version.c 2021-02-17 17:22:34.702972090 +0000
1655 mpfr_get_version (void)
1657 - return "4.1.0-p7";
1658 + return "4.1.0-p8";
1660 diff -Naurd mpfr-4.1.0-a/tests/tdigamma.c mpfr-4.1.0-b/tests/tdigamma.c
1661 --- mpfr-4.1.0-a/tests/tdigamma.c 2021-02-11 12:52:52.547350357 +0000
1662 +++ mpfr-4.1.0-b/tests/tdigamma.c 2021-02-17 17:22:34.690972226 +0000
1663 @@ -110,6 +110,26 @@
1667 +/* another test that fails with GMP_CHECK_RANDOMIZE=1613197421465830
1668 + on revision 14429 */
1675 + mpfr_init2 (x, 510);
1676 + mpfr_init2 (y, 4);
1677 + mpfr_set_str (x, "-8.2923051438433494998166335341807999322052669984208422481227138906096000469898717007386115912802685588348601663465077353194268894939972221117314512518182580e+35", 10, MPFR_RNDN);
1678 + mpfr_clear_flags ();
1679 + inex = mpfr_digamma (y, x, MPFR_RNDU);
1680 + MPFR_ASSERTN (mpfr_cmp_ui0 (y, 88) == 0);
1681 + MPFR_ASSERTN (inex > 0);
1682 + MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_INEXACT);
1688 main (int argc, char *argv[])
1696 test_generic (MPFR_PREC_MIN, 200, 20);
1698 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
1699 --- mpfr-4.1.0-a/PATCHES 2021-02-17 17:25:46.396981483 +0000
1700 +++ mpfr-4.1.0-b/PATCHES 2021-02-17 17:25:46.440981068 +0000
1702 +jyn_asympt-interm-zero
1703 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
1704 --- mpfr-4.1.0-a/VERSION 2021-02-17 17:22:34.702972090 +0000
1705 +++ mpfr-4.1.0-b/VERSION 2021-02-17 17:25:46.440981068 +0000
1709 diff -Naurd mpfr-4.1.0-a/src/jyn_asympt.c mpfr-4.1.0-b/src/jyn_asympt.c
1710 --- mpfr-4.1.0-a/src/jyn_asympt.c 2021-02-11 12:53:38.410850685 +0000
1711 +++ mpfr-4.1.0-b/src/jyn_asympt.c 2021-02-17 17:25:46.424981219 +0000
1713 MPFR_ZIV_INIT (loop, w);
1719 mpfr_set_prec (c, w);
1723 /* if s or c is zero, MPFR_GET_EXP will fail below */
1724 if (MPFR_IS_ZERO(s) || MPFR_IS_ZERO(c))
1729 + goto clear; /* with ok=0 */
1731 /* precompute 1/(8|z|) */
1732 mpfr_si_div (iz, MPFR_IS_POS(z) ? 1 : -1, z, MPFR_RNDN); /* err <= 1 */
1734 mpfr_sub (s, c, s, MPFR_RNDN);
1737 + if (MPFR_IS_ZERO(s))
1738 + goto clear; /* with ok=0 */
1741 mpfr_neg (s, s, MPFR_RNDN);
1742 if (MPFR_GET_EXP (s) > err)
1743 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
1744 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-17 17:22:34.702972090 +0000
1745 +++ mpfr-4.1.0-b/src/mpfr.h 2021-02-17 17:25:46.436981105 +0000
1747 #define MPFR_VERSION_MAJOR 4
1748 #define MPFR_VERSION_MINOR 1
1749 #define MPFR_VERSION_PATCHLEVEL 0
1750 -#define MPFR_VERSION_STRING "4.1.0-p8"
1751 +#define MPFR_VERSION_STRING "4.1.0-p9"
1754 MPFR_USE_FILE: Define it to make MPFR define functions dealing
1755 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
1756 --- mpfr-4.1.0-a/src/version.c 2021-02-17 17:22:34.702972090 +0000
1757 +++ mpfr-4.1.0-b/src/version.c 2021-02-17 17:25:46.440981068 +0000
1760 mpfr_get_version (void)
1762 - return "4.1.0-p8";
1763 + return "4.1.0-p9";
1765 diff -Naurd mpfr-4.1.0-a/tests/mpfr-test.h mpfr-4.1.0-b/tests/mpfr-test.h
1766 --- mpfr-4.1.0-a/tests/mpfr-test.h 2020-06-29 13:57:32.000000000 +0000
1767 +++ mpfr-4.1.0-b/tests/mpfr-test.h 2021-02-17 17:25:46.424981219 +0000
1770 #define mpfr_cmp0(x,y) (MPFR_ASSERTN (!MPFR_IS_NAN (x) && !MPFR_IS_NAN (y)), mpfr_cmp (x,y))
1771 #define mpfr_cmp_ui0(x,i) (MPFR_ASSERTN (!MPFR_IS_NAN (x)), mpfr_cmp_ui (x,i))
1772 +#define mpfr_cmp_si_2exp0(x,i,e) (MPFR_ASSERTN (!MPFR_IS_NAN (x)), \
1773 + mpfr_cmp_si_2exp (x,i,e))
1775 /* define CHECK_EXTERNAL if you want to check mpfr against another library
1776 with correct rounding. You'll probably have to modify mpfr_print_raw()
1777 diff -Naurd mpfr-4.1.0-a/tests/tj1.c mpfr-4.1.0-b/tests/tj1.c
1778 --- mpfr-4.1.0-a/tests/tj1.c 2020-01-08 18:11:13.000000000 +0000
1779 +++ mpfr-4.1.0-b/tests/tj1.c 2021-02-17 17:25:46.424981219 +0000
1781 /* since |x| is just above 2^e, |j1(x)| is just above 2^(e-1),
1782 thus y should be 2^(e-1) and the inexact flag should be
1783 of opposite sign of x */
1784 - MPFR_ASSERTN(mpfr_cmp_si_2exp (y, sign, e - 1) == 0);
1785 + MPFR_ASSERTN(mpfr_cmp_si_2exp0 (y, sign, e - 1) == 0);
1786 MPFR_ASSERTN(VSIGN (inex) * sign < 0);
1790 /* here |y| should be 0.5*2^emin and the inexact flag should
1791 have the sign of x */
1792 - MPFR_ASSERTN(mpfr_cmp_si_2exp (y, sign, e) == 0);
1793 + MPFR_ASSERTN(mpfr_cmp_si_2exp0 (y, sign, e) == 0);
1794 MPFR_ASSERTN(VSIGN (inex) * sign > 0);
1801 +/* a test that fails with GMP_CHECK_RANDOMIZE=1613146232984428
1802 + on revision 14429 */
1809 + mpfr_init2 (x, 221);
1810 + mpfr_init2 (y, 1);
1811 + mpfr_set_str (x, "1.6484611511696130037307738844228498447763863563070374544054791168614e+01", 10, MPFR_RNDN);
1812 + mpfr_clear_flags ();
1813 + inex = mpfr_j1 (y, x, MPFR_RNDZ);
1814 + MPFR_ASSERTN (mpfr_cmp_si_2exp0 (y, -1, -9) == 0);
1815 + MPFR_ASSERTN (inex > 0);
1816 + MPFR_ASSERTN (__gmpfr_flags == MPFR_FLAGS_INEXACT);
1822 main (int argc, char *argv[])
1826 tests_start_mpfr ();
1833 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
1834 --- mpfr-4.1.0-a/PATCHES 2021-03-09 13:55:43.183158946 +0000
1835 +++ mpfr-4.1.0-b/PATCHES 2021-03-09 13:55:43.223158508 +0000
1838 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
1839 --- mpfr-4.1.0-a/VERSION 2021-02-17 17:25:46.440981068 +0000
1840 +++ mpfr-4.1.0-b/VERSION 2021-03-09 13:55:43.223158508 +0000
1844 diff -Naurd mpfr-4.1.0-a/doc/mpfr.info mpfr-4.1.0-b/doc/mpfr.info
1845 --- mpfr-4.1.0-a/doc/mpfr.info 2020-07-10 11:59:13.000000000 +0000
1846 +++ mpfr-4.1.0-b/doc/mpfr.info 2021-03-09 13:55:51.167071327 +0000
1847 @@ -3217,7 +3217,11 @@
1849 Each function in this interface is also implemented as a macro for
1850 efficiency reasons: for example ‘mpfr_custom_init (s, p)’ uses the
1851 -macro, while ‘(mpfr_custom_init) (s, p)’ uses the function.
1852 +macro, while ‘(mpfr_custom_init) (s, p)’ uses the function. Note that
1853 +the macro may evaluate arguments multiple times (or none). Moreover,
1854 +macros implementing functions with the ‘void’ return type may not be
1855 +used in contexts where an expression is expected, e.g., inside
1856 +‘for(...)’ or before a comma operator.
1858 Note 1: MPFR functions may still initialize temporary floating-point
1859 numbers using ‘mpfr_init’ and similar functions. See Custom Allocation
1860 @@ -4579,13 +4583,13 @@
1862 * mpfr_csch: Transcendental Functions.
1864 -* mpfr_custom_get_exp: Custom Interface. (line 76)
1865 -* mpfr_custom_get_kind: Custom Interface. (line 66)
1866 -* mpfr_custom_get_significand: Custom Interface. (line 71)
1867 -* mpfr_custom_get_size: Custom Interface. (line 37)
1868 -* mpfr_custom_init: Custom Interface. (line 41)
1869 -* mpfr_custom_init_set: Custom Interface. (line 48)
1870 -* mpfr_custom_move: Custom Interface. (line 85)
1871 +* mpfr_custom_get_exp: Custom Interface. (line 80)
1872 +* mpfr_custom_get_kind: Custom Interface. (line 70)
1873 +* mpfr_custom_get_significand: Custom Interface. (line 75)
1874 +* mpfr_custom_get_size: Custom Interface. (line 41)
1875 +* mpfr_custom_init: Custom Interface. (line 45)
1876 +* mpfr_custom_init_set: Custom Interface. (line 52)
1877 +* mpfr_custom_move: Custom Interface. (line 89)
1878 * MPFR_DECL_INIT: Initialization Functions.
1880 * mpfr_digamma: Transcendental Functions.
1881 @@ -5165,19 +5169,19 @@
1882 Node: Memory Handling Functions
\x7f155904
1883 Node: Compatibility with MPF
\x7f157792
1884 Node: Custom Interface
\x7f160961
1885 -Node: Internals\x7f165592
1886 -Node: API Compatibility\x7f167136
1887 -Node: Type and Macro Changes\x7f169084
1888 -Node: Added Functions\x7f172267
1889 -Node: Changed Functions\x7f177074
1890 -Node: Removed Functions\x7f184433
1891 -Node: Other Changes\x7f185163
1892 -Node: MPFR and the IEEE 754 Standard\x7f186864
1893 -Node: Contributors\x7f189481
1894 -Node: References\x7f192620
1895 -Node: GNU Free Documentation License\x7f194501
1896 -Node: Concept Index\x7f217095
1897 -Node: Function and Type Index\x7f223168
1898 +Node: Internals\x7f165852
1899 +Node: API Compatibility\x7f167396
1900 +Node: Type and Macro Changes\x7f169344
1901 +Node: Added Functions\x7f172527
1902 +Node: Changed Functions\x7f177334
1903 +Node: Removed Functions\x7f184693
1904 +Node: Other Changes\x7f185423
1905 +Node: MPFR and the IEEE 754 Standard\x7f187124
1906 +Node: Contributors\x7f189741
1907 +Node: References\x7f192880
1908 +Node: GNU Free Documentation License\x7f194761
1909 +Node: Concept Index\x7f217355
1910 +Node: Function and Type Index\x7f223428
1914 diff -Naurd mpfr-4.1.0-a/doc/mpfr.texi mpfr-4.1.0-b/doc/mpfr.texi
1915 --- mpfr-4.1.0-a/doc/mpfr.texi 2020-07-10 11:52:33.000000000 +0000
1916 +++ mpfr-4.1.0-b/doc/mpfr.texi 2021-03-09 13:55:43.211158639 +0000
1917 @@ -3817,6 +3817,12 @@
1918 Each function in this interface is also implemented as a macro for
1919 efficiency reasons: for example @code{mpfr_custom_init (s, p)}
1920 uses the macro, while @code{(mpfr_custom_init) (s, p)} uses the function.
1921 +Note that the macro may evaluate arguments multiple times (or none).
1922 +Moreover, macros implementing functions with the @code{void} return type
1923 +may not be used in contexts where an expression is expected, e.g., inside
1924 +@code{for(...)} or before a comma operator.
1925 +@c These limitations with macros cannot be avoided in a C90 compatible way.
1926 +@c In the future, inline functions could be used.
1928 Note 1: MPFR functions may still initialize temporary floating-point numbers
1929 using @code{mpfr_init} and similar functions. See Custom Allocation (GNU MP)@.
1930 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
1931 --- mpfr-4.1.0-a/src/mpfr.h 2021-02-17 17:25:46.436981105 +0000
1932 +++ mpfr-4.1.0-b/src/mpfr.h 2021-03-09 13:55:43.223158508 +0000
1934 #define MPFR_VERSION_MAJOR 4
1935 #define MPFR_VERSION_MINOR 1
1936 #define MPFR_VERSION_PATCHLEVEL 0
1937 -#define MPFR_VERSION_STRING "4.1.0-p9"
1938 +#define MPFR_VERSION_STRING "4.1.0-p10"
1941 MPFR_USE_FILE: Define it to make MPFR define functions dealing
1942 @@ -833,23 +833,39 @@
1943 even if it produces faster and smaller code. */
1944 #ifndef MPFR_USE_NO_MACRO
1946 -/* Inlining these functions is both faster and smaller */
1947 -#define mpfr_nan_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_NAN)
1948 -#define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF)
1949 -#define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
1950 -#define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF)
1951 +/* In the implementation of these macros, we need to make sure that the
1952 + arguments are evaluated one time exactly and that type conversion is
1953 + done as it would be with a function. Tests should be added to ensure
1955 + Note that the macros for the custom interface are not concerned; the
1956 + MPFR manual has been clarified. */
1958 +/* Prevent x from being used as an lvalue.
1959 + Thanks to Wojtek Lerch and Tim Rentsch for the idea. */
1960 +#define MPFR_VALUE_OF(x) (0 ? (x) : (x))
1962 +/* The following macro converts the argument to mpfr_srcptr, as in type
1963 + conversion for function parameters. But it will detect disallowed
1964 + implicit conversions, e.g. when the argument has an integer type. */
1965 +#define MPFR_SRCPTR(x) ((mpfr_srcptr) (0 ? (x) : (mpfr_srcptr) (x)))
1966 +#define MPFR_GET_SIGN(_x) MPFR_VALUE_OF(MPFR_SIGN(MPFR_SRCPTR(_x)))
1968 +#define mpfr_nan_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_NAN)
1969 +#define mpfr_inf_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_INF)
1970 +#define mpfr_zero_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp == __MPFR_EXP_ZERO)
1971 +#define mpfr_regular_p(_x) (MPFR_SRCPTR(_x)->_mpfr_exp > __MPFR_EXP_INF)
1973 +/* mpfr_sgn is documented as a macro, thus the following code is fine.
1974 + But it would be safer to regard it as a function in some future
1976 #define mpfr_sgn(_x) \
1977 ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
1978 (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
1981 -/* Prevent them from using as lvalues */
1982 -#define MPFR_VALUE_OF(x) (0 ? (x) : (x))
1983 -#define mpfr_get_prec(_x) MPFR_VALUE_OF((_x)->_mpfr_prec)
1984 -#define mpfr_get_exp(_x) MPFR_VALUE_OF((_x)->_mpfr_exp)
1985 -/* Note 1: If need be, the MPFR_VALUE_OF can be used for other expressions
1986 - (of any type). Thanks to Wojtek Lerch and Tim Rentsch for the idea.
1987 - Note 2: Defining mpfr_get_exp() as a macro has the effect to disable
1988 +#define mpfr_get_prec(_x) MPFR_VALUE_OF(MPFR_SRCPTR(_x)->_mpfr_prec)
1989 +#define mpfr_get_exp(_x) MPFR_VALUE_OF(MPFR_SRCPTR(_x)->_mpfr_exp)
1990 +/* Note: Defining mpfr_get_exp() as a macro has the effect to disable
1991 the check that the argument is a pure FP number (done in the function);
1992 this increases the risk of undetected error and makes debugging more
1993 complex. Is it really worth in practice? (Potential FIXME) */
1994 @@ -861,11 +877,17 @@
1996 #define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
1997 #define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
1998 -#define mpfr_set(a,b,r) mpfr_set4(a,b,r,MPFR_SIGN(b))
1999 +#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
2000 +#define mpfr_set(a,b,r) \
2001 + __extension__ ({ \
2002 + mpfr_srcptr _p = (b); \
2003 + mpfr_set4(a,_p,r,MPFR_SIGN(_p)); \
2006 #define mpfr_abs(a,b,r) mpfr_set4(a,b,r,1)
2007 -#define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c))
2008 +#define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_GET_SIGN(c))
2009 #define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
2010 -#define mpfr_signbit(x) (MPFR_SIGN(x) < 0)
2011 +#define mpfr_signbit(x) (MPFR_GET_SIGN(x) < 0)
2012 #define mpfr_cmp(b, c) mpfr_cmp3(b, c, 1)
2013 #define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
2014 #define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
2015 diff -Naurd mpfr-4.1.0-a/src/ubf.c mpfr-4.1.0-b/src/ubf.c
2016 --- mpfr-4.1.0-a/src/ubf.c 2020-02-12 01:38:57.000000000 +0000
2017 +++ mpfr-4.1.0-b/src/ubf.c 2021-03-09 13:55:43.211158639 +0000
2019 mpfr_get_prec (b), mpfr_log_prec, b,
2020 mpfr_get_prec (c), mpfr_log_prec, c),
2022 - mpfr_get_prec (a), mpfr_log_prec, a));
2023 + mpfr_get_prec ((mpfr_ptr) a), mpfr_log_prec, a));
2025 MPFR_ASSERTD ((mpfr_ptr) a != b);
2026 MPFR_ASSERTD ((mpfr_ptr) a != c);
2027 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
2028 --- mpfr-4.1.0-a/src/version.c 2021-02-17 17:25:46.440981068 +0000
2029 +++ mpfr-4.1.0-b/src/version.c 2021-03-09 13:55:43.223158508 +0000
2032 mpfr_get_version (void)
2034 - return "4.1.0-p9";
2035 + return "4.1.0-p10";
2037 diff -Naurd mpfr-4.1.0-a/tests/mpfr-test.h mpfr-4.1.0-b/tests/mpfr-test.h
2038 --- mpfr-4.1.0-a/tests/mpfr-test.h 2021-02-17 17:25:46.424981219 +0000
2039 +++ mpfr-4.1.0-b/tests/mpfr-test.h 2021-03-09 13:55:43.211158639 +0000
2041 #define STRINGIZE(S) #S
2042 #define MAKE_STR(S) STRINGIZE(S)
2044 +/* In C (but not C++), mpfr_ptr and mpfr_srcptr arguments can be provided
2045 + in a different pointer type, such as void *. For functions implemented
2046 + as macros, the type conversion for the function parameters will not be
2047 + done by the compiler, which means potential bugs in these implementations
2048 + if we forget to take these unusual cases into account. So we need to test
2049 + such arguments, in order to make sure that the arguments are converted to
2050 + the expected type when needed.
2052 + However, at least when the function is not implemented as a macro (which
2053 + is the case when MPFR_USE_NO_MACRO is defined), such tests with void *
2054 + arguments are not valid in C++; therefore, we will not do the cast to
2055 + void * if the __cplusplus macro is defined. And with GCC compilers (and
2056 + compatible), we will ignore the -Wc++-compat option around these tests.
2058 + Note: in the future, inline functions could be used instead of macros,
2059 + and such tests would become useless (except to detect compiler bugs).
2061 +#if defined (__cplusplus)
2062 +#define VOIDP_CAST(X) (X)
2064 +#define VOIDP_CAST(X) ((void *) (X))
2065 +#if defined (__GNUC__)
2066 +#define IGNORE_CPP_COMPAT
2070 #if defined (__cplusplus)
2073 diff -Naurd mpfr-4.1.0-a/tests/tcopysign.c mpfr-4.1.0-b/tests/tcopysign.c
2074 --- mpfr-4.1.0-a/tests/tcopysign.c 2020-01-08 18:11:13.000000000 +0000
2075 +++ mpfr-4.1.0-b/tests/tcopysign.c 2021-03-09 13:55:43.211158639 +0000
2077 copysign_variant (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y,
2078 mpfr_rnd_t rnd_mode, int k)
2081 + int a = 0, b = 0, c = 0;
2083 + /* invalid sign, to test that the sign is always correctly set */
2084 + MPFR_SIGN (z) = 0;
2088 + MPFR_ASSERTN (MPFR_PREC (z) >= MPFR_PREC (x));
2089 + mpfr_set (z, x, MPFR_RNDN);
2096 mpfr_clear_flags ();
2100 - mpfr_copysign (z, x, y, MPFR_RNDN);
2101 + mpfr_copysign (z, p, y, rnd_mode);
2104 - (mpfr_copysign) (z, x, y, MPFR_RNDN);
2105 + (mpfr_copysign) (z, p, y, rnd_mode);
2108 - mpfr_setsign (z, x, mpfr_signbit (y), MPFR_RNDN);
2109 +#ifdef IGNORE_CPP_COMPAT
2110 +#pragma GCC diagnostic push
2111 +#pragma GCC diagnostic ignored "-Wc++-compat"
2113 + mpfr_copysign ((a++, VOIDP_CAST(z)),
2114 + (b++, VOIDP_CAST(p)),
2115 + (c++, VOIDP_CAST(y)), rnd_mode);
2116 +#ifdef IGNORE_CPP_COMPAT
2117 +#pragma GCC diagnostic pop
2119 + MPFR_ASSERTN (a == 1);
2120 + MPFR_ASSERTN (b == 1);
2121 + MPFR_ASSERTN (c == 1);
2124 - mpfr_setsign (z, x, (mpfr_signbit) (y), MPFR_RNDN);
2125 + mpfr_setsign (z, p, mpfr_signbit (y), rnd_mode);
2128 - (mpfr_setsign) (z, x, mpfr_signbit (y), MPFR_RNDN);
2129 + mpfr_setsign (z, p, (mpfr_signbit) (y), rnd_mode);
2132 - (mpfr_setsign) (z, x, (mpfr_signbit) (y), MPFR_RNDN);
2133 + (mpfr_setsign) (z, p, mpfr_signbit (y), rnd_mode);
2136 + (mpfr_setsign) (z, p, (mpfr_signbit) (y), rnd_mode);
2139 +#ifdef IGNORE_CPP_COMPAT
2140 +#pragma GCC diagnostic push
2141 +#pragma GCC diagnostic ignored "-Wc++-compat"
2143 + mpfr_setsign ((a++, VOIDP_CAST(z)),
2144 + (b++, VOIDP_CAST(p)),
2145 + mpfr_signbit ((c++, VOIDP_CAST(y))), rnd_mode);
2146 +#ifdef IGNORE_CPP_COMPAT
2147 +#pragma GCC diagnostic pop
2149 + MPFR_ASSERTN (a == 1);
2150 + MPFR_ASSERTN (b == 1);
2151 + MPFR_ASSERTN (c == 1);
2157 for (i = 0; i <= 1; i++)
2158 for (j = 0; j <= 1; j++)
2159 - for (k = 0; k <= 5; k++)
2160 + for (k = 0; k < 16; k++)
2163 i ? MPFR_SET_NEG (x) : MPFR_SET_POS (x);
2164 diff -Naurd mpfr-4.1.0-a/tests/texceptions.c mpfr-4.1.0-b/tests/texceptions.c
2165 --- mpfr-4.1.0-a/tests/texceptions.c 2020-01-08 18:11:13.000000000 +0000
2166 +++ mpfr-4.1.0-b/tests/texceptions.c 2021-03-09 13:55:43.211158639 +0000
2167 @@ -103,10 +103,26 @@
2168 check_get_prec (void)
2174 - if (mpfr_get_prec (x) != 17 || (mpfr_get_prec)(x) != 17)
2176 + if (mpfr_get_prec (x) != 17 || (mpfr_get_prec) (x) != 17)
2177 PRINT_ERROR ("mpfr_get_prec");
2179 +#ifdef IGNORE_CPP_COMPAT
2180 +#pragma GCC diagnostic push
2181 +#pragma GCC diagnostic ignored "-Wc++-compat"
2184 + if (mpfr_get_prec ((i++, VOIDP_CAST(x))) != 17)
2185 + PRINT_ERROR ("mpfr_get_prec (2)");
2187 +#ifdef IGNORE_CPP_COMPAT
2188 +#pragma GCC diagnostic pop
2191 + MPFR_ASSERTN (i == 1);
2195 diff -Naurd mpfr-4.1.0-a/tests/tisnan.c mpfr-4.1.0-b/tests/tisnan.c
2196 --- mpfr-4.1.0-a/tests/tisnan.c 2020-01-08 18:11:13.000000000 +0000
2197 +++ mpfr-4.1.0-b/tests/tisnan.c 2021-03-09 13:55:43.211158639 +0000
2198 @@ -27,180 +27,235 @@
2204 + /* We need to check that when the function is implemented by a macro,
2205 + it behaves correctly. */
2206 +#define ARG (i++, VOIDP_CAST(x))
2207 +#define CHECK MPFR_ASSERTN (i == ++j)
2209 tests_start_mpfr ();
2214 + /* The following should yield a compilation error when the functions
2215 + are implemented as macros. Change 0 to 1 above in order to test. */
2216 + (void) (mpfr_nan_p (1L));
2217 + (void) (mpfr_inf_p (1L));
2218 + (void) (mpfr_number_p (1L));
2219 + (void) (mpfr_zero_p (1L));
2220 + (void) (mpfr_regular_p (1L));
2223 +#ifdef IGNORE_CPP_COMPAT
2224 +#pragma GCC diagnostic push
2225 +#pragma GCC diagnostic ignored "-Wc++-compat"
2228 /* check +infinity gives non-zero for mpfr_inf_p only */
2229 mpfr_set_ui (x, 1L, MPFR_RNDZ);
2230 mpfr_div_ui (x, x, 0L, MPFR_RNDZ);
2231 - if (mpfr_nan_p (x) || (mpfr_nan_p) (x) )
2232 + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG))
2234 printf ("Error: mpfr_nan_p(+Inf) gives non-zero\n");
2237 - if (mpfr_inf_p (x) == 0)
2239 + if (!mpfr_inf_p (x) || !(mpfr_inf_p) (x) || !mpfr_inf_p (ARG))
2241 printf ("Error: mpfr_inf_p(+Inf) gives zero\n");
2244 - if (mpfr_number_p (x) || (mpfr_number_p) (x) )
2246 + if (mpfr_number_p (x) || (mpfr_number_p) (x) || mpfr_number_p (ARG))
2248 printf ("Error: mpfr_number_p(+Inf) gives non-zero\n");
2251 - if (mpfr_zero_p (x) || (mpfr_zero_p) (x) )
2253 + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG))
2255 printf ("Error: mpfr_zero_p(+Inf) gives non-zero\n");
2258 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2260 + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG))
2262 printf ("Error: mpfr_regular_p(+Inf) gives non-zero\n");
2268 mpfr_neg (x, x, MPFR_RNDN);
2269 - if (mpfr_nan_p (x) || (mpfr_nan_p(x)))
2270 + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG))
2272 printf ("Error: mpfr_nan_p(-Inf) gives non-zero\n");
2275 - if (mpfr_inf_p (x) == 0)
2277 + if (!mpfr_inf_p (x) || !(mpfr_inf_p) (x) || !mpfr_inf_p (ARG))
2279 printf ("Error: mpfr_inf_p(-Inf) gives zero\n");
2282 - if (mpfr_number_p (x) || (mpfr_number_p)(x) )
2284 + if (mpfr_number_p (x) || (mpfr_number_p) (x) || mpfr_number_p (ARG))
2286 printf ("Error: mpfr_number_p(-Inf) gives non-zero\n");
2289 - if (mpfr_zero_p (x) || (mpfr_zero_p)(x) )
2291 + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG))
2293 printf ("Error: mpfr_zero_p(-Inf) gives non-zero\n");
2296 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2298 + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG))
2300 printf ("Error: mpfr_regular_p(-Inf) gives non-zero\n");
2306 mpfr_sub (x, x, x, MPFR_RNDN);
2307 - if (mpfr_nan_p (x) == 0)
2308 + if (!mpfr_nan_p (x) || !(mpfr_nan_p) (x) || !mpfr_nan_p (ARG))
2310 printf ("Error: mpfr_nan_p(NaN) gives zero\n");
2313 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2315 + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG))
2317 printf ("Error: mpfr_inf_p(NaN) gives non-zero\n");
2320 - if (mpfr_number_p (x) || (mpfr_number_p) (x) )
2322 + if (mpfr_number_p (x) || (mpfr_number_p) (x) || mpfr_number_p (ARG))
2324 printf ("Error: mpfr_number_p(NaN) gives non-zero\n");
2327 - if (mpfr_zero_p (x) || (mpfr_zero_p)(x) )
2329 + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG))
2331 printf ("Error: mpfr_number_p(NaN) gives non-zero\n");
2334 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2336 + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG))
2338 printf ("Error: mpfr_regular_p(NaN) gives non-zero\n");
2343 /* same for a regular number */
2344 mpfr_set_ui (x, 1, MPFR_RNDN);
2345 - if (mpfr_nan_p (x) || (mpfr_nan_p)(x))
2346 + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG))
2348 printf ("Error: mpfr_nan_p(1) gives non-zero\n");
2351 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2353 + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG))
2355 printf ("Error: mpfr_inf_p(1) gives non-zero\n");
2358 - if (mpfr_number_p (x) == 0)
2360 + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG))
2362 printf ("Error: mpfr_number_p(1) gives zero\n");
2365 - if (mpfr_zero_p (x) || (mpfr_zero_p) (x) )
2367 + if (mpfr_zero_p (x) || (mpfr_zero_p) (x) || mpfr_zero_p (ARG))
2369 printf ("Error: mpfr_zero_p(1) gives non-zero\n");
2372 - if (mpfr_regular_p (x) == 0 || (mpfr_regular_p) (x) == 0)
2374 + if (!mpfr_regular_p (x) || !(mpfr_regular_p) (x) || !mpfr_regular_p (ARG))
2376 printf ("Error: mpfr_regular_p(1) gives zero\n");
2382 mpfr_set_ui (x, 0, MPFR_RNDN);
2383 - if (mpfr_nan_p (x) || (mpfr_nan_p)(x))
2384 + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG))
2386 printf ("Error: mpfr_nan_p(+0) gives non-zero\n");
2389 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2391 + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG))
2393 printf ("Error: mpfr_inf_p(+0) gives non-zero\n");
2396 - if (mpfr_number_p (x) == 0)
2398 + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG))
2400 printf ("Error: mpfr_number_p(+0) gives zero\n");
2403 - if (mpfr_zero_p (x) == 0 )
2405 + if (!mpfr_zero_p (x) || !(mpfr_zero_p) (x) || !mpfr_zero_p (ARG))
2407 printf ("Error: mpfr_zero_p(+0) gives zero\n");
2410 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2412 + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG))
2414 printf ("Error: mpfr_regular_p(+0) gives non-zero\n");
2420 mpfr_set_ui (x, 0, MPFR_RNDN);
2421 mpfr_neg (x, x, MPFR_RNDN);
2422 - if (mpfr_nan_p (x) || (mpfr_nan_p)(x))
2423 + if (mpfr_nan_p (x) || (mpfr_nan_p) (x) || mpfr_nan_p (ARG))
2425 printf ("Error: mpfr_nan_p(-0) gives non-zero\n");
2428 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2430 + if (mpfr_inf_p (x) || (mpfr_inf_p) (x) || mpfr_inf_p (ARG))
2432 printf ("Error: mpfr_inf_p(-0) gives non-zero\n");
2435 - if (mpfr_number_p (x) == 0)
2437 + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG))
2439 printf ("Error: mpfr_number_p(-0) gives zero\n");
2442 - if (mpfr_zero_p (x) == 0 )
2444 + if (!mpfr_zero_p (x) || !(mpfr_zero_p) (x) || !mpfr_zero_p (ARG))
2446 printf ("Error: mpfr_zero_p(-0) gives zero\n");
2449 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2451 + if (mpfr_regular_p (x) || (mpfr_regular_p) (x) || mpfr_regular_p (ARG))
2453 printf ("Error: mpfr_regular_p(-0) gives non-zero\n");
2458 +#ifdef IGNORE_CPP_COMPAT
2459 +#pragma GCC diagnostic pop
2464 diff -Naurd mpfr-4.1.0-a/tests/tset.c mpfr-4.1.0-b/tests/tset.c
2465 --- mpfr-4.1.0-a/tests/tset.c 2020-01-08 18:11:13.000000000 +0000
2466 +++ mpfr-4.1.0-b/tests/tset.c 2021-03-09 13:55:43.207158683 +0000
2469 check_ternary_value (void)
2476 @@ -226,28 +226,45 @@
2478 if (rnd == MPFR_RNDF) /* the test below makes no sense */
2480 - inexact = mpfr_set (y, x, (mpfr_rnd_t) rnd);
2481 - cmp = mpfr_cmp (y, x);
2482 - if (((inexact == 0) && (cmp != 0)) ||
2483 - ((inexact > 0) && (cmp <= 0)) ||
2484 - ((inexact < 0) && (cmp >= 0)))
2486 - printf ("Wrong ternary value in mpfr_set for %s: expected"
2488 - mpfr_print_rnd_mode ((mpfr_rnd_t) rnd), cmp,
2492 - /* Test mpfr_set function too */
2493 - inexact = (mpfr_set) (y, x, (mpfr_rnd_t) rnd);
2494 - cmp = mpfr_cmp (y, x);
2495 - if (((inexact == 0) && (cmp != 0)) ||
2496 - ((inexact > 0) && (cmp <= 0)) ||
2497 - ((inexact < 0) && (cmp >= 0)))
2498 + for (k = 0; k < 3; k++)
2500 - printf ("Wrong ternary value in mpfr_set(2): expected %d,"
2501 - " got %d\n", cmp, inexact);
2503 + int a = 0, b = 0, c = 0;
2508 + inexact = mpfr_set (y, x, (mpfr_rnd_t) rnd);
2511 + inexact = (mpfr_set) (y, x, (mpfr_rnd_t) rnd);
2514 +#ifdef IGNORE_CPP_COMPAT
2515 +#pragma GCC diagnostic push
2516 +#pragma GCC diagnostic ignored "-Wc++-compat"
2518 + inexact = mpfr_set ((a++, VOIDP_CAST(y)),
2519 + (b++, VOIDP_CAST(x)),
2520 + (c++, (mpfr_rnd_t) rnd));
2521 +#ifdef IGNORE_CPP_COMPAT
2522 +#pragma GCC diagnostic pop
2524 + MPFR_ASSERTN (a == 1);
2525 + MPFR_ASSERTN (b == 1);
2526 + MPFR_ASSERTN (c == 1);
2529 + cmp = mpfr_cmp (y, x);
2530 + if (((inexact == 0) && (cmp != 0)) ||
2531 + ((inexact > 0) && (cmp <= 0)) ||
2532 + ((inexact < 0) && (cmp >= 0)))
2534 + printf ("Wrong ternary value in mpfr_set for %s (%d):"
2535 + " expected %d, got %d\n",
2536 + mpfr_print_rnd_mode ((mpfr_rnd_t) rnd),
2543 diff -Naurd mpfr-4.1.0-a/tests/tset_exp.c mpfr-4.1.0-b/tests/tset_exp.c
2544 --- mpfr-4.1.0-a/tests/tset_exp.c 2020-01-08 18:11:13.000000000 +0000
2545 +++ mpfr-4.1.0-b/tests/tset_exp.c 2021-03-09 13:55:43.211158639 +0000
2549 mpfr_exp_t emin, emax, e;
2552 tests_start_mpfr ();
2555 e = (mpfr_get_exp) (x);
2556 MPFR_ASSERTN (e == emin);
2558 +#ifdef IGNORE_CPP_COMPAT
2559 +#pragma GCC diagnostic push
2560 +#pragma GCC diagnostic ignored "-Wc++-compat"
2562 + e = mpfr_get_exp ((i++, VOIDP_CAST(x)));
2563 +#ifdef IGNORE_CPP_COMPAT
2564 +#pragma GCC diagnostic pop
2566 + MPFR_ASSERTN (e == emin);
2567 + MPFR_ASSERTN (i == 1);
2569 ret = mpfr_set_exp (x, -1);
2570 MPFR_ASSERTN (ret == 0 && mpfr_cmp_ui_2exp (x, 1, -2) == 0);
2572 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
2573 --- mpfr-4.1.0-a/PATCHES 2021-03-09 13:58:00.889650773 +0000
2574 +++ mpfr-4.1.0-b/PATCHES 2021-03-09 13:58:00.937650249 +0000
2577 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
2578 --- mpfr-4.1.0-a/VERSION 2021-03-09 13:55:43.223158508 +0000
2579 +++ mpfr-4.1.0-b/VERSION 2021-03-09 13:58:00.937650249 +0000
2583 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
2584 --- mpfr-4.1.0-a/src/mpfr.h 2021-03-09 13:55:43.223158508 +0000
2585 +++ mpfr-4.1.0-b/src/mpfr.h 2021-03-09 13:58:00.933650293 +0000
2587 #define MPFR_VERSION_MAJOR 4
2588 #define MPFR_VERSION_MINOR 1
2589 #define MPFR_VERSION_PATCHLEVEL 0
2590 -#define MPFR_VERSION_STRING "4.1.0-p10"
2591 +#define MPFR_VERSION_STRING "4.1.0-p11"
2594 MPFR_USE_FILE: Define it to make MPFR define functions dealing
2595 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
2596 --- mpfr-4.1.0-a/src/version.c 2021-03-09 13:55:43.223158508 +0000
2597 +++ mpfr-4.1.0-b/src/version.c 2021-03-09 13:58:00.933650293 +0000
2600 mpfr_get_version (void)
2602 - return "4.1.0-p10";
2603 + return "4.1.0-p11";
2605 diff -Naurd mpfr-4.1.0-a/tests/tset_si.c mpfr-4.1.0-b/tests/tset_si.c
2606 --- mpfr-4.1.0-a/tests/tset_si.c 2020-03-26 11:51:33.000000000 +0000
2607 +++ mpfr-4.1.0-b/tests/tset_si.c 2021-03-09 13:58:00.917650467 +0000
2608 @@ -127,27 +127,29 @@
2609 power of 2 is exact, unless underflow/overflow occurs.
2610 The tests on the exponent below avoid integer overflows
2611 (ep[i] may take extreme values). */
2612 - e = mpfr_get_exp (x1);
2613 mpfr_clear_flags ();
2614 - if (j != 0 && ep[i] < __gmpfr_emin - e) /* underflow */
2617 + e = MPFR_GET_EXP (x1);
2618 + if (ep[i] < __gmpfr_emin - e) /* underflow */
2621 (rnd == MPFR_RNDN &&
2622 - (ep[i] < __gmpfr_emin - mpfr_get_exp (y) - 1 ||
2623 + (ep[i] < __gmpfr_emin - MPFR_GET_EXP (y) - 1 ||
2624 IS_POW2 (sign * j))) ?
2625 MPFR_RNDZ : (mpfr_rnd_t) rnd;
2626 inex1 = mpfr_underflow (x1, r, sign);
2627 flags1 = __gmpfr_flags;
2629 - else if (j != 0 && ep[i] > __gmpfr_emax - e) /* overflow */
2630 + else if (ep[i] > __gmpfr_emax - e) /* overflow */
2632 inex1 = mpfr_overflow (x1, (mpfr_rnd_t) rnd, sign);
2633 flags1 = __gmpfr_flags;
2638 - mpfr_set_exp (x1, ep[i] + e);
2639 + mpfr_set_exp (x1, ep[i] + e);
2641 flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0;
2644 diff -Naurd mpfr-4.1.0-a/tests/tset_sj.c mpfr-4.1.0-b/tests/tset_sj.c
2645 --- mpfr-4.1.0-a/tests/tset_sj.c 2020-06-01 10:39:52.000000000 +0000
2646 +++ mpfr-4.1.0-b/tests/tset_sj.c 2021-03-09 13:58:00.917650467 +0000
2647 @@ -225,27 +225,29 @@
2648 power of 2 is exact, unless underflow/overflow occurs.
2649 The tests on the exponent below avoid integer overflows
2650 (ep[i] may take extreme values). */
2651 - e = mpfr_get_exp (x1);
2652 mpfr_clear_flags ();
2653 - if (j != 0 && ep[i] < __gmpfr_emin - e) /* underflow */
2656 + e = MPFR_GET_EXP (x1);
2657 + if (ep[i] < __gmpfr_emin - e) /* underflow */
2660 (rnd == MPFR_RNDN &&
2661 - (ep[i] < __gmpfr_emin - mpfr_get_exp (y) - 1 ||
2662 + (ep[i] < __gmpfr_emin - MPFR_GET_EXP (y) - 1 ||
2663 IS_POW2 (sign * j))) ?
2664 MPFR_RNDZ : (mpfr_rnd_t) rnd;
2665 inex1 = mpfr_underflow (x1, r, sign);
2666 flags1 = __gmpfr_flags;
2668 - else if (j != 0 && ep[i] > __gmpfr_emax - e) /* overflow */
2669 + else if (ep[i] > __gmpfr_emax - e) /* overflow */
2671 inex1 = mpfr_overflow (x1, (mpfr_rnd_t) rnd, sign);
2672 flags1 = __gmpfr_flags;
2677 - mpfr_set_exp (x1, ep[i] + e);
2678 + mpfr_set_exp (x1, ep[i] + e);
2680 flags1 = inex1 != 0 ? MPFR_FLAGS_INEXACT : 0;
2683 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
2684 --- mpfr-4.1.0-a/PATCHES 2021-04-23 09:49:34.648281897 +0000
2685 +++ mpfr-4.1.0-b/PATCHES 2021-04-23 09:49:34.696281616 +0000
2688 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
2689 --- mpfr-4.1.0-a/VERSION 2021-03-09 13:58:00.937650249 +0000
2690 +++ mpfr-4.1.0-b/VERSION 2021-04-23 09:49:34.696281616 +0000
2694 diff -Naurd mpfr-4.1.0-a/src/get_str.c mpfr-4.1.0-b/src/get_str.c
2695 --- mpfr-4.1.0-a/src/get_str.c 2020-06-18 17:17:18.000000000 +0000
2696 +++ mpfr-4.1.0-b/src/get_str.c 2021-04-23 09:49:34.680281710 +0000
2697 @@ -2484,6 +2484,8 @@
2699 mpfr_get_str_ndigits (int b, mpfr_prec_t p)
2701 + MPFR_SAVE_EXPO_DECL (expo);
2703 MPFR_ASSERTN (2 <= b && b <= 62);
2705 /* deal first with power of two bases, since even for those, mpfr_ceil_mul
2706 @@ -2497,17 +2499,26 @@
2707 return 1 + (p + k - 2) / k;
2710 + MPFR_SAVE_EXPO_MARK (expo);
2712 /* the value returned by mpfr_ceil_mul is guaranteed to be
2713 1 + ceil(p*log(2)/log(b)) for p < 186564318007 (it returns one more
2714 for p=186564318007 and b=7 or 49) */
2715 MPFR_STAT_STATIC_ASSERT (MPFR_PREC_BITS >= 64 || MPFR_PREC_BITS <= 32);
2717 #if MPFR_PREC_BITS >= 64
2718 /* 64-bit numbers are supported by the C implementation, so that we can
2719 use the large constant below. If MPFR_PREC_BITS <= 32, the condition
2720 is always satisfied, so that we do not need any test. */
2721 - if (MPFR_LIKELY (p < 186564318007))
2722 + (MPFR_LIKELY (p < 186564318007))
2726 - return 1 + mpfr_ceil_mul (IS_POW2(b) ? p - 1 : p, b, 1);
2728 + size_t ret = 1 + mpfr_ceil_mul (IS_POW2(b) ? p - 1 : p, b, 1);
2729 + MPFR_SAVE_EXPO_FREE (expo);
2733 /* Now p is large and b is not a power of two. The code below works for any
2734 value of p and b, as long as b is not a power of two. Indeed, in such a
2735 @@ -2541,6 +2552,8 @@
2740 + MPFR_SAVE_EXPO_FREE (expo);
2744 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
2745 --- mpfr-4.1.0-a/src/mpfr.h 2021-03-09 13:58:00.933650293 +0000
2746 +++ mpfr-4.1.0-b/src/mpfr.h 2021-04-23 09:49:34.692281639 +0000
2748 #define MPFR_VERSION_MAJOR 4
2749 #define MPFR_VERSION_MINOR 1
2750 #define MPFR_VERSION_PATCHLEVEL 0
2751 -#define MPFR_VERSION_STRING "4.1.0-p11"
2752 +#define MPFR_VERSION_STRING "4.1.0-p12"
2755 MPFR_USE_FILE: Define it to make MPFR define functions dealing
2756 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
2757 --- mpfr-4.1.0-a/src/version.c 2021-03-09 13:58:00.933650293 +0000
2758 +++ mpfr-4.1.0-b/src/version.c 2021-04-23 09:49:34.696281616 +0000
2761 mpfr_get_version (void)
2763 - return "4.1.0-p11";
2764 + return "4.1.0-p12";
2766 diff -Naurd mpfr-4.1.0-a/tests/tget_str.c mpfr-4.1.0-b/tests/tget_str.c
2767 --- mpfr-4.1.0-a/tests/tget_str.c 2020-01-08 18:11:13.000000000 +0000
2768 +++ mpfr-4.1.0-b/tests/tget_str.c 2021-04-23 09:49:34.680281710 +0000
2769 @@ -1311,6 +1311,33 @@
2774 +test_ndigits_aux (int b, mpfr_prec_t p, size_t expected_m)
2777 + mpfr_exp_t old_emin, old_emax, e[] = { MPFR_EMIN_MIN, 0, MPFR_EMAX_MAX };
2778 + mpfr_flags_t flags;
2781 + old_emin = mpfr_get_emin ();
2782 + old_emax = mpfr_get_emax ();
2784 + i = randlimb () % (numberof (e) + 1);
2785 + if (i < numberof (e))
2791 + __gmpfr_flags = flags = randlimb () & MPFR_FLAGS_ALL;
2792 + m = mpfr_get_str_ndigits (b, p);
2793 + MPFR_ASSERTN (m == expected_m);
2794 + MPFR_ASSERTN (__gmpfr_flags == flags);
2796 + set_emin (old_emin);
2797 + set_emax (old_emax);
2800 /* test of mpfr_get_str_ndigits */
2803 @@ -1319,61 +1346,61 @@
2805 /* for b=2, we have 1 + ceil((p-1)*log(2)/log(b)) = p */
2806 for (p = MPFR_PREC_MIN; p <= 1024; p++)
2807 - MPFR_ASSERTN(mpfr_get_str_ndigits (2, p) == p);
2808 + test_ndigits_aux (2, p, p);
2810 /* for b=4, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/2)
2812 for (p = MPFR_PREC_MIN; p <= 1024; p++)
2813 - MPFR_ASSERTN(mpfr_get_str_ndigits (4, p) == 1 + (p / 2));
2814 + test_ndigits_aux (4, p, 1 + (p / 2));
2816 /* for b=8, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/3)
2817 = 1 + floor((p+1)/3) */
2818 for (p = MPFR_PREC_MIN; p <= 1024; p++)
2819 - MPFR_ASSERTN(mpfr_get_str_ndigits (8, p) == 1 + ((p + 1) / 3));
2820 + test_ndigits_aux (8, p, 1 + ((p + 1) / 3));
2822 /* for b=16, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/4)
2823 = 1 + floor((p+2)/4) */
2824 for (p = MPFR_PREC_MIN; p <= 1024; p++)
2825 - MPFR_ASSERTN(mpfr_get_str_ndigits (16, p) == 1 + ((p + 2) / 4));
2826 + test_ndigits_aux (16, p, 1 + ((p + 2) / 4));
2828 /* for b=32, we have 1 + ceil((p-1)*log(2)/log(b)) = 1 + ceil((p-1)/5)
2829 = 1 + floor((p+3)/5) */
2830 for (p = MPFR_PREC_MIN; p <= 1024; p++)
2831 - MPFR_ASSERTN(mpfr_get_str_ndigits (32, p) == 1 + ((p + 3) / 5));
2832 + test_ndigits_aux (32, p, 1 + ((p + 3) / 5));
2835 - MPFR_ASSERTN(mpfr_get_str_ndigits (57, 35) == 8);
2836 + test_ndigits_aux (57, 35, 8);
2839 - MPFR_ASSERTN(mpfr_get_str_ndigits (31, 649) == 133);
2840 + test_ndigits_aux (31, 649, 133);
2843 - MPFR_ASSERTN(mpfr_get_str_ndigits (43, 5041) == 931);
2844 + test_ndigits_aux (43, 5041, 931);
2847 - MPFR_ASSERTN(mpfr_get_str_ndigits (41, 17771) == 3319);
2848 + test_ndigits_aux (41, 17771, 3319);
2850 /* 20th convergent of log(2)/log(3) */
2851 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 630138897) == 397573381);
2852 + test_ndigits_aux (3, 630138897, 397573381);
2854 #if MPFR_PREC_BITS >= 64
2855 /* 21st convergent of log(2)/log(3) */
2856 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 9809721694) == 6189245292);
2857 + test_ndigits_aux (3, 9809721694, 6189245292);
2859 /* 22nd convergent of log(2)/log(3) */
2860 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 10439860591) == 6586818672);
2861 + test_ndigits_aux (3, 10439860591, 6586818672);
2863 /* 23rd convergent of log(2)/log(3) */
2864 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 103768467013) == 65470613322);
2865 + test_ndigits_aux (3, 103768467013, 65470613322);
2867 /* 24th convergent of log(2)/log(3) */
2868 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 217976794617) == 137528045314);
2869 + test_ndigits_aux (3, 217976794617, 137528045314);
2871 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 1193652440098) == 753110839882);
2872 + test_ndigits_aux (3, 1193652440098, 753110839882);
2874 - MPFR_ASSERTN(mpfr_get_str_ndigits (3, 683381996816440) == 431166034846569);
2875 + test_ndigits_aux (3, 683381996816440, 431166034846569);
2877 - MPFR_ASSERTN(mpfr_get_str_ndigits (7, 186564318007) == 66455550933);
2878 + test_ndigits_aux (7, 186564318007, 66455550933);
2882 diff -Naurd mpfr-4.1.0-a/PATCHES mpfr-4.1.0-b/PATCHES
2883 --- mpfr-4.1.0-a/PATCHES 2021-05-17 16:09:00.574477185 +0000
2884 +++ mpfr-4.1.0-b/PATCHES 2021-05-17 16:09:00.754476587 +0000
2886 +vasprintf-prec-zero
2887 diff -Naurd mpfr-4.1.0-a/VERSION mpfr-4.1.0-b/VERSION
2888 --- mpfr-4.1.0-a/VERSION 2021-04-23 09:49:34.696281616 +0000
2889 +++ mpfr-4.1.0-b/VERSION 2021-05-17 16:09:00.754476587 +0000
2893 diff -Naurd mpfr-4.1.0-a/src/mpfr.h mpfr-4.1.0-b/src/mpfr.h
2894 --- mpfr-4.1.0-a/src/mpfr.h 2021-04-23 09:49:34.692281639 +0000
2895 +++ mpfr-4.1.0-b/src/mpfr.h 2021-05-17 16:09:00.754476587 +0000
2897 #define MPFR_VERSION_MAJOR 4
2898 #define MPFR_VERSION_MINOR 1
2899 #define MPFR_VERSION_PATCHLEVEL 0
2900 -#define MPFR_VERSION_STRING "4.1.0-p12"
2901 +#define MPFR_VERSION_STRING "4.1.0-p13"
2904 MPFR_USE_FILE: Define it to make MPFR define functions dealing
2905 diff -Naurd mpfr-4.1.0-a/src/vasprintf.c mpfr-4.1.0-b/src/vasprintf.c
2906 --- mpfr-4.1.0-a/src/vasprintf.c 2021-02-11 12:48:27.354242922 +0000
2907 +++ mpfr-4.1.0-b/src/vasprintf.c 2021-05-17 16:09:00.598477107 +0000
2908 @@ -635,7 +635,13 @@
2910 buffer_cat (struct string_buffer *b, const char *s, size_t len)
2912 - MPFR_ASSERTD (len > 0);
2913 + /* If len == 0, which is possible when outputting an integer 0
2914 + (either a native one or mpfr_prec_t) with precision field = 0,
2915 + do nothing. This test is not necessary since the code below is
2916 + valid for len == 0, but this is safer, just in case. */
2920 MPFR_ASSERTD (len <= strlen (s));
2922 if (buffer_incr_len (b, len))
2923 diff -Naurd mpfr-4.1.0-a/src/version.c mpfr-4.1.0-b/src/version.c
2924 --- mpfr-4.1.0-a/src/version.c 2021-04-23 09:49:34.696281616 +0000
2925 +++ mpfr-4.1.0-b/src/version.c 2021-05-17 16:09:00.754476587 +0000
2928 mpfr_get_version (void)
2930 - return "4.1.0-p12";
2931 + return "4.1.0-p13";
2933 diff -Naurd mpfr-4.1.0-a/tests/tsprintf.c mpfr-4.1.0-b/tests/tsprintf.c
2934 --- mpfr-4.1.0-a/tests/tsprintf.c 2020-04-08 22:39:35.000000000 +0000
2935 +++ mpfr-4.1.0-b/tests/tsprintf.c 2021-05-17 16:09:00.598477107 +0000
2936 @@ -193,6 +193,10 @@
2937 sprintf (buf, "%d", i);
2938 check_vsprintf (buf, "%d", i);
2940 + check_vsprintf ("0", "%d", 0);
2941 + check_vsprintf ("", "%.d", 0);
2942 + check_vsprintf ("", "%.0d", 0);
2944 sprintf (buf, "%e", d);
2945 check_vsprintf (buf, "%e", d);
2948 mpfr_prec_t p = 128;
2952 - mpfr_init2 (x, p);
2954 /* specifier 'P' for precision */
2955 check_vsprintf ("128", "%Pu", p);
2956 check_vsprintf ("00128", "%.5Pu", p);
2957 @@ -247,9 +248,19 @@
2958 check_vsprintf ("0200:", "%0#+ -Po:", p);
2959 check_vsprintf ("+0000128 :", "%0+ *.*Pd:", -9, 7, p);
2960 check_vsprintf ("+12345 :", "%0+ -*.*Pd:", -9, -3, (mpfr_prec_t) 12345);
2961 + check_vsprintf ("0", "%Pu", (mpfr_prec_t) 0);
2962 /* Do not add a test like "%05.1Pd" as MS Windows is buggy: when
2963 a precision is given, the '0' flag must be ignored. */
2965 + /* specifier 'P' with precision field 0 */
2966 + check_vsprintf ("128", "%.Pu", p);
2967 + check_vsprintf ("128", "%.0Pd", p);
2968 + /* check_vsprintf ("", "%.Pu", (mpfr_prec_t) 0); */
2969 + check_vsprintf ("", "%.0Pd", (mpfr_prec_t) 0);
2972 + mpfr_init2 (x, 128);
2974 /* special numbers */
2975 mpfr_set_inf (x, 1);
2976 check_sprintf (pinf_str, "%Re", x);