sbcl rebuild
[arch-packages.git] / mpfr / repos / core-x86_64 / patches.diff
blob3ecb16f1b7bb6c1a079e838f73c7716d96a9ecc6
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
4 @@ -0,0 +1 @@
5 +decimal128-conv
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
9 @@ -1 +1 @@
10 -4.1.0
11 +4.1.0-p1
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
15 @@ -40,22 +40,21 @@
16 static _Decimal128
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 */
24 static _Decimal128
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 */
32 static _Decimal128
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
44 @@ -27,7 +27,7 @@
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"
51 /* User macros:
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
56 @@ -25,5 +25,5 @@
57 const char *
58 mpfr_get_version (void)
60 - return "4.1.0";
61 + return "4.1.0-p1";
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
66 @@ -0,0 +1 @@
67 +random_deviate
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
71 @@ -1 +1 @@
72 -4.1.0-p1
73 +4.1.0-p2
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
77 @@ -27,7 +27,7 @@
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"
84 /* User macros:
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
89 @@ -289,6 +289,7 @@
90 mpfr_random_size_t p = mpfr_get_prec (z); /* Number of bits in result */
91 mpz_t t;
92 int inex;
93 + mpfr_exp_t negxe;
95 if (n == 0)
97 @@ -370,14 +371,22 @@
98 mpz_setbit (t, 0); /* Set the trailing bit so result is always inexact */
99 if (neg)
100 mpz_neg (t, t);
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;
111 + else
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
116 * inexact value.
118 - inex = mpfr_set_z_2exp (z, t, -x->e, rnd);
119 + inex = mpfr_set_z_2exp (z, t, negxe, rnd);
120 mpz_clear (t);
121 return inex;
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
126 @@ -25,5 +25,5 @@
127 const char *
128 mpfr_get_version (void)
130 - return "4.1.0-p1";
131 + return "4.1.0-p2";
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
136 @@ -0,0 +1 @@
137 +set_z_2exp-overflow
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
141 @@ -1 +1 @@
142 -4.1.0-p2
143 +4.1.0-p3
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
147 @@ -27,7 +27,7 @@
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"
154 /* User macros:
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
159 @@ -28,10 +28,11 @@
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;
165 int k, sign_z, inex;
166 mp_limb_t *fp, *zp;
167 - mpfr_exp_t exp;
168 + mpfr_exp_t exp, nmax;
169 + mpfr_uexp_t uexp;
171 sign_z = mpz_sgn (z);
172 if (MPFR_UNLIKELY (sign_z == 0)) /* ignore the exponent for 0 */
173 @@ -43,10 +44,15 @@
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
192 @@ -64,8 +70,21 @@
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
203 + mpfr_exp_t. */
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
218 @@ -25,5 +25,5 @@
219 const char *
220 mpfr_get_version (void)
222 - return "4.1.0-p2";
223 + return "4.1.0-p3";
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
228 @@ -97,49 +97,149 @@
229 mpfr_get_si is a rather indirect test of a low level routine. */
231 static void
232 -check (long i, mpfr_rnd_t rnd)
233 +check (long i, mpfr_rnd_t rnd, int reduced)
235 - mpfr_t f;
236 + mpfr_t f1, f2, f3;
237 mpz_t z;
238 - mpfr_exp_t e;
239 + mpfr_exp_t e, old_emin, old_emax;
240 int inex;
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);
250 mpz_init (z);
251 mpz_set_ui (z, i);
252 /* the following loop ensures that no overflow occurs */
254 e = randexp ();
255 while (e > mpfr_get_emax () - CHAR_BIT * sizeof(long));
256 - inex = mpfr_set_z_2exp (f, z, e, rnd);
257 - if (inex != 0)
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);
274 + flags_out (0);
275 + printf ("got "); mpfr_dump (f1);
276 + printf ("with inex = %d and flags =", inex);
277 + flags_out (flags);
278 exit (1);
280 - mpfr_div_2si (f, f, e, rnd);
281 - if (mpfr_get_si (f, MPFR_RNDZ) != i)
283 + if (reduced)
285 - printf ("Error in mpfr_set_z_2exp for i=%ld e=", i);
286 - if (e < LONG_MIN)
287 - printf ("(<LONG_MIN)");
288 - else if (e > LONG_MAX)
289 - printf ("(>LONG_MAX)");
290 - else
291 - printf ("%ld", (long) e);
292 - printf (" rnd_mode=%d\n", rnd);
293 - printf ("expected %ld\n", i);
294 - printf ("got "); mpfr_dump (f);
295 - exit (1);
296 + mpfr_exp_t ef, emin, emax;
297 + int inex2, inex3;
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) &&
316 + flags2 == flags3))
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);
329 + exit (1);
332 + mpfr_set_emin (old_emin);
333 + mpfr_set_emax (old_emax);
335 - mpfr_clear (f);
337 + mpfr_clears (f1, f2, f3, (mpfr_ptr) 0);
338 mpz_clear (z);
341 +static void
342 +check_huge (void)
344 + if (getenv ("MPFR_CHECK_LARGEMEM") != NULL)
346 + mpfr_t x;
347 + mpz_t z;
348 + long e;
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),
358 + this fails with:
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
363 + Got 0
364 + */
365 + mpz_init_set_ui (z, 17);
366 + e = 0x7ffffff0;
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");
374 + printf ("Got ");
375 + mpfr_dump (x);
376 + exit (1);
378 + mpz_clear (z);
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");
388 + printf ("Got ");
389 + mpfr_dump (x);
390 + exit (1);
392 + mpz_clear (z);
394 + mpfr_clear (x);
399 main (int argc, char *argv[])
401 @@ -147,11 +247,13 @@
403 tests_start_mpfr ();
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);
410 check0 ();
412 + check_huge ();
414 tests_end_mpfr ();
416 return 0;
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
420 @@ -0,0 +1 @@
421 +prototypes
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
425 @@ -1 +1 @@
426 -4.1.0-p3
427 +4.1.0-p4
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
431 @@ -56,7 +56,7 @@
434 static void
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
443 @@ -181,7 +181,7 @@
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;
451 mpz_t t, u, v;
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
455 @@ -36,7 +36,7 @@
456 Return PREC(y) when the truncated series does not converge.
458 static mpfr_exp_t
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 */
463 mpfr_t erru, errs;
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
467 @@ -80,7 +80,7 @@
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;
475 int inex;
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
479 @@ -291,7 +291,8 @@
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,
485 + mpfr_ptr x)
487 unsigned char *result;
488 mpfr_uexp_t uexp;
489 @@ -372,7 +373,7 @@
490 * than 128 bits).
492 static int
493 -mpfr_fpif_read_exponent_from_file (mpfr_t x, FILE * fh)
494 +mpfr_fpif_read_exponent_from_file (mpfr_ptr x, FILE * fh)
496 mpfr_exp_t exponent;
497 mpfr_uexp_t uexp;
498 @@ -456,7 +457,7 @@
499 * format
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;
507 @@ -492,7 +493,7 @@
508 * Assume buffer is not NULL.
510 static void
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;
516 @@ -522,7 +523,7 @@
517 * return 0 if successful
520 -mpfr_fpif_export (FILE *fh, mpfr_t x)
521 +mpfr_fpif_export (FILE *fh, mpfr_ptr x)
523 int status;
524 unsigned char *buf;
525 @@ -582,7 +583,7 @@
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)
532 int status;
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
537 @@ -31,7 +31,7 @@
538 for determinating the relative error.
540 static int
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)
544 int i;
545 mpfr_t s, u, v, w;
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
549 @@ -31,7 +31,7 @@
550 precision should be >= 4.
552 static void
553 -mpfr_gamma_alpha (mpfr_t s, mpfr_prec_t p)
554 +mpfr_gamma_alpha (mpfr_ptr s, mpfr_prec_t p)
556 MPFR_LOG_FUNC
557 (("p=%Pu", 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,
567 + mpfr_rnd_t);
569 __MPFR_DECLSPEC double mpfr_scale2 (double, int);
571 @@ -2485,7 +2486,7 @@
572 mpfr_prec_t);
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
583 @@ -27,7 +27,7 @@
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"
590 /* User macros:
591 MPFR_USE_FILE: Define it to make MPFR define functions dealing
592 @@ -781,8 +781,8 @@
593 __MPFR_DECLSPEC int mpfr_strtofr (mpfr_ptr, const char *, char **, int,
594 mpfr_rnd_t);
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,
613 + mpfr_rnd_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,
616 + mpfr_rnd_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
623 @@ -155,7 +155,7 @@
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;
631 int inex;
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
635 @@ -35,7 +35,7 @@
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))
644 @@ -54,7 +54,7 @@
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.
653 @@ -82,7 +82,7 @@
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
665 @@ -64,7 +64,7 @@
667 /* allocate and set to (0,1) */
668 void
669 -mpfr_random_deviate_init (mpfr_random_deviate_t x)
670 +mpfr_random_deviate_init (mpfr_random_deviate_ptr x)
672 mpz_init (x->f);
673 x->e = 0;
674 @@ -72,21 +72,22 @@
676 /* reset to (0,1) */
677 void
678 -mpfr_random_deviate_reset (mpfr_random_deviate_t x)
679 +mpfr_random_deviate_reset (mpfr_random_deviate_ptr x)
681 x->e = 0;
684 /* deallocate */
685 void
686 -mpfr_random_deviate_clear (mpfr_random_deviate_t x)
687 +mpfr_random_deviate_clear (mpfr_random_deviate_ptr x)
689 mpz_clear (x->f);
692 /* swap two random deviates */
693 void
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;
699 unsigned long t;
700 @@ -107,7 +108,7 @@
702 /* ensure x has at least k bits */
703 static void
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 */
709 @@ -223,7 +224,7 @@
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);
718 @@ -243,7 +244,7 @@
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,
724 gmp_randstate_t r)
726 if (k == 0)
727 @@ -256,7 +257,8 @@
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,
734 gmp_randstate_t r)
736 mpfr_random_size_t k = 1;
737 @@ -280,7 +282,7 @@
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
749 @@ -76,7 +76,7 @@
750 /* set mpfr_t z = (neg ? -1 : 1) * (n + x) */
751 __MPFR_DECLSPEC int
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
761 @@ -61,7 +61,7 @@
762 and prepares rop to give it one more bit of precision
763 and to save its old value within it. */
764 void
765 -mpfr_round_nearest_away_begin (mpfr_t rop)
766 +mpfr_round_nearest_away_begin (mpfr_ptr rop)
768 mpfr_t tmp;
769 mp_size_t xsize;
770 @@ -129,7 +129,7 @@
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)
777 mpfr_t tmp;
778 mp_size_t xsize;
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
782 @@ -26,13 +26,13 @@
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)
796 if (j >= 0)
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
801 @@ -23,7 +23,7 @@
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)
808 char *p;
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
813 @@ -29,13 +29,13 @@
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)
827 int cnt, inex;
828 mp_size_t i, k;
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
832 @@ -463,7 +463,7 @@
833 Return err such that the relative error is bounded by 2^err ulps.
835 static int
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;
841 @@ -577,7 +577,7 @@
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)
848 int inexs, inexc;
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
853 @@ -226,7 +226,7 @@
854 BUT if it returns 0 (NAN or INF), the ternary value is also '0'
855 (ie NAN and INF are exact) */
856 static int
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;
862 @@ -451,7 +451,7 @@
863 and the precision of x.
864 Returns the ternary value. */
865 static int
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;
870 mpfr_exp_t exp;
871 @@ -934,7 +934,7 @@
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,
877 mpfr_rnd_t rnd)
879 int res;
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
883 @@ -963,7 +963,7 @@
884 #define NDIGITS 8
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)
891 size_t ndigits;
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
895 @@ -25,5 +25,5 @@
896 const char *
897 mpfr_get_version (void)
899 - return "4.1.0-p3";
900 + return "4.1.0-p4";
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
905 @@ -35,7 +35,7 @@
906 sum(tc[i]*product((s+2j)*(s+2j-1)/n^2,j=1..i-1), i=1..p)*s*n^(-s-1)
908 static void
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)
912 mpfr_t s1, d, u;
913 unsigned long n2;
914 @@ -130,7 +130,7 @@
915 n - an integer
916 Output: sum - a floating-point number approximating sum(1/i^s, i=1..n-1) */
917 static void
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)
921 mpfr_t u, s1;
922 int i;
923 @@ -158,7 +158,7 @@
924 Output: z - Zeta(s) rounded to the precision of z with direction rnd_mode
926 static int
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;
932 @@ -356,8 +356,8 @@
933 At input, p is Pi rounded down.
934 The comments in the code are for rnd = RNDD. */
935 static void
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)
941 mpz_t sint;
943 @@ -432,7 +432,7 @@
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;
951 long add;
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
955 @@ -24,7 +24,7 @@
957 /* set bit n of x to b, where bit 0 is the most significant one */
958 static void
959 -set_bit (mpfr_t x, unsigned int n, int b)
960 +set_bit (mpfr_ptr x, unsigned int n, int b)
962 unsigned l;
963 mp_size_t xn;
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
967 @@ -369,7 +369,7 @@
968 /* given y = o(x/u), x, u, find the inexact flag by
969 multiplying y by u */
970 static int
971 -get_inexact (mpfr_t y, mpfr_t x, mpfr_t u)
972 +get_inexact (mpfr_ptr y, mpfr_ptr x, mpfr_ptr u)
974 mpfr_t xx;
975 int inex;
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
979 @@ -23,7 +23,7 @@
980 #include "mpfr-test.h"
982 static void
983 -teq (mpfr_t x)
984 +teq (mpfr_ptr x)
986 mpfr_t y;
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
991 @@ -26,7 +26,7 @@
992 * exponential distribution. We only take differences of this function so the
993 * offset doesn't matter; here Phi(0) = 0. */
994 static void
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);
1000 @@ -43,7 +43,7 @@
1001 * TAOCP, Vol 2, 3.3.1, Table 1. It more accurate than the similar formula,
1002 * DLMF 8.11.10. */
1003 static void
1004 -chisq_prob (mpfr_t q, long nu, mpfr_t chisqp)
1005 +chisq_prob (mpfr_ptr q, long nu, mpfr_ptr chisqp)
1007 mpfr_t t;
1008 mpfr_rnd_t rnd;
1009 @@ -170,7 +170,7 @@
1010 * this function. low precision means prec = 2, 3, or 4. High values of
1011 * precision will result in integer overflow. */
1012 static long
1013 -sequential (mpfr_t x)
1014 +sequential (mpfr_ptr x)
1016 long expt, prec;
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
1021 @@ -24,7 +24,7 @@
1023 /* check both mpfr_fmma and mpfr_fmms */
1024 static void
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
1033 @@ -62,8 +62,8 @@
1036 static void
1037 -test_failed (mpfr_t erem, mpfr_t grem, int eret, int gret, mpfr_t x, mpfr_t y,
1038 - mpfr_rnd_t rnd)
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);
1044 @@ -83,7 +83,7 @@
1047 static void
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)
1051 int inex0, inex1;
1052 mpfr_t r1;
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
1056 @@ -65,7 +65,7 @@
1057 const int prec_max_printf = 5000;
1059 static void
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
1068 @@ -890,7 +890,7 @@
1069 computing with a working precision p2. Assume that x is not an
1070 integer <= 2. */
1071 static void
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
1080 @@ -26,7 +26,7 @@
1081 * for the normal distribution. We only take differences of this function so
1082 * the offset doesn't matter; here Phi(0) = 0. */
1083 static void
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);
1089 @@ -44,7 +44,7 @@
1090 * TAOCP, Vol 2, 3.3.1, Table 1. It more accurate than the similar formula,
1091 * DLMF 8.11.10. */
1092 static void
1093 -chisq_prob (mpfr_t q, long nu, mpfr_t chisqp)
1094 +chisq_prob (mpfr_ptr q, long nu, mpfr_ptr chisqp)
1096 mpfr_t t;
1097 mpfr_rnd_t rnd;
1098 @@ -166,7 +166,7 @@
1099 * this function. low precision means prec = 2, 3, or 4. High values of
1100 * precision will result in integer overflow. */
1101 static long
1102 -sequential (mpfr_t x)
1103 +sequential (mpfr_ptr x)
1105 long expt, prec;
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
1110 @@ -74,7 +74,7 @@
1111 int stdout_redirect;
1113 static void
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
1122 @@ -367,7 +367,7 @@
1123 #endif
1125 static void
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
1134 @@ -23,7 +23,7 @@
1135 #include "mpfr-test.h"
1137 static void
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);
1143 @@ -43,7 +43,7 @@
1145 /* check against sinh, cosh */
1146 static void
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;
1151 int isc, is, ic;
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
1155 @@ -33,7 +33,7 @@
1157 static void
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);
1164 @@ -44,7 +44,7 @@
1167 static void
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
1176 @@ -59,7 +59,7 @@
1179 static void
1180 -get_exact_sum (mpfr_t sum, mpfr_t *tab, int n)
1181 +get_exact_sum (mpfr_ptr sum, mpfr_t *tab, int n)
1183 int i;
1185 @@ -1198,7 +1198,7 @@
1188 static int
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)
1192 int ret, i;
1193 switch (n)
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
1197 @@ -0,0 +1 @@
1198 +digamma-hugemem
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
1202 @@ -1 +1 @@
1203 -4.1.0-p4
1204 +4.1.0-p5
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))
1214 - q = MPFR_EXP(x);
1215 - else
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). */
1229 +#define GUARD 30
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)
1241 + <= ulp(t)
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);
1246 mpfr_clear (t);
1247 @@ -235,6 +243,21 @@
1248 mpfr_clear (t);
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);
1258 + q = MPFR_EXP(x);
1260 + else
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);
1268 mpfr_init2 (t, p);
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
1272 @@ -27,7 +27,7 @@
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"
1279 /* User macros:
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
1284 @@ -25,5 +25,5 @@
1285 const char *
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
1294 @@ -49,12 +49,54 @@
1295 mpfr_clear (y);
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.
1303 +static void
1304 +bug20210206 (void)
1306 +#define NPREC 4
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));
1328 + mpfr_clear (x);
1331 + for (i = 0; i < NPREC; i++)
1332 + mpfr_clear (y[i]);
1333 + mpfr_clear (z);
1335 + set_emin (emin);
1336 + set_emax (emax);
1340 main (int argc, char *argv[])
1342 tests_start_mpfr ();
1344 special ();
1345 + bug20210206 ();
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
1352 @@ -0,0 +1 @@
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
1357 @@ -1 +1 @@
1358 -4.1.0-p5
1359 +4.1.0-p6
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);
1374 - if (errt > erru)
1375 - errt = errt + 1;
1376 - else if (errt == erru)
1377 - errt = errt + 2;
1378 - else
1379 - errt = erru + 1;
1380 - if (MPFR_CAN_ROUND (t, p - errt, MPFR_PREC(y), rnd_mode))
1381 - break;
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);
1393 + if (errt > erru)
1394 + errt = errt + 1;
1395 + else if (errt == erru)
1396 + errt = errt + 2;
1397 + else
1398 + errt = erru + 1;
1399 + if (MPFR_CAN_ROUND (t, p - errt, MPFR_PREC(y), rnd_mode))
1400 + break;
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
1408 @@ -27,7 +27,7 @@
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"
1415 /* User macros:
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
1420 @@ -25,5 +25,5 @@
1421 const char *
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
1430 @@ -90,6 +90,26 @@
1431 set_emax (emax);
1434 +/* another test that fails with GMP_CHECK_RANDOMIZE=1612741376857003
1435 + on revision 14398 */
1436 +static void
1437 +bug20210208 (void)
1439 + mpfr_t x, y;
1440 + int inex;
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);
1450 + mpfr_clear (x);
1451 + mpfr_clear (y);
1455 main (int argc, char *argv[])
1457 @@ -97,6 +117,7 @@
1459 special ();
1460 bug20210206 ();
1461 + bug20210208 ();
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
1468 @@ -0,0 +1 @@
1469 +jn-interm-zero
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
1473 @@ -1 +1 @@
1474 -4.1.0-p6
1475 +4.1.0-p7
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
1479 @@ -69,6 +69,8 @@
1480 MPFR_ZIV_INIT (loop, w);
1481 for (;;)
1483 + int ok = 1;
1485 mpfr_set_prec (c, w);
1486 mpfr_init2 (s, w);
1487 mpfr_init2 (P, w);
1488 @@ -92,6 +94,13 @@
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))
1495 + ok = 0;
1496 + goto clear;
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);
1502 @@ -257,6 +266,9 @@
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);
1508 + clear:
1509 mpfr_clear (s);
1510 mpfr_clear (P);
1511 mpfr_clear (Q);
1512 @@ -266,8 +278,7 @@
1513 mpfr_clear (err_s);
1514 mpfr_clear (err_u);
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)))
1519 break;
1520 if (diverge != 0)
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
1525 @@ -27,7 +27,7 @@
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"
1532 /* User macros:
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
1537 @@ -25,5 +25,5 @@
1538 const char *
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
1547 @@ -27,6 +27,25 @@
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 */
1552 +static void
1553 +bug20210208 (void)
1555 + mpfr_t x, y;
1556 + int inex;
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);
1566 + mpfr_clear (x);
1567 + mpfr_clear (y);
1571 main (int argc, char *argv[])
1573 @@ -35,6 +54,8 @@
1575 tests_start_mpfr ();
1577 + bug20210208 ();
1579 mpfr_init (x);
1580 mpfr_init (y);
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
1585 @@ -0,0 +1 @@
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
1590 @@ -1 +1 @@
1591 -4.1.0-p7
1592 +4.1.0-p8
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;
1605 - else
1606 - e1 ++;
1607 - e1 ++; /* rounding error for mpfr_sub */
1608 - if (MPFR_CAN_ROUND (v, p - e1, MPFR_PREC(y), rnd_mode))
1609 - break;
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;
1617 + else
1618 + e1 ++;
1619 + e1 ++; /* rounding error for mpfr_sub */
1620 + if (MPFR_CAN_ROUND (v, p - e1, MPFR_PREC(y), rnd_mode))
1621 + break;
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);
1636 else
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
1641 @@ -27,7 +27,7 @@
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"
1648 /* User macros:
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
1653 @@ -25,5 +25,5 @@
1654 const char *
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 @@
1664 mpfr_clear (y);
1667 +/* another test that fails with GMP_CHECK_RANDOMIZE=1613197421465830
1668 + on revision 14429 */
1669 +static void
1670 +bug20210215 (void)
1672 + mpfr_t x, y;
1673 + int inex;
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);
1683 + mpfr_clear (x);
1684 + mpfr_clear (y);
1688 main (int argc, char *argv[])
1690 @@ -118,6 +138,7 @@
1691 special ();
1692 bug20210206 ();
1693 bug20210208 ();
1694 + bug20210215 ();
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
1701 @@ -0,0 +1 @@
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
1706 @@ -1 +1 @@
1707 -4.1.0-p8
1708 +4.1.0-p9
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
1712 @@ -69,7 +69,7 @@
1713 MPFR_ZIV_INIT (loop, w);
1714 for (;;)
1716 - int ok = 1;
1717 + int ok = 0;
1719 mpfr_set_prec (c, w);
1720 mpfr_init2 (s, w);
1721 @@ -96,10 +96,7 @@
1723 /* if s or c is zero, MPFR_GET_EXP will fail below */
1724 if (MPFR_IS_ZERO(s) || MPFR_IS_ZERO(c))
1726 - ok = 0;
1727 - goto clear;
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 */
1733 @@ -227,6 +224,9 @@
1734 mpfr_sub (s, c, s, MPFR_RNDN);
1735 #endif
1737 + if (MPFR_IS_ZERO(s))
1738 + goto clear; /* with ok=0 */
1739 + ok = 1;
1740 if ((n & 2) != 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
1746 @@ -27,7 +27,7 @@
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"
1753 /* User macros:
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
1758 @@ -25,5 +25,5 @@
1759 const char *
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
1768 @@ -191,6 +191,8 @@
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
1780 @@ -55,14 +55,14 @@
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);
1788 else
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);
1797 @@ -72,6 +72,26 @@
1798 mpfr_clear (y);
1801 +/* a test that fails with GMP_CHECK_RANDOMIZE=1613146232984428
1802 + on revision 14429 */
1803 +static void
1804 +bug20210215 (void)
1806 + mpfr_t x, y;
1807 + int inex;
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);
1817 + mpfr_clear (x);
1818 + mpfr_clear (y);
1822 main (int argc, char *argv[])
1824 @@ -79,6 +99,8 @@
1826 tests_start_mpfr ();
1828 + bug20210215 ();
1830 test_small ();
1832 mpfr_init (x);
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
1836 @@ -0,0 +1 @@
1837 +macros
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
1841 @@ -1 +1 @@
1842 -4.1.0-p9
1843 +4.1.0-p10
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 @@
1861 (line 115)
1862 * mpfr_csch: Transcendental Functions.
1863 (line 180)
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.
1879 (line 77)
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
1911 \x1f
1912 End Tag Table
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
1933 @@ -27,7 +27,7 @@
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"
1940 /* User macros:
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
1954 + that.
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
1975 + MPFR version. */
1976 #define mpfr_sgn(_x) \
1977 ((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
1978 (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
1979 MPFR_SIGN (_x))
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)); \
2004 + })
2005 +#endif
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
2018 @@ -78,7 +78,7 @@
2019 mpfr_get_prec (b), mpfr_log_prec, b,
2020 mpfr_get_prec (c), mpfr_log_prec, c),
2021 ("a[%Pu]=%.*Rg",
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
2030 @@ -25,5 +25,5 @@
2031 const char *
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
2040 @@ -92,6 +92,32 @@
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)
2063 +#else
2064 +#define VOIDP_CAST(X) ((void *) (X))
2065 +#if defined (__GNUC__)
2066 +#define IGNORE_CPP_COMPAT
2067 +#endif
2068 +#endif
2070 #if defined (__cplusplus)
2071 extern "C" {
2072 #endif
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
2076 @@ -26,26 +26,72 @@
2077 copysign_variant (mpfr_ptr z, mpfr_srcptr x, mpfr_srcptr y,
2078 mpfr_rnd_t rnd_mode, int k)
2080 + mpfr_srcptr p;
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;
2086 + if (k >= 8)
2088 + MPFR_ASSERTN (MPFR_PREC (z) >= MPFR_PREC (x));
2089 + mpfr_set (z, x, MPFR_RNDN);
2090 + p = z;
2091 + k -= 8;
2093 + else
2094 + p = x;
2096 mpfr_clear_flags ();
2097 switch (k)
2099 case 0:
2100 - mpfr_copysign (z, x, y, MPFR_RNDN);
2101 + mpfr_copysign (z, p, y, rnd_mode);
2102 return;
2103 case 1:
2104 - (mpfr_copysign) (z, x, y, MPFR_RNDN);
2105 + (mpfr_copysign) (z, p, y, rnd_mode);
2106 return;
2107 case 2:
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"
2112 +#endif
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
2118 +#endif
2119 + MPFR_ASSERTN (a == 1);
2120 + MPFR_ASSERTN (b == 1);
2121 + MPFR_ASSERTN (c == 1);
2122 return;
2123 case 3:
2124 - mpfr_setsign (z, x, (mpfr_signbit) (y), MPFR_RNDN);
2125 + mpfr_setsign (z, p, mpfr_signbit (y), rnd_mode);
2126 return;
2127 case 4:
2128 - (mpfr_setsign) (z, x, mpfr_signbit (y), MPFR_RNDN);
2129 + mpfr_setsign (z, p, (mpfr_signbit) (y), rnd_mode);
2130 return;
2131 case 5:
2132 - (mpfr_setsign) (z, x, (mpfr_signbit) (y), MPFR_RNDN);
2133 + (mpfr_setsign) (z, p, mpfr_signbit (y), rnd_mode);
2134 + return;
2135 + case 6:
2136 + (mpfr_setsign) (z, p, (mpfr_signbit) (y), rnd_mode);
2137 + return;
2138 + case 7:
2139 +#ifdef IGNORE_CPP_COMPAT
2140 +#pragma GCC diagnostic push
2141 +#pragma GCC diagnostic ignored "-Wc++-compat"
2142 +#endif
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
2148 +#endif
2149 + MPFR_ASSERTN (a == 1);
2150 + MPFR_ASSERTN (b == 1);
2151 + MPFR_ASSERTN (c == 1);
2152 return;
2155 @@ -64,7 +110,7 @@
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++)
2162 mpfr_set_nan (x);
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)
2170 mpfr_t x;
2171 + int i = 0;
2173 mpfr_init2 (x, 17);
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"
2182 +#endif
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
2189 +#endif
2191 + MPFR_ASSERTN (i == 1);
2192 mpfr_clear (x);
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 @@
2199 main (void)
2201 mpfr_t x;
2202 + int i = 0, j = 0;
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 ();
2211 mpfr_init (x);
2213 +#if 0
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));
2221 +#endif
2223 +#ifdef IGNORE_CPP_COMPAT
2224 +#pragma GCC diagnostic push
2225 +#pragma GCC diagnostic ignored "-Wc++-compat"
2226 +#endif
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");
2235 exit (1);
2237 - if (mpfr_inf_p (x) == 0)
2238 + CHECK;
2239 + if (!mpfr_inf_p (x) || !(mpfr_inf_p) (x) || !mpfr_inf_p (ARG))
2241 printf ("Error: mpfr_inf_p(+Inf) gives zero\n");
2242 exit (1);
2244 - if (mpfr_number_p (x) || (mpfr_number_p) (x) )
2245 + CHECK;
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");
2249 exit (1);
2251 - if (mpfr_zero_p (x) || (mpfr_zero_p) (x) )
2252 + CHECK;
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");
2256 exit (1);
2258 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2259 + CHECK;
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");
2263 exit (1);
2265 + CHECK;
2267 /* same for -Inf */
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");
2273 exit (1);
2275 - if (mpfr_inf_p (x) == 0)
2276 + CHECK;
2277 + if (!mpfr_inf_p (x) || !(mpfr_inf_p) (x) || !mpfr_inf_p (ARG))
2279 printf ("Error: mpfr_inf_p(-Inf) gives zero\n");
2280 exit (1);
2282 - if (mpfr_number_p (x) || (mpfr_number_p)(x) )
2283 + CHECK;
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");
2287 exit (1);
2289 - if (mpfr_zero_p (x) || (mpfr_zero_p)(x) )
2290 + CHECK;
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");
2294 exit (1);
2296 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2297 + CHECK;
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");
2301 exit (1);
2303 + CHECK;
2305 /* same for NaN */
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");
2311 exit (1);
2313 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2314 + CHECK;
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");
2318 exit (1);
2320 - if (mpfr_number_p (x) || (mpfr_number_p) (x) )
2321 + CHECK;
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");
2325 exit (1);
2327 - if (mpfr_zero_p (x) || (mpfr_zero_p)(x) )
2328 + CHECK;
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");
2332 exit (1);
2334 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2335 + CHECK;
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");
2339 exit (1);
2341 + CHECK;
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");
2349 exit (1);
2351 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2352 + CHECK;
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");
2356 exit (1);
2358 - if (mpfr_number_p (x) == 0)
2359 + CHECK;
2360 + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG))
2362 printf ("Error: mpfr_number_p(1) gives zero\n");
2363 exit (1);
2365 - if (mpfr_zero_p (x) || (mpfr_zero_p) (x) )
2366 + CHECK;
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");
2370 exit (1);
2372 - if (mpfr_regular_p (x) == 0 || (mpfr_regular_p) (x) == 0)
2373 + CHECK;
2374 + if (!mpfr_regular_p (x) || !(mpfr_regular_p) (x) || !mpfr_regular_p (ARG))
2376 printf ("Error: mpfr_regular_p(1) gives zero\n");
2377 exit (1);
2379 + CHECK;
2381 /* Same for +0 */
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");
2387 exit (1);
2389 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2390 + CHECK;
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");
2394 exit (1);
2396 - if (mpfr_number_p (x) == 0)
2397 + CHECK;
2398 + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG))
2400 printf ("Error: mpfr_number_p(+0) gives zero\n");
2401 exit (1);
2403 - if (mpfr_zero_p (x) == 0 )
2404 + CHECK;
2405 + if (!mpfr_zero_p (x) || !(mpfr_zero_p) (x) || !mpfr_zero_p (ARG))
2407 printf ("Error: mpfr_zero_p(+0) gives zero\n");
2408 exit (1);
2410 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2411 + CHECK;
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");
2415 exit (1);
2417 + CHECK;
2419 /* Same for -0 */
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");
2426 exit (1);
2428 - if (mpfr_inf_p (x) || (mpfr_inf_p)(x) )
2429 + CHECK;
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");
2433 exit (1);
2435 - if (mpfr_number_p (x) == 0)
2436 + CHECK;
2437 + if (!mpfr_number_p (x) || !(mpfr_number_p) (x) || !mpfr_number_p (ARG))
2439 printf ("Error: mpfr_number_p(-0) gives zero\n");
2440 exit (1);
2442 - if (mpfr_zero_p (x) == 0 )
2443 + CHECK;
2444 + if (!mpfr_zero_p (x) || !(mpfr_zero_p) (x) || !mpfr_zero_p (ARG))
2446 printf ("Error: mpfr_zero_p(-0) gives zero\n");
2447 exit (1);
2449 - if (mpfr_regular_p (x) || (mpfr_regular_p) (x) )
2450 + CHECK;
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");
2454 exit (1);
2456 + CHECK;
2458 +#ifdef IGNORE_CPP_COMPAT
2459 +#pragma GCC diagnostic pop
2460 +#endif
2462 mpfr_clear (x);
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
2467 @@ -207,7 +207,7 @@
2468 static void
2469 check_ternary_value (void)
2471 - int p, q, rnd;
2472 + int k, p, q, rnd;
2473 int inexact, cmp;
2474 mpfr_t x, y;
2476 @@ -226,28 +226,45 @@
2478 if (rnd == MPFR_RNDF) /* the test below makes no sense */
2479 continue;
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"
2487 - " %d, got %d\n",
2488 - mpfr_print_rnd_mode ((mpfr_rnd_t) rnd), cmp,
2489 - inexact);
2490 - exit (1);
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);
2502 - exit (1);
2503 + int a = 0, b = 0, c = 0;
2505 + switch (k)
2507 + case 0:
2508 + inexact = mpfr_set (y, x, (mpfr_rnd_t) rnd);
2509 + break;
2510 + case 1:
2511 + inexact = (mpfr_set) (y, x, (mpfr_rnd_t) rnd);
2512 + break;
2513 + case 2:
2514 +#ifdef IGNORE_CPP_COMPAT
2515 +#pragma GCC diagnostic push
2516 +#pragma GCC diagnostic ignored "-Wc++-compat"
2517 +#endif
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
2523 +#endif
2524 + MPFR_ASSERTN (a == 1);
2525 + MPFR_ASSERTN (b == 1);
2526 + MPFR_ASSERTN (c == 1);
2527 + break;
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),
2537 + k, cmp, inexact);
2538 + exit (1);
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
2546 @@ -28,6 +28,7 @@
2547 mpfr_t x;
2548 int ret;
2549 mpfr_exp_t emin, emax, e;
2550 + int i = 0;
2552 tests_start_mpfr ();
2554 @@ -63,6 +64,17 @@
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"
2561 +#endif
2562 + e = mpfr_get_exp ((i++, VOIDP_CAST(x)));
2563 +#ifdef IGNORE_CPP_COMPAT
2564 +#pragma GCC diagnostic pop
2565 +#endif
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
2575 @@ -0,0 +1 @@
2576 +tset_sij
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
2580 @@ -1 +1 @@
2581 -4.1.0-p10
2582 +4.1.0-p11
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
2586 @@ -27,7 +27,7 @@
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"
2593 /* User macros:
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
2598 @@ -25,5 +25,5 @@
2599 const char *
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 */
2615 + if (j == 0)
2616 + goto zero;
2617 + e = MPFR_GET_EXP (x1);
2618 + if (ep[i] < __gmpfr_emin - e) /* underflow */
2620 mpfr_rnd_t r =
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;
2635 else
2637 - if (j != 0)
2638 - mpfr_set_exp (x1, ep[i] + e);
2639 + mpfr_set_exp (x1, ep[i] + e);
2640 + zero:
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 */
2654 + if (j == 0)
2655 + goto zero;
2656 + e = MPFR_GET_EXP (x1);
2657 + if (ep[i] < __gmpfr_emin - e) /* underflow */
2659 mpfr_rnd_t r =
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;
2674 else
2676 - if (j != 0)
2677 - mpfr_set_exp (x1, ep[i] + e);
2678 + mpfr_set_exp (x1, ep[i] + e);
2679 + zero:
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
2686 @@ -0,0 +1 @@
2687 +get_str_ndigits
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
2691 @@ -1 +1 @@
2692 -4.1.0-p11
2693 +4.1.0-p12
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 @@
2698 size_t
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);
2716 + if
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))
2723 +#else
2724 + (1)
2725 #endif
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);
2730 + return ret;
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 @@
2736 mpfr_clear (d);
2737 mpfr_clear (u);
2740 + MPFR_SAVE_EXPO_FREE (expo);
2741 return 1 + ret;
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
2747 @@ -27,7 +27,7 @@
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"
2754 /* User macros:
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
2759 @@ -25,5 +25,5 @@
2760 const char *
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 @@
2770 mpfr_clear (x);
2773 +static void
2774 +test_ndigits_aux (int b, mpfr_prec_t p, size_t expected_m)
2776 + size_t m;
2777 + mpfr_exp_t old_emin, old_emax, e[] = { MPFR_EMIN_MIN, 0, MPFR_EMAX_MAX };
2778 + mpfr_flags_t flags;
2779 + int i;
2781 + old_emin = mpfr_get_emin ();
2782 + old_emax = mpfr_get_emax ();
2784 + i = randlimb () % (numberof (e) + 1);
2785 + if (i < numberof (e))
2787 + set_emin (e[i]);
2788 + set_emax (e[i]);
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 */
2801 static void
2802 test_ndigits (void)
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)
2811 = 1 + floor(p/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));
2834 /* error < 1e-3 */
2835 - MPFR_ASSERTN(mpfr_get_str_ndigits (57, 35) == 8);
2836 + test_ndigits_aux (57, 35, 8);
2838 /* error < 1e-4 */
2839 - MPFR_ASSERTN(mpfr_get_str_ndigits (31, 649) == 133);
2840 + test_ndigits_aux (31, 649, 133);
2842 /* error < 1e-5 */
2843 - MPFR_ASSERTN(mpfr_get_str_ndigits (43, 5041) == 931);
2844 + test_ndigits_aux (43, 5041, 931);
2846 /* error < 1e-6 */
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);
2879 #endif
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
2885 @@ -0,0 +1 @@
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
2890 @@ -1 +1 @@
2891 -4.1.0-p12
2892 +4.1.0-p13
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
2896 @@ -27,7 +27,7 @@
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"
2903 /* User macros:
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 @@
2909 static int
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. */
2917 + if (len == 0)
2918 + return 0;
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
2926 @@ -25,5 +25,5 @@
2927 const char *
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);
2947 @@ -227,9 +231,6 @@
2948 mpfr_prec_t p = 128;
2949 mpfr_t x, y, z;
2951 - mpfr_init (z);
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);
2971 + mpfr_init (z);
2972 + mpfr_init2 (x, 128);
2974 /* special numbers */
2975 mpfr_set_inf (x, 1);
2976 check_sprintf (pinf_str, "%Re", x);