Magellan Linux

Annotation of /trunk/mpfr/patches/mpfr-3.1.2-p11.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2570 - (hide annotations) (download)
Wed Nov 26 00:39:01 2014 UTC (9 years, 6 months ago) by niro
File size: 56734 byte(s)
-all patches up to patchlevel 11
1 niro 2570 diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
2     --- mpfr-3.1.2-a/PATCHES 2013-09-26 10:52:52.000000000 +0000
3     +++ mpfr-3.1.2-b/PATCHES 2013-09-26 10:52:52.000000000 +0000
4     @@ -0,0 +1 @@
5     +exp_2
6     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
7     --- mpfr-3.1.2-a/VERSION 2013-03-13 15:37:28.000000000 +0000
8     +++ mpfr-3.1.2-b/VERSION 2013-09-26 10:52:52.000000000 +0000
9     @@ -1 +1 @@
10     -3.1.2
11     +3.1.2-p1
12     diff -Naurd mpfr-3.1.2-a/src/exp_2.c mpfr-3.1.2-b/src/exp_2.c
13     --- mpfr-3.1.2-a/src/exp_2.c 2013-03-13 15:37:28.000000000 +0000
14     +++ mpfr-3.1.2-b/src/exp_2.c 2013-09-26 10:52:52.000000000 +0000
15     @@ -204,7 +204,7 @@
16     for (k = 0; k < K; k++)
17     {
18     mpz_mul (ss, ss, ss);
19     - exps <<= 1;
20     + exps *= 2;
21     exps += mpz_normalize (ss, ss, q);
22     }
23     mpfr_set_z (s, ss, MPFR_RNDN);
24     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
25     --- mpfr-3.1.2-a/src/mpfr.h 2013-03-13 15:37:37.000000000 +0000
26     +++ mpfr-3.1.2-b/src/mpfr.h 2013-09-26 10:52:52.000000000 +0000
27     @@ -27,7 +27,7 @@
28     #define MPFR_VERSION_MAJOR 3
29     #define MPFR_VERSION_MINOR 1
30     #define MPFR_VERSION_PATCHLEVEL 2
31     -#define MPFR_VERSION_STRING "3.1.2"
32     +#define MPFR_VERSION_STRING "3.1.2-p1"
33    
34     /* Macros dealing with MPFR VERSION */
35     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
36     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
37     --- mpfr-3.1.2-a/src/version.c 2013-03-13 15:37:34.000000000 +0000
38     +++ mpfr-3.1.2-b/src/version.c 2013-09-26 10:52:52.000000000 +0000
39     @@ -25,5 +25,5 @@
40     const char *
41     mpfr_get_version (void)
42     {
43     - return "3.1.2";
44     + return "3.1.2-p1";
45     }
46     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
47     --- mpfr-3.1.2-a/PATCHES 2013-09-26 10:56:55.000000000 +0000
48     +++ mpfr-3.1.2-b/PATCHES 2013-09-26 10:56:55.000000000 +0000
49     @@ -0,0 +1 @@
50     +fits-smallneg
51     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
52     --- mpfr-3.1.2-a/VERSION 2013-09-26 10:52:52.000000000 +0000
53     +++ mpfr-3.1.2-b/VERSION 2013-09-26 10:56:55.000000000 +0000
54     @@ -1 +1 @@
55     -3.1.2-p1
56     +3.1.2-p2
57     diff -Naurd mpfr-3.1.2-a/src/fits_u.h mpfr-3.1.2-b/src/fits_u.h
58     --- mpfr-3.1.2-a/src/fits_u.h 2013-03-13 15:37:35.000000000 +0000
59     +++ mpfr-3.1.2-b/src/fits_u.h 2013-09-26 10:56:55.000000000 +0000
60     @@ -32,17 +32,20 @@
61     int res;
62    
63     if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
64     - /* Zero always fit */
65     - return MPFR_IS_ZERO (f) ? 1 : 0;
66     - else if (MPFR_IS_NEG (f))
67     - /* Negative numbers don't fit */
68     - return 0;
69     - /* now it fits if
70     - (a) f <= MAXIMUM
71     - (b) round(f, prec(slong), rnd) <= MAXIMUM */
72     + return MPFR_IS_ZERO (f) ? 1 : 0; /* Zero always fits */
73    
74     e = MPFR_GET_EXP (f);
75    
76     + if (MPFR_IS_NEG (f))
77     + return e >= 1 ? 0 /* f <= -1 does not fit */
78     + : rnd != MPFR_RNDN ? MPFR_IS_LIKE_RNDU (rnd, -1) /* directed mode */
79     + : e < 0 ? 1 /* f > -1/2 fits in MPFR_RNDN */
80     + : mpfr_powerof2_raw(f); /* -1/2 fits, -1 < f < -1/2 don't */
81     +
82     + /* Now it fits if
83     + (a) f <= MAXIMUM
84     + (b) round(f, prec(slong), rnd) <= MAXIMUM */
85     +
86     /* first compute prec(MAXIMUM); fits in an int */
87     for (s = MAXIMUM, prec = 0; s != 0; s /= 2, prec ++);
88    
89     diff -Naurd mpfr-3.1.2-a/src/fits_uintmax.c mpfr-3.1.2-b/src/fits_uintmax.c
90     --- mpfr-3.1.2-a/src/fits_uintmax.c 2013-03-13 15:37:33.000000000 +0000
91     +++ mpfr-3.1.2-b/src/fits_uintmax.c 2013-09-26 10:56:55.000000000 +0000
92     @@ -27,51 +27,19 @@
93     #include "mpfr-intmax.h"
94     #include "mpfr-impl.h"
95    
96     -#ifdef _MPFR_H_HAVE_INTMAX_T
97     -
98     -/* We can't use fits_u.h <= mpfr_cmp_ui */
99     -int
100     -mpfr_fits_uintmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
101     -{
102     - mpfr_exp_t e;
103     - int prec;
104     - uintmax_t s;
105     - mpfr_t x;
106     - int res;
107     -
108     - if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
109     - /* Zero always fit */
110     - return MPFR_IS_ZERO (f) ? 1 : 0;
111     - else if (MPFR_IS_NEG (f))
112     - /* Negative numbers don't fit */
113     - return 0;
114     - /* now it fits if
115     - (a) f <= MAXIMUM
116     - (b) round(f, prec(slong), rnd) <= MAXIMUM */
117     -
118     - e = MPFR_GET_EXP (f);
119     -
120     - /* first compute prec(MAXIMUM); fits in an int */
121     - for (s = MPFR_UINTMAX_MAX, prec = 0; s != 0; s /= 2, prec ++);
122     -
123     - /* MAXIMUM needs prec bits, i.e. MAXIMUM = 2^prec - 1 */
124     -
125     - /* if e <= prec - 1, then f < 2^(prec-1) < MAXIMUM */
126     - if (e <= prec - 1)
127     - return 1;
128     +/* Note: though mpfr-impl.h is included in fits_u.h, we also include it
129     + above so that it gets included even when _MPFR_H_HAVE_INTMAX_T is not
130     + defined; this is necessary to avoid an empty translation unit, which
131     + is forbidden by ISO C. Without this, a failing test can be reproduced
132     + by creating an invalid stdint.h somewhere in the default include path
133     + and by compiling MPFR with "gcc -ansi -pedantic-errors". */
134    
135     - /* if e >= prec + 1, then f >= 2^prec > MAXIMUM */
136     - if (e >= prec + 1)
137     - return 0;
138     +#ifdef _MPFR_H_HAVE_INTMAX_T
139    
140     - MPFR_ASSERTD (e == prec);
141     +#define FUNCTION mpfr_fits_uintmax_p
142     +#define MAXIMUM MPFR_UINTMAX_MAX
143     +#define TYPE uintmax_t
144    
145     - /* hard case: first round to prec bits, then check */
146     - mpfr_init2 (x, prec);
147     - mpfr_set (x, f, rnd);
148     - res = MPFR_GET_EXP (x) == e;
149     - mpfr_clear (x);
150     - return res;
151     -}
152     +#include "fits_u.h"
153    
154     #endif
155     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
156     --- mpfr-3.1.2-a/src/mpfr.h 2013-09-26 10:52:52.000000000 +0000
157     +++ mpfr-3.1.2-b/src/mpfr.h 2013-09-26 10:56:55.000000000 +0000
158     @@ -27,7 +27,7 @@
159     #define MPFR_VERSION_MAJOR 3
160     #define MPFR_VERSION_MINOR 1
161     #define MPFR_VERSION_PATCHLEVEL 2
162     -#define MPFR_VERSION_STRING "3.1.2-p1"
163     +#define MPFR_VERSION_STRING "3.1.2-p2"
164    
165     /* Macros dealing with MPFR VERSION */
166     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
167     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
168     --- mpfr-3.1.2-a/src/version.c 2013-09-26 10:52:52.000000000 +0000
169     +++ mpfr-3.1.2-b/src/version.c 2013-09-26 10:56:55.000000000 +0000
170     @@ -25,5 +25,5 @@
171     const char *
172     mpfr_get_version (void)
173     {
174     - return "3.1.2-p1";
175     + return "3.1.2-p2";
176     }
177     diff -Naurd mpfr-3.1.2-a/tests/tfits.c mpfr-3.1.2-b/tests/tfits.c
178     --- mpfr-3.1.2-a/tests/tfits.c 2013-03-13 15:37:45.000000000 +0000
179     +++ mpfr-3.1.2-b/tests/tfits.c 2013-09-26 10:56:55.000000000 +0000
180     @@ -33,155 +33,176 @@
181     #include "mpfr-intmax.h"
182     #include "mpfr-test.h"
183    
184     -#define ERROR1 { printf("Initial error for x="); mpfr_dump(x); exit(1); }
185     -#define ERROR2 { printf("Error for x="); mpfr_dump(x); exit(1); }
186     +#define ERROR1(N) \
187     + do \
188     + { \
189     + printf("Error %d for rnd = %s and x = ", N, \
190     + mpfr_print_rnd_mode ((mpfr_rnd_t) r)); \
191     + mpfr_dump(x); \
192     + exit(1); \
193     + } \
194     + while (0)
195    
196     static void check_intmax (void);
197    
198     int
199     main (void)
200     {
201     - mpfr_t x;
202     + mpfr_t x, y;
203     + int i, r;
204    
205     tests_start_mpfr ();
206    
207     mpfr_init2 (x, 256);
208     + mpfr_init2 (y, 8);
209    
210     - /* Check NAN */
211     - mpfr_set_nan (x);
212     - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
213     - ERROR1;
214     - if (mpfr_fits_slong_p (x, MPFR_RNDN))
215     - ERROR1;
216     - if (mpfr_fits_uint_p (x, MPFR_RNDN))
217     - ERROR1;
218     - if (mpfr_fits_sint_p (x, MPFR_RNDN))
219     - ERROR1;
220     - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
221     - ERROR1;
222     - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
223     - ERROR1;
224     + RND_LOOP (r)
225     + {
226    
227     - /* Check INF */
228     - mpfr_set_inf (x, 1);
229     - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
230     - ERROR1;
231     - if (mpfr_fits_slong_p (x, MPFR_RNDN))
232     - ERROR1;
233     - if (mpfr_fits_uint_p (x, MPFR_RNDN))
234     - ERROR1;
235     - if (mpfr_fits_sint_p (x, MPFR_RNDN))
236     - ERROR1;
237     - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
238     - ERROR1;
239     - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
240     - ERROR1;
241     + /* Check NAN */
242     + mpfr_set_nan (x);
243     + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
244     + ERROR1 (1);
245     + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
246     + ERROR1 (2);
247     + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
248     + ERROR1 (3);
249     + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
250     + ERROR1 (4);
251     + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
252     + ERROR1 (5);
253     + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
254     + ERROR1 (6);
255    
256     - /* Check Zero */
257     - MPFR_SET_ZERO (x);
258     - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
259     - ERROR2;
260     - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
261     - ERROR2;
262     - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
263     - ERROR2;
264     - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
265     - ERROR2;
266     - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
267     - ERROR2;
268     - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
269     - ERROR2;
270     + /* Check INF */
271     + mpfr_set_inf (x, 1);
272     + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
273     + ERROR1 (7);
274     + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
275     + ERROR1 (8);
276     + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
277     + ERROR1 (9);
278     + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
279     + ERROR1 (10);
280     + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
281     + ERROR1 (11);
282     + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
283     + ERROR1 (12);
284    
285     - /* Check small op */
286     - mpfr_set_str1 (x, "1@-1");
287     - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
288     - ERROR2;
289     - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
290     - ERROR2;
291     - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
292     - ERROR2;
293     - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
294     - ERROR2;
295     - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
296     - ERROR2;
297     - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
298     - ERROR2;
299     + /* Check Zero */
300     + MPFR_SET_ZERO (x);
301     + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
302     + ERROR1 (13);
303     + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
304     + ERROR1 (14);
305     + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
306     + ERROR1 (15);
307     + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
308     + ERROR1 (16);
309     + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
310     + ERROR1 (17);
311     + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
312     + ERROR1 (18);
313    
314     - /* Check 17 */
315     - mpfr_set_ui (x, 17, MPFR_RNDN);
316     - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
317     - ERROR2;
318     - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
319     - ERROR2;
320     - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
321     - ERROR2;
322     - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
323     - ERROR2;
324     - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
325     - ERROR2;
326     - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
327     - ERROR2;
328     + /* Check small positive op */
329     + mpfr_set_str1 (x, "1@-1");
330     + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
331     + ERROR1 (19);
332     + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
333     + ERROR1 (20);
334     + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
335     + ERROR1 (21);
336     + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
337     + ERROR1 (22);
338     + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
339     + ERROR1 (23);
340     + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
341     + ERROR1 (24);
342    
343     - /* Check all other values */
344     - mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
345     - mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
346     - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
347     - ERROR1;
348     - if (mpfr_fits_slong_p (x, MPFR_RNDN))
349     - ERROR1;
350     - mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
351     - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
352     - ERROR1;
353     - if (mpfr_fits_uint_p (x, MPFR_RNDN))
354     - ERROR1;
355     - if (mpfr_fits_sint_p (x, MPFR_RNDN))
356     - ERROR1;
357     - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
358     - ERROR1;
359     - if (mpfr_fits_sshort_p (x, MPFR_RNDN))
360     - ERROR1;
361     + /* Check 17 */
362     + mpfr_set_ui (x, 17, MPFR_RNDN);
363     + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
364     + ERROR1 (25);
365     + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
366     + ERROR1 (26);
367     + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
368     + ERROR1 (27);
369     + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
370     + ERROR1 (28);
371     + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
372     + ERROR1 (29);
373     + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
374     + ERROR1 (30);
375    
376     - mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
377     - if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
378     - ERROR2;
379     - mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
380     - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
381     - ERROR2;
382     - mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
383     - if (!mpfr_fits_uint_p (x, MPFR_RNDN))
384     - ERROR2;
385     - mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
386     - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
387     - ERROR2;
388     - mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
389     - if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
390     - ERROR2;
391     - mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
392     - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
393     - ERROR2;
394     + /* Check all other values */
395     + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
396     + mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
397     + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
398     + ERROR1 (31);
399     + if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
400     + ERROR1 (32);
401     + mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
402     + if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
403     + ERROR1 (33);
404     + if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
405     + ERROR1 (34);
406     + if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
407     + ERROR1 (35);
408     + if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
409     + ERROR1 (36);
410     + if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
411     + ERROR1 (37);
412    
413     - mpfr_set_si (x, 1, MPFR_RNDN);
414     - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
415     - ERROR2;
416     - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
417     - ERROR2;
418     + mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
419     + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
420     + ERROR1 (38);
421     + mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
422     + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
423     + ERROR1 (39);
424     + mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
425     + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
426     + ERROR1 (40);
427     + mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
428     + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
429     + ERROR1 (41);
430     + mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
431     + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
432     + ERROR1 (42);
433     + mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
434     + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
435     + ERROR1 (43);
436    
437     - /* Check negative value */
438     - mpfr_set_si (x, -1, MPFR_RNDN);
439     - if (!mpfr_fits_sint_p (x, MPFR_RNDN))
440     - ERROR2;
441     - if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
442     - ERROR2;
443     - if (!mpfr_fits_slong_p (x, MPFR_RNDN))
444     - ERROR2;
445     - if (mpfr_fits_uint_p (x, MPFR_RNDN))
446     - ERROR1;
447     - if (mpfr_fits_ushort_p (x, MPFR_RNDN))
448     - ERROR1;
449     - if (mpfr_fits_ulong_p (x, MPFR_RNDN))
450     - ERROR1;
451     + mpfr_set_si (x, 1, MPFR_RNDN);
452     + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
453     + ERROR1 (44);
454     + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
455     + ERROR1 (45);
456     +
457     + /* Check negative op */
458     + for (i = 1; i <= 4; i++)
459     + {
460     + int inv;
461     +
462     + mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
463     + mpfr_rint (y, x, (mpfr_rnd_t) r);
464     + inv = MPFR_NOTZERO (y);
465     + if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r) ^ inv)
466     + ERROR1 (46);
467     + if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
468     + ERROR1 (47);
469     + if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r) ^ inv)
470     + ERROR1 (48);
471     + if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
472     + ERROR1 (49);
473     + if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r) ^ inv)
474     + ERROR1 (50);
475     + if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
476     + ERROR1 (51);
477     + }
478     + }
479    
480     mpfr_clear (x);
481     + mpfr_clear (y);
482    
483     check_intmax ();
484    
485     @@ -189,85 +210,98 @@
486     return 0;
487     }
488    
489     -static void check_intmax (void)
490     +static void
491     +check_intmax (void)
492     {
493     #ifdef _MPFR_H_HAVE_INTMAX_T
494     - mpfr_t x;
495     + mpfr_t x, y;
496     + int i, r;
497    
498     - mpfr_init2 (x, sizeof (uintmax_t)*CHAR_BIT);
499     + mpfr_init2 (x, sizeof (uintmax_t) * CHAR_BIT);
500     + mpfr_init2 (y, 8);
501    
502     - /* Check NAN */
503     - mpfr_set_nan (x);
504     - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
505     - ERROR1;
506     - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
507     - ERROR1;
508     + RND_LOOP (r)
509     + {
510     + /* Check NAN */
511     + mpfr_set_nan (x);
512     + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
513     + ERROR1 (52);
514     + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
515     + ERROR1 (53);
516    
517     - /* Check INF */
518     - mpfr_set_inf (x, 1);
519     - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
520     - ERROR1;
521     - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
522     - ERROR1;
523     + /* Check INF */
524     + mpfr_set_inf (x, 1);
525     + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
526     + ERROR1 (54);
527     + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
528     + ERROR1 (55);
529    
530     - /* Check Zero */
531     - MPFR_SET_ZERO (x);
532     - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
533     - ERROR2;
534     - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
535     - ERROR2;
536     + /* Check Zero */
537     + MPFR_SET_ZERO (x);
538     + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
539     + ERROR1 (56);
540     + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
541     + ERROR1 (57);
542    
543     - /* Check small op */
544     - mpfr_set_str1 (x, "1@-1");
545     - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
546     - ERROR2;
547     - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
548     - ERROR2;
549     + /* Check positive small op */
550     + mpfr_set_str1 (x, "1@-1");
551     + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
552     + ERROR1 (58);
553     + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
554     + ERROR1 (59);
555    
556     - /* Check 17 */
557     - mpfr_set_ui (x, 17, MPFR_RNDN);
558     - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
559     - ERROR2;
560     - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
561     - ERROR2;
562     + /* Check 17 */
563     + mpfr_set_ui (x, 17, MPFR_RNDN);
564     + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
565     + ERROR1 (60);
566     + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
567     + ERROR1 (61);
568    
569     - /* Check hugest */
570     - mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
571     - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
572     - ERROR1;
573     - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
574     - ERROR1;
575     + /* Check hugest */
576     + mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
577     + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
578     + ERROR1 (62);
579     + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
580     + ERROR1 (63);
581    
582     - /* Check all other values */
583     - mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
584     - mpfr_add_ui (x, x, 1, MPFR_RNDN);
585     - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
586     - ERROR1;
587     - mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
588     - if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
589     - ERROR2;
590     - mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
591     - mpfr_add_ui (x, x, 1, MPFR_RNDN);
592     - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
593     - ERROR1;
594     - mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
595     - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
596     - ERROR2;
597     - mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
598     - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
599     - ERROR2;
600     - mpfr_sub_ui (x, x, 1, MPFR_RNDN);
601     - if (mpfr_fits_intmax_p (x, MPFR_RNDN))
602     - ERROR1;
603     + /* Check all other values */
604     + mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
605     + mpfr_add_ui (x, x, 1, MPFR_RNDN);
606     + if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
607     + ERROR1 (64);
608     + mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
609     + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
610     + ERROR1 (65);
611     + mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
612     + mpfr_add_ui (x, x, 1, MPFR_RNDN);
613     + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
614     + ERROR1 (66);
615     + mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
616     + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
617     + ERROR1 (67);
618     + mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
619     + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
620     + ERROR1 (68);
621     + mpfr_sub_ui (x, x, 1, MPFR_RNDN);
622     + if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
623     + ERROR1 (69);
624    
625     - /* Check negative value */
626     - mpfr_set_si (x, -1, MPFR_RNDN);
627     - if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
628     - ERROR2;
629     - if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
630     - ERROR1;
631     + /* Check negative op */
632     + for (i = 1; i <= 4; i++)
633     + {
634     + int inv;
635     +
636     + mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
637     + mpfr_rint (y, x, (mpfr_rnd_t) r);
638     + inv = MPFR_NOTZERO (y);
639     + if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r) ^ inv)
640     + ERROR1 (70);
641     + if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
642     + ERROR1 (71);
643     + }
644     + }
645    
646     mpfr_clear (x);
647     + mpfr_clear (y);
648     #endif
649     }
650     -
651     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
652     --- mpfr-3.1.2-a/PATCHES 2013-10-09 13:34:21.000000000 +0000
653     +++ mpfr-3.1.2-b/PATCHES 2013-10-09 13:34:21.000000000 +0000
654     @@ -0,0 +1 @@
655     +clang-divby0
656     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
657     --- mpfr-3.1.2-a/VERSION 2013-09-26 10:52:52.000000000 +0000
658     +++ mpfr-3.1.2-b/VERSION 2013-10-09 13:34:21.000000000 +0000
659     @@ -1 +1 @@
660     -3.1.2-p2
661     +3.1.2-p3
662     diff -Naurd mpfr-3.1.2-a/src/mpfr-impl.h mpfr-3.1.2-b/src/mpfr-impl.h
663     --- mpfr-3.1.2-a/src/mpfr-impl.h 2013-03-13 15:37:36.000000000 +0000
664     +++ mpfr-3.1.2-b/src/mpfr-impl.h 2013-10-09 13:34:21.000000000 +0000
665     @@ -468,8 +468,16 @@
666     #define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1)
667    
668     /* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0
669     - at compile time. */
670     -#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
671     + at compile time.
672     + Clang with -fsanitize=undefined is a bit similar due to a bug:
673     + http://llvm.org/bugs/show_bug.cgi?id=17381
674     + but even without its sanitizer, it may be better to use the
675     + double_zero version until IEEE 754 division by zero is properly
676     + supported:
677     + http://llvm.org/bugs/show_bug.cgi?id=17000
678     +*/
679     +#if (defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)) || \
680     + defined(__clang__)
681     static double double_zero = 0.0;
682     # define DBL_NAN (double_zero/double_zero)
683     # define DBL_POS_INF ((double) 1.0/double_zero)
684     @@ -501,6 +509,8 @@
685     (with Xcode 2.4.1, i.e. the latest one). */
686     #define LVALUE(x) (&(x) == &(x) || &(x) != &(x))
687     #define DOUBLE_ISINF(x) (LVALUE(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
688     +/* The DOUBLE_ISNAN(x) macro is also valid on long double x
689     + (assuming that the compiler isn't too broken). */
690     #ifdef MPFR_NANISNAN
691     /* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
692     The + must not be replaced by a ||. With gcc -ffast-math, NaN is
693     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
694     --- mpfr-3.1.2-a/src/mpfr.h 2013-09-26 10:52:52.000000000 +0000
695     +++ mpfr-3.1.2-b/src/mpfr.h 2013-10-09 13:34:21.000000000 +0000
696     @@ -27,7 +27,7 @@
697     #define MPFR_VERSION_MAJOR 3
698     #define MPFR_VERSION_MINOR 1
699     #define MPFR_VERSION_PATCHLEVEL 2
700     -#define MPFR_VERSION_STRING "3.1.2-p2"
701     +#define MPFR_VERSION_STRING "3.1.2-p3"
702    
703     /* Macros dealing with MPFR VERSION */
704     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
705     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
706     --- mpfr-3.1.2-a/src/version.c 2013-09-26 10:52:52.000000000 +0000
707     +++ mpfr-3.1.2-b/src/version.c 2013-10-09 13:34:21.000000000 +0000
708     @@ -25,5 +25,5 @@
709     const char *
710     mpfr_get_version (void)
711     {
712     - return "3.1.2-p2";
713     + return "3.1.2-p3";
714     }
715     diff -Naurd mpfr-3.1.2-a/tests/tget_flt.c mpfr-3.1.2-b/tests/tget_flt.c
716     --- mpfr-3.1.2-a/tests/tget_flt.c 2013-03-13 15:37:44.000000000 +0000
717     +++ mpfr-3.1.2-b/tests/tget_flt.c 2013-10-09 13:34:21.000000000 +0000
718     @@ -28,9 +28,17 @@
719     main (void)
720     {
721     mpfr_t x, y;
722     - float f, g, infp;
723     + float f, g;
724     int i;
725     +#if !defined(MPFR_ERRDIVZERO)
726     + float infp;
727     +#endif
728     +
729     + tests_start_mpfr ();
730    
731     +#if !defined(MPFR_ERRDIVZERO)
732     + /* The definition of DBL_POS_INF involves a division by 0. This makes
733     + "clang -O2 -fsanitize=undefined -fno-sanitize-recover" fail. */
734     infp = (float) DBL_POS_INF;
735     if (infp * 0.5 != infp)
736     {
737     @@ -38,8 +46,7 @@
738     fprintf (stderr, "(this is probably a compiler bug, please report)\n");
739     exit (1);
740     }
741     -
742     - tests_start_mpfr ();
743     +#endif
744    
745     mpfr_init2 (x, 24);
746     mpfr_init2 (y, 24);
747     @@ -353,6 +360,7 @@
748     printf ("expected %.8e, got %.8e\n", g, f);
749     exit (1);
750     }
751     +#if !defined(MPFR_ERRDIVZERO)
752     f = mpfr_get_flt (x, MPFR_RNDN); /* first round to 2^128 (even rule),
753     thus we should get +Inf */
754     g = infp;
755     @@ -376,6 +384,7 @@
756     printf ("expected %.8e, got %.8e\n", g, f);
757     exit (1);
758     }
759     +#endif
760    
761     mpfr_clear (x);
762     mpfr_clear (y);
763     diff -Naurd mpfr-3.1.2-a/tests/tset_ld.c mpfr-3.1.2-b/tests/tset_ld.c
764     --- mpfr-3.1.2-a/tests/tset_ld.c 2013-03-13 15:37:44.000000000 +0000
765     +++ mpfr-3.1.2-b/tests/tset_ld.c 2013-10-09 13:34:21.000000000 +0000
766     @@ -47,8 +47,11 @@
767     static int
768     Isnan_ld (long double d)
769     {
770     - double e = (double) d;
771     - if (DOUBLE_ISNAN (e))
772     + /* Do not convert d to double as this can give an overflow, which
773     + may confuse compilers without IEEE 754 support (such as clang
774     + -fsanitize=undefined), or trigger a trap if enabled.
775     + The DOUBLE_ISNAN macro should work fine on long double. */
776     + if (DOUBLE_ISNAN (d))
777     return 1;
778     LONGDOUBLE_NAN_ACTION (d, goto yes);
779     return 0;
780     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
781     --- mpfr-3.1.2-a/PATCHES 2013-11-15 00:51:49.211333830 +0000
782     +++ mpfr-3.1.2-b/PATCHES 2013-11-15 00:51:49.323334999 +0000
783     @@ -0,0 +1 @@
784     +printf-alt0
785     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
786     --- mpfr-3.1.2-a/VERSION 2013-11-15 00:51:49.211333830 +0000
787     +++ mpfr-3.1.2-b/VERSION 2013-11-15 00:51:49.323334999 +0000
788     @@ -1 +1 @@
789     -3.1.2-p3
790     +3.1.2-p4
791     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
792     --- mpfr-3.1.2-a/src/mpfr.h 2013-11-15 00:51:49.211333830 +0000
793     +++ mpfr-3.1.2-b/src/mpfr.h 2013-11-15 00:51:49.323334999 +0000
794     @@ -27,7 +27,7 @@
795     #define MPFR_VERSION_MAJOR 3
796     #define MPFR_VERSION_MINOR 1
797     #define MPFR_VERSION_PATCHLEVEL 2
798     -#define MPFR_VERSION_STRING "3.1.2-p3"
799     +#define MPFR_VERSION_STRING "3.1.2-p4"
800    
801     /* Macros dealing with MPFR VERSION */
802     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
803     diff -Naurd mpfr-3.1.2-a/src/vasprintf.c mpfr-3.1.2-b/src/vasprintf.c
804     --- mpfr-3.1.2-a/src/vasprintf.c 2013-03-13 15:37:37.000000000 +0000
805     +++ mpfr-3.1.2-b/src/vasprintf.c 2013-11-15 00:51:49.267334408 +0000
806     @@ -1040,7 +1040,7 @@
807     }
808    
809     /* Determine the different parts of the string representation of the regular
810     - number P when SPEC.SPEC is 'e', 'E', 'g', or 'G'.
811     + number P when spec.spec is 'e', 'E', 'g', or 'G'.
812     DEC_INFO contains the previously computed exponent and string or is NULL.
813    
814     return -1 if some field > INT_MAX */
815     @@ -1167,7 +1167,7 @@
816     }
817    
818     /* Determine the different parts of the string representation of the regular
819     - number P when SPEC.SPEC is 'f', 'F', 'g', or 'G'.
820     + number P when spec.spec is 'f', 'F', 'g', or 'G'.
821     DEC_INFO contains the previously computed exponent and string or is NULL.
822    
823     return -1 if some field of number_parts is greater than INT_MAX */
824     @@ -1559,7 +1559,7 @@
825     /* fractional part */
826     {
827     np->point = MPFR_DECIMAL_POINT;
828     - np->fp_trailing_zeros = (spec.spec == 'g' && spec.spec == 'G') ?
829     + np->fp_trailing_zeros = (spec.spec == 'g' || spec.spec == 'G') ?
830     spec.prec - 1 : spec.prec;
831     }
832     else if (spec.alt)
833     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
834     --- mpfr-3.1.2-a/src/version.c 2013-11-15 00:51:49.211333830 +0000
835     +++ mpfr-3.1.2-b/src/version.c 2013-11-15 00:51:49.323334999 +0000
836     @@ -25,5 +25,5 @@
837     const char *
838     mpfr_get_version (void)
839     {
840     - return "3.1.2-p3";
841     + return "3.1.2-p4";
842     }
843     diff -Naurd mpfr-3.1.2-a/tests/tsprintf.c mpfr-3.1.2-b/tests/tsprintf.c
844     --- mpfr-3.1.2-a/tests/tsprintf.c 2013-03-13 15:37:44.000000000 +0000
845     +++ mpfr-3.1.2-b/tests/tsprintf.c 2013-11-15 00:51:49.267334408 +0000
846     @@ -456,10 +456,16 @@
847     check_sprintf ("1.999900 ", "%-#10.7RG", x);
848     check_sprintf ("1.9999 ", "%-10.7RG", x);
849     mpfr_set_ui (x, 1, MPFR_RNDN);
850     + check_sprintf ("1.", "%#.1Rg", x);
851     + check_sprintf ("1. ", "%-#5.1Rg", x);
852     + check_sprintf (" 1.0", "%#5.2Rg", x);
853     check_sprintf ("1.00000000000000000000000000000", "%#.30Rg", x);
854     check_sprintf ("1", "%.30Rg", x);
855     mpfr_set_ui (x, 0, MPFR_RNDN);
856     - check_sprintf ("0.000000000000000000000000000000", "%#.30Rg", x);
857     + check_sprintf ("0.", "%#.1Rg", x);
858     + check_sprintf ("0. ", "%-#5.1Rg", x);
859     + check_sprintf (" 0.0", "%#5.2Rg", x);
860     + check_sprintf ("0.00000000000000000000000000000", "%#.30Rg", x);
861     check_sprintf ("0", "%.30Rg", x);
862    
863     /* following tests with precision 53 bits */
864     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
865     --- mpfr-3.1.2-a/PATCHES 2013-12-01 11:07:49.575329762 +0000
866     +++ mpfr-3.1.2-b/PATCHES 2013-12-01 11:07:49.751331625 +0000
867     @@ -0,0 +1 @@
868     +custom_init_set
869     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
870     --- mpfr-3.1.2-a/VERSION 2013-12-01 11:07:49.571329714 +0000
871     +++ mpfr-3.1.2-b/VERSION 2013-12-01 11:07:49.747331585 +0000
872     @@ -1 +1 @@
873     -3.1.2-p4
874     +3.1.2-p5
875     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
876     --- mpfr-3.1.2-a/src/mpfr.h 2013-12-01 11:07:49.571329714 +0000
877     +++ mpfr-3.1.2-b/src/mpfr.h 2013-12-01 11:07:49.747331585 +0000
878     @@ -27,7 +27,7 @@
879     #define MPFR_VERSION_MAJOR 3
880     #define MPFR_VERSION_MINOR 1
881     #define MPFR_VERSION_PATCHLEVEL 2
882     -#define MPFR_VERSION_STRING "3.1.2-p4"
883     +#define MPFR_VERSION_STRING "3.1.2-p5"
884    
885     /* Macros dealing with MPFR VERSION */
886     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
887     @@ -861,7 +861,7 @@
888     _t = (mpfr_kind_t) _k; \
889     _s = 1; \
890     } else { \
891     - _t = (mpfr_kind_t) -k; \
892     + _t = (mpfr_kind_t) - _k; \
893     _s = -1; \
894     } \
895     _e = _t == MPFR_REGULAR_KIND ? (e) : \
896     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
897     --- mpfr-3.1.2-a/src/version.c 2013-12-01 11:07:49.575329762 +0000
898     +++ mpfr-3.1.2-b/src/version.c 2013-12-01 11:07:49.747331585 +0000
899     @@ -25,5 +25,5 @@
900     const char *
901     mpfr_get_version (void)
902     {
903     - return "3.1.2-p4";
904     + return "3.1.2-p5";
905     }
906     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
907     --- mpfr-3.1.2-a/PATCHES 2014-04-15 21:56:49.609057464 +0000
908     +++ mpfr-3.1.2-b/PATCHES 2014-04-15 21:56:49.697059857 +0000
909     @@ -0,0 +1 @@
910     +li2-return
911     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
912     --- mpfr-3.1.2-a/VERSION 2014-04-15 21:56:49.609057464 +0000
913     +++ mpfr-3.1.2-b/VERSION 2014-04-15 21:56:49.697059857 +0000
914     @@ -1 +1 @@
915     -3.1.2-p5
916     +3.1.2-p6
917     diff -Naurd mpfr-3.1.2-a/src/li2.c mpfr-3.1.2-b/src/li2.c
918     --- mpfr-3.1.2-a/src/li2.c 2013-03-13 15:37:32.000000000 +0000
919     +++ mpfr-3.1.2-b/src/li2.c 2014-04-15 21:56:49.653058661 +0000
920     @@ -630,5 +630,5 @@
921     return mpfr_check_range (y, inexact, rnd_mode);
922     }
923    
924     - MPFR_ASSERTN (0); /* should never reach this point */
925     + MPFR_RET_NEVER_GO_HERE ();
926     }
927     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
928     --- mpfr-3.1.2-a/src/mpfr.h 2014-04-15 21:56:49.609057464 +0000
929     +++ mpfr-3.1.2-b/src/mpfr.h 2014-04-15 21:56:49.697059857 +0000
930     @@ -27,7 +27,7 @@
931     #define MPFR_VERSION_MAJOR 3
932     #define MPFR_VERSION_MINOR 1
933     #define MPFR_VERSION_PATCHLEVEL 2
934     -#define MPFR_VERSION_STRING "3.1.2-p5"
935     +#define MPFR_VERSION_STRING "3.1.2-p6"
936    
937     /* Macros dealing with MPFR VERSION */
938     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
939     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
940     --- mpfr-3.1.2-a/src/version.c 2014-04-15 21:56:49.609057464 +0000
941     +++ mpfr-3.1.2-b/src/version.c 2014-04-15 21:56:49.697059857 +0000
942     @@ -25,5 +25,5 @@
943     const char *
944     mpfr_get_version (void)
945     {
946     - return "3.1.2-p5";
947     + return "3.1.2-p6";
948     }
949     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
950     --- mpfr-3.1.2-a/PATCHES 2014-04-15 22:04:57.090286262 +0000
951     +++ mpfr-3.1.2-b/PATCHES 2014-04-15 22:04:57.162288198 +0000
952     @@ -0,0 +1 @@
953     +exp3
954     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
955     --- mpfr-3.1.2-a/VERSION 2014-04-15 22:04:57.086286154 +0000
956     +++ mpfr-3.1.2-b/VERSION 2014-04-15 22:04:57.162288198 +0000
957     @@ -1 +1 @@
958     -3.1.2-p6
959     +3.1.2-p7
960     diff -Naurd mpfr-3.1.2-a/src/exp3.c mpfr-3.1.2-b/src/exp3.c
961     --- mpfr-3.1.2-a/src/exp3.c 2013-03-13 15:37:34.000000000 +0000
962     +++ mpfr-3.1.2-b/src/exp3.c 2014-04-15 22:04:57.126287230 +0000
963     @@ -283,7 +283,7 @@
964     }
965     }
966    
967     - if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDD, MPFR_RNDZ,
968     + if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDN, MPFR_RNDZ,
969     MPFR_PREC(y) + (rnd_mode == MPFR_RNDN)))
970     {
971     inexact = mpfr_set (y, shift_x > 0 ? t : tmp, rnd_mode);
972     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
973     --- mpfr-3.1.2-a/src/mpfr.h 2014-04-15 22:04:57.086286154 +0000
974     +++ mpfr-3.1.2-b/src/mpfr.h 2014-04-15 22:04:57.162288198 +0000
975     @@ -27,7 +27,7 @@
976     #define MPFR_VERSION_MAJOR 3
977     #define MPFR_VERSION_MINOR 1
978     #define MPFR_VERSION_PATCHLEVEL 2
979     -#define MPFR_VERSION_STRING "3.1.2-p6"
980     +#define MPFR_VERSION_STRING "3.1.2-p7"
981    
982     /* Macros dealing with MPFR VERSION */
983     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
984     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
985     --- mpfr-3.1.2-a/src/version.c 2014-04-15 22:04:57.090286262 +0000
986     +++ mpfr-3.1.2-b/src/version.c 2014-04-15 22:04:57.162288198 +0000
987     @@ -25,5 +25,5 @@
988     const char *
989     mpfr_get_version (void)
990     {
991     - return "3.1.2-p6";
992     + return "3.1.2-p7";
993     }
994     diff -Naurd mpfr-3.1.2-a/tests/texp.c mpfr-3.1.2-b/tests/texp.c
995     --- mpfr-3.1.2-a/tests/texp.c 2013-03-13 15:37:44.000000000 +0000
996     +++ mpfr-3.1.2-b/tests/texp.c 2014-04-15 22:04:57.126287230 +0000
997     @@ -150,6 +150,22 @@
998     exit (1);
999     }
1000    
1001     + mpfr_set_prec (x, 118);
1002     + mpfr_set_str_binary (x, "0.1110010100011101010000111110011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E-86");
1003     + mpfr_set_prec (y, 118);
1004     + mpfr_exp_2 (y, x, MPFR_RNDU);
1005     + mpfr_exp_3 (x, x, MPFR_RNDU);
1006     + if (mpfr_cmp (x, y))
1007     + {
1008     + printf ("mpfr_exp_2 and mpfr_exp_3 differ for prec=118\n");
1009     + printf ("mpfr_exp_2 gives ");
1010     + mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
1011     + printf ("\nmpfr_exp_3 gives ");
1012     + mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
1013     + printf ("\n");
1014     + exit (1);
1015     + }
1016     +
1017     mpfr_clear (x);
1018     mpfr_clear (y);
1019     return 0;
1020     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
1021     --- mpfr-3.1.2-a/PATCHES 2014-04-15 22:20:32.243481506 +0000
1022     +++ mpfr-3.1.2-b/PATCHES 2014-04-15 22:22:32.418722707 +0000
1023     @@ -0,0 +1 @@
1024     +gmp6-compat
1025     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
1026     --- mpfr-3.1.2-a/VERSION 2014-04-15 22:20:20.755171478 +0000
1027     +++ mpfr-3.1.2-b/VERSION 2014-04-15 22:21:45.225450147 +0000
1028     @@ -1 +1 @@
1029     -3.1.2-p7
1030     +3.1.2-p8
1031     diff -Naurd mpfr-3.1.2-a/configure mpfr-3.1.2-b/configure
1032     --- mpfr-3.1.2-a/configure 2013-03-13 15:38:20.000000000 +0000
1033     +++ mpfr-3.1.2-b/configure 2014-04-15 22:21:38.821277476 +0000
1034     @@ -14545,26 +14545,30 @@
1035     rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1036     fi
1037    
1038     -if test "$use_gmp_build" = yes ; then
1039     - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for valid GMP_NUMB_BITS" >&5
1040     -$as_echo_n "checking for valid GMP_NUMB_BITS... " >&6; }
1041     - if test "$cross_compiling" = yes; then :
1042     +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency" >&5
1043     +$as_echo_n "checking for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency... " >&6; }
1044     +if test "$cross_compiling" = yes; then :
1045     { $as_echo "$as_me:${as_lineno-$LINENO}: result: can't test" >&5
1046     $as_echo "can't test" >&6; }
1047     else
1048     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1049     /* end confdefs.h. */
1050    
1051     +#include <stdio.h>
1052     #include <limits.h>
1053     #include "gmp.h"
1054     -#include "gmp-impl.h"
1055    
1056     int
1057     main ()
1058     {
1059    
1060     - return GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
1061     - && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
1062     + if (GMP_NUMB_BITS == sizeof(mp_limb_t) * CHAR_BIT)
1063     + return 0;
1064     + fprintf (stderr, "GMP_NUMB_BITS = %ld\n", (long) GMP_NUMB_BITS);
1065     + fprintf (stderr, "sizeof(mp_limb_t) = %ld\n", (long) sizeof(mp_limb_t));
1066     + fprintf (stderr, "sizeof(mp_limb_t) * CHAR_BIT = %ld != GMP_NUMB_BITS\n",
1067     + (long) (sizeof(mp_limb_t) * CHAR_BIT));
1068     + return 1;
1069    
1070     ;
1071     return 0;
1072     @@ -14577,14 +14581,14 @@
1073    
1074     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1075     $as_echo "no" >&6; }
1076     - as_fn_error $? "GMP_NUMB_BITS is incorrect.
1077     -You probably need to change some of the GMP or MPFR compile options." "$LINENO" 5
1078     + as_fn_error $? "GMP_NUMB_BITS and sizeof(mp_limb_t) are not consistent.
1079     +You probably need to change some of the GMP or MPFR compile options.
1080     +See 'config.log' for details (search for GMP_NUMB_BITS)." "$LINENO" 5
1081     fi
1082     rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
1083     conftest.$ac_objext conftest.beam conftest.$ac_ext
1084     fi
1085    
1086     -fi
1087    
1088    
1089     if test "$dont_link_with_gmp" = yes ; then
1090     diff -Naurd mpfr-3.1.2-a/configure.ac mpfr-3.1.2-b/configure.ac
1091     --- mpfr-3.1.2-a/configure.ac 2013-03-13 15:37:46.000000000 +0000
1092     +++ mpfr-3.1.2-b/configure.ac 2013-03-13 15:37:46.000000000 +0000
1093     @@ -435,23 +435,29 @@
1094     ])
1095     fi
1096    
1097     -dnl Check for valid GMP_NUMB_BITS and BYTES_PER_MP_LIMB
1098     +dnl Check for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency.
1099     +dnl Problems may occur if gmp.h was generated with some ABI
1100     +dnl and is used with another ABI (or if nails are used).
1101     dnl This test doesn't need to link with libgmp (at least it shouldn't).
1102     -if test "$use_gmp_build" = yes ; then
1103     - AC_MSG_CHECKING(for valid GMP_NUMB_BITS)
1104     - AC_RUN_IFELSE([AC_LANG_PROGRAM([[
1105     +AC_MSG_CHECKING(for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency)
1106     +AC_RUN_IFELSE([AC_LANG_PROGRAM([[
1107     +#include <stdio.h>
1108     #include <limits.h>
1109     #include "gmp.h"
1110     -#include "gmp-impl.h"
1111     ]], [[
1112     - return GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
1113     - && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
1114     + if (GMP_NUMB_BITS == sizeof(mp_limb_t) * CHAR_BIT)
1115     + return 0;
1116     + fprintf (stderr, "GMP_NUMB_BITS = %ld\n", (long) GMP_NUMB_BITS);
1117     + fprintf (stderr, "sizeof(mp_limb_t) = %ld\n", (long) sizeof(mp_limb_t));
1118     + fprintf (stderr, "sizeof(mp_limb_t) * CHAR_BIT = %ld != GMP_NUMB_BITS\n",
1119     + (long) (sizeof(mp_limb_t) * CHAR_BIT));
1120     + return 1;
1121     ]])], [AC_MSG_RESULT(yes)], [
1122     AC_MSG_RESULT(no)
1123     - AC_MSG_ERROR([GMP_NUMB_BITS is incorrect.
1124     -You probably need to change some of the GMP or MPFR compile options.])],
1125     + AC_MSG_ERROR([GMP_NUMB_BITS and sizeof(mp_limb_t) are not consistent.
1126     +You probably need to change some of the GMP or MPFR compile options.
1127     +See 'config.log' for details (search for GMP_NUMB_BITS).])],
1128     [AC_MSG_RESULT([can't test])])
1129     -fi
1130    
1131    
1132     dnl We really need to link using libtool. But it is impossible with the current
1133     diff -Naurd mpfr-3.1.2-a/src/init2.c mpfr-3.1.2-b/src/init2.c
1134     --- mpfr-3.1.2-a/src/init2.c 2013-03-13 15:37:32.000000000 +0000
1135     +++ mpfr-3.1.2-b/src/init2.c 2014-04-15 22:21:06.220398489 +0000
1136     @@ -30,11 +30,11 @@
1137    
1138     /* Check if we can represent the number of limbs
1139     * associated to the maximum of mpfr_prec_t*/
1140     - MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/BYTES_PER_MP_LIMB) );
1141     + MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/MPFR_BYTES_PER_MP_LIMB) );
1142    
1143     - /* Check for correct GMP_NUMB_BITS and BYTES_PER_MP_LIMB */
1144     - MPFR_ASSERTN( GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
1145     - && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB );
1146     + /* Check for correct GMP_NUMB_BITS and MPFR_BYTES_PER_MP_LIMB */
1147     + MPFR_ASSERTN( GMP_NUMB_BITS == MPFR_BYTES_PER_MP_LIMB * CHAR_BIT
1148     + && sizeof(mp_limb_t) == MPFR_BYTES_PER_MP_LIMB );
1149    
1150     MPFR_ASSERTN (mp_bits_per_limb == GMP_NUMB_BITS);
1151    
1152     diff -Naurd mpfr-3.1.2-a/src/mpfr-gmp.h mpfr-3.1.2-b/src/mpfr-gmp.h
1153     --- mpfr-3.1.2-a/src/mpfr-gmp.h 2013-03-13 15:37:32.000000000 +0000
1154     +++ mpfr-3.1.2-b/src/mpfr-gmp.h 2014-04-15 22:21:06.220398489 +0000
1155     @@ -72,7 +72,6 @@
1156     #endif
1157    
1158     /* Define some macros */
1159     -#define BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
1160    
1161     #define MP_LIMB_T_MAX (~(mp_limb_t)0)
1162    
1163     @@ -96,19 +95,19 @@
1164     #define SHRT_HIGHBIT SHRT_MIN
1165    
1166     /* MP_LIMB macros */
1167     -#define MPN_ZERO(dst, n) memset((dst), 0, (n)*BYTES_PER_MP_LIMB)
1168     -#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
1169     -#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
1170     +#define MPN_ZERO(dst, n) memset((dst), 0, (n)*MPFR_BYTES_PER_MP_LIMB)
1171     +#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
1172     +#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
1173     #define MPN_COPY(dst,src,n) \
1174     do \
1175     { \
1176     if ((dst) != (src)) \
1177     { \
1178     MPFR_ASSERTD ((char *) (dst) >= (char *) (src) + \
1179     - (n) * BYTES_PER_MP_LIMB || \
1180     + (n) * MPFR_BYTES_PER_MP_LIMB || \
1181     (char *) (src) >= (char *) (dst) + \
1182     - (n) * BYTES_PER_MP_LIMB); \
1183     - memcpy ((dst), (src), (n) * BYTES_PER_MP_LIMB); \
1184     + (n) * MPFR_BYTES_PER_MP_LIMB); \
1185     + memcpy ((dst), (src), (n) * MPFR_BYTES_PER_MP_LIMB); \
1186     } \
1187     } \
1188     while (0)
1189     diff -Naurd mpfr-3.1.2-a/src/mpfr-impl.h mpfr-3.1.2-b/src/mpfr-impl.h
1190     --- mpfr-3.1.2-a/src/mpfr-impl.h 2013-10-09 13:34:21.000000000 +0000
1191     +++ mpfr-3.1.2-b/src/mpfr-impl.h 2014-04-15 22:21:06.220398489 +0000
1192     @@ -191,7 +191,7 @@
1193     # endif
1194     #endif
1195    
1196     -
1197     +#define MPFR_BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
1198    
1199     /******************************************************
1200     ******************** Check GMP ***********************
1201     @@ -930,7 +930,7 @@
1202     #define MPFR_SET_ALLOC_SIZE(x, n) \
1203     ( ((mp_size_t*) MPFR_MANT(x))[-1] = n)
1204     #define MPFR_MALLOC_SIZE(s) \
1205     - ( sizeof(mpfr_size_limb_t) + BYTES_PER_MP_LIMB * ((size_t) s) )
1206     + ( sizeof(mpfr_size_limb_t) + MPFR_BYTES_PER_MP_LIMB * ((size_t) s) )
1207     #define MPFR_SET_MANT_PTR(x,p) \
1208     (MPFR_MANT(x) = (mp_limb_t*) ((mpfr_size_limb_t*) p + 1))
1209     #define MPFR_GET_REAL_PTR(x) \
1210     @@ -964,7 +964,7 @@
1211     #endif
1212    
1213     #define MPFR_TMP_LIMBS_ALLOC(N) \
1214     - ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * BYTES_PER_MP_LIMB))
1215     + ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * MPFR_BYTES_PER_MP_LIMB))
1216    
1217     /* temporary allocate 1 limb at xp, and initialize mpfr variable x */
1218     /* The temporary var doesn't have any size field, but it doesn't matter
1219     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
1220     --- mpfr-3.1.2-a/src/mpfr.h 2014-04-15 22:20:20.755171478 +0000
1221     +++ mpfr-3.1.2-b/src/mpfr.h 2014-04-15 22:21:45.225450147 +0000
1222     @@ -27,7 +27,7 @@
1223     #define MPFR_VERSION_MAJOR 3
1224     #define MPFR_VERSION_MINOR 1
1225     #define MPFR_VERSION_PATCHLEVEL 2
1226     -#define MPFR_VERSION_STRING "3.1.2-p7"
1227     +#define MPFR_VERSION_STRING "3.1.2-p8"
1228    
1229     /* Macros dealing with MPFR VERSION */
1230     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1231     diff -Naurd mpfr-3.1.2-a/src/mul.c mpfr-3.1.2-b/src/mul.c
1232     --- mpfr-3.1.2-a/src/mul.c 2013-03-13 15:37:37.000000000 +0000
1233     +++ mpfr-3.1.2-b/src/mul.c 2014-04-15 22:21:06.224398597 +0000
1234     @@ -106,7 +106,7 @@
1235     MPFR_ASSERTD(tn <= k);
1236    
1237     /* Check for no size_t overflow*/
1238     - MPFR_ASSERTD((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
1239     + MPFR_ASSERTD((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
1240     MPFR_TMP_MARK(marker);
1241     tmp = MPFR_TMP_LIMBS_ALLOC (k);
1242    
1243     @@ -301,7 +301,7 @@
1244     MPFR_ASSERTD (tn <= k); /* tn <= k, thus no int overflow */
1245    
1246     /* Check for no size_t overflow*/
1247     - MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
1248     + MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
1249     MPFR_TMP_MARK (marker);
1250     tmp = MPFR_TMP_LIMBS_ALLOC (k);
1251    
1252     diff -Naurd mpfr-3.1.2-a/src/stack_interface.c mpfr-3.1.2-b/src/stack_interface.c
1253     --- mpfr-3.1.2-a/src/stack_interface.c 2013-03-13 15:37:32.000000000 +0000
1254     +++ mpfr-3.1.2-b/src/stack_interface.c 2014-04-15 22:21:06.220398489 +0000
1255     @@ -26,7 +26,7 @@
1256     size_t
1257     mpfr_custom_get_size (mpfr_prec_t prec)
1258     {
1259     - return MPFR_PREC2LIMBS (prec) * BYTES_PER_MP_LIMB;
1260     + return MPFR_PREC2LIMBS (prec) * MPFR_BYTES_PER_MP_LIMB;
1261     }
1262    
1263     #undef mpfr_custom_init
1264     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
1265     --- mpfr-3.1.2-a/src/version.c 2014-04-15 22:20:20.755171478 +0000
1266     +++ mpfr-3.1.2-b/src/version.c 2014-04-15 22:21:45.225450147 +0000
1267     @@ -25,5 +25,5 @@
1268     const char *
1269     mpfr_get_version (void)
1270     {
1271     - return "3.1.2-p7";
1272     + return "3.1.2-p8";
1273     }
1274     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
1275     --- mpfr-3.1.2-a/PATCHES 2014-06-30 15:15:25.533266905 +0000
1276     +++ mpfr-3.1.2-b/PATCHES 2014-06-30 15:15:25.617269178 +0000
1277     @@ -0,0 +1 @@
1278     +div-overflow
1279     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
1280     --- mpfr-3.1.2-a/VERSION 2014-06-30 15:15:25.529266797 +0000
1281     +++ mpfr-3.1.2-b/VERSION 2014-06-30 15:15:25.617269178 +0000
1282     @@ -1 +1 @@
1283     -3.1.2-p8
1284     +3.1.2-p9
1285     diff -Naurd mpfr-3.1.2-a/src/div.c mpfr-3.1.2-b/src/div.c
1286     --- mpfr-3.1.2-a/src/div.c 2013-03-13 15:37:33.000000000 +0000
1287     +++ mpfr-3.1.2-b/src/div.c 2014-06-30 15:15:25.585268312 +0000
1288     @@ -750,7 +750,9 @@
1289     truncate_check_qh:
1290     if (qh)
1291     {
1292     - qexp ++;
1293     + if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
1294     + qexp ++;
1295     + /* else qexp is now incorrect, but one will still get an overflow */
1296     q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
1297     }
1298     goto truncate;
1299     @@ -765,7 +767,9 @@
1300     inex = 1; /* always here */
1301     if (mpn_add_1 (q0p, q0p, q0size, MPFR_LIMB_ONE << sh))
1302     {
1303     - qexp ++;
1304     + if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
1305     + qexp ++;
1306     + /* else qexp is now incorrect, but one will still get an overflow */
1307     q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
1308     }
1309    
1310     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
1311     --- mpfr-3.1.2-a/src/mpfr.h 2014-06-30 15:15:25.533266905 +0000
1312     +++ mpfr-3.1.2-b/src/mpfr.h 2014-06-30 15:15:25.613269070 +0000
1313     @@ -27,7 +27,7 @@
1314     #define MPFR_VERSION_MAJOR 3
1315     #define MPFR_VERSION_MINOR 1
1316     #define MPFR_VERSION_PATCHLEVEL 2
1317     -#define MPFR_VERSION_STRING "3.1.2-p8"
1318     +#define MPFR_VERSION_STRING "3.1.2-p9"
1319    
1320     /* Macros dealing with MPFR VERSION */
1321     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1322     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
1323     --- mpfr-3.1.2-a/src/version.c 2014-06-30 15:15:25.533266905 +0000
1324     +++ mpfr-3.1.2-b/src/version.c 2014-06-30 15:15:25.613269070 +0000
1325     @@ -25,5 +25,5 @@
1326     const char *
1327     mpfr_get_version (void)
1328     {
1329     - return "3.1.2-p8";
1330     + return "3.1.2-p9";
1331     }
1332     diff -Naurd mpfr-3.1.2-a/tests/tdiv.c mpfr-3.1.2-b/tests/tdiv.c
1333     --- mpfr-3.1.2-a/tests/tdiv.c 2013-03-13 15:37:44.000000000 +0000
1334     +++ mpfr-3.1.2-b/tests/tdiv.c 2014-06-30 15:15:25.585268312 +0000
1335     @@ -1104,6 +1104,96 @@
1336     #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
1337     #include "tgeneric.c"
1338    
1339     +static void
1340     +test_extreme (void)
1341     +{
1342     + mpfr_t x, y, z;
1343     + mpfr_exp_t emin, emax;
1344     + mpfr_prec_t p[4] = { 8, 32, 64, 256 };
1345     + int xi, yi, zi, j, r;
1346     + unsigned int flags, ex_flags;
1347     +
1348     + emin = mpfr_get_emin ();
1349     + emax = mpfr_get_emax ();
1350     +
1351     + mpfr_set_emin (MPFR_EMIN_MIN);
1352     + mpfr_set_emax (MPFR_EMAX_MAX);
1353     +
1354     + for (xi = 0; xi < 4; xi++)
1355     + {
1356     + mpfr_init2 (x, p[xi]);
1357     + mpfr_setmax (x, MPFR_EMAX_MAX);
1358     + MPFR_ASSERTN (mpfr_check (x));
1359     + for (yi = 0; yi < 4; yi++)
1360     + {
1361     + mpfr_init2 (y, p[yi]);
1362     + mpfr_setmin (y, MPFR_EMIN_MIN);
1363     + for (j = 0; j < 2; j++)
1364     + {
1365     + MPFR_ASSERTN (mpfr_check (y));
1366     + for (zi = 0; zi < 4; zi++)
1367     + {
1368     + mpfr_init2 (z, p[zi]);
1369     + RND_LOOP (r)
1370     + {
1371     + mpfr_clear_flags ();
1372     + mpfr_div (z, x, y, (mpfr_rnd_t) r);
1373     + flags = __gmpfr_flags;
1374     + MPFR_ASSERTN (mpfr_check (z));
1375     + ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT;
1376     + if (flags != ex_flags)
1377     + {
1378     + printf ("Bad flags in test_extreme on z = a/b"
1379     + " with %s and\n",
1380     + mpfr_print_rnd_mode ((mpfr_rnd_t) r));
1381     + printf ("a = ");
1382     + mpfr_dump (x);
1383     + printf ("b = ");
1384     + mpfr_dump (y);
1385     + printf ("Expected flags:");
1386     + flags_out (ex_flags);
1387     + printf ("Got flags: ");
1388     + flags_out (flags);
1389     + printf ("z = ");
1390     + mpfr_dump (z);
1391     + exit (1);
1392     + }
1393     + mpfr_clear_flags ();
1394     + mpfr_div (z, y, x, (mpfr_rnd_t) r);
1395     + flags = __gmpfr_flags;
1396     + MPFR_ASSERTN (mpfr_check (z));
1397     + ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT;
1398     + if (flags != ex_flags)
1399     + {
1400     + printf ("Bad flags in test_extreme on z = a/b"
1401     + " with %s and\n",
1402     + mpfr_print_rnd_mode ((mpfr_rnd_t) r));
1403     + printf ("a = ");
1404     + mpfr_dump (y);
1405     + printf ("b = ");
1406     + mpfr_dump (x);
1407     + printf ("Expected flags:");
1408     + flags_out (ex_flags);
1409     + printf ("Got flags: ");
1410     + flags_out (flags);
1411     + printf ("z = ");
1412     + mpfr_dump (z);
1413     + exit (1);
1414     + }
1415     + }
1416     + mpfr_clear (z);
1417     + } /* zi */
1418     + mpfr_nextabove (y);
1419     + } /* j */
1420     + mpfr_clear (y);
1421     + } /* yi */
1422     + mpfr_clear (x);
1423     + } /* xi */
1424     +
1425     + set_emin (emin);
1426     + set_emax (emax);
1427     +}
1428     +
1429     int
1430     main (int argc, char *argv[])
1431     {
1432     @@ -1130,6 +1220,7 @@
1433     test_20070603 ();
1434     test_20070628 ();
1435     test_generic (2, 800, 50);
1436     + test_extreme ();
1437    
1438     tests_end_mpfr ();
1439     return 0;
1440     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
1441     --- mpfr-3.1.2-a/PATCHES 2014-06-30 15:17:53.337268149 +0000
1442     +++ mpfr-3.1.2-b/PATCHES 2014-06-30 15:17:53.417270314 +0000
1443     @@ -0,0 +1 @@
1444     +vasprintf
1445     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
1446     --- mpfr-3.1.2-a/VERSION 2014-06-30 15:17:53.337268149 +0000
1447     +++ mpfr-3.1.2-b/VERSION 2014-06-30 15:17:53.413270206 +0000
1448     @@ -1 +1 @@
1449     -3.1.2-p9
1450     +3.1.2-p10
1451     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
1452     --- mpfr-3.1.2-a/src/mpfr.h 2014-06-30 15:17:53.337268149 +0000
1453     +++ mpfr-3.1.2-b/src/mpfr.h 2014-06-30 15:17:53.413270206 +0000
1454     @@ -27,7 +27,7 @@
1455     #define MPFR_VERSION_MAJOR 3
1456     #define MPFR_VERSION_MINOR 1
1457     #define MPFR_VERSION_PATCHLEVEL 2
1458     -#define MPFR_VERSION_STRING "3.1.2-p9"
1459     +#define MPFR_VERSION_STRING "3.1.2-p10"
1460    
1461     /* Macros dealing with MPFR VERSION */
1462     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1463     diff -Naurd mpfr-3.1.2-a/src/vasprintf.c mpfr-3.1.2-b/src/vasprintf.c
1464     --- mpfr-3.1.2-a/src/vasprintf.c 2013-11-15 00:51:49.267334408 +0000
1465     +++ mpfr-3.1.2-b/src/vasprintf.c 2014-06-30 15:17:53.377269231 +0000
1466     @@ -884,14 +884,18 @@
1467     first digit, we want the exponent for radix two and the decimal
1468     point AFTER the first digit. */
1469     {
1470     - MPFR_ASSERTN (exp > MPFR_EMIN_MIN /4); /* possible overflow */
1471     + /* An integer overflow is normally not possible since MPFR_EXP_MIN
1472     + is twice as large as MPFR_EMIN_MIN. */
1473     + MPFR_ASSERTN (exp > (MPFR_EXP_MIN + 3) / 4);
1474     exp = (exp - 1) * 4;
1475     }
1476     else
1477     /* EXP is the exponent for decimal point BEFORE the first digit, we
1478     want the exponent for decimal point AFTER the first digit. */
1479     {
1480     - MPFR_ASSERTN (exp > MPFR_EMIN_MIN); /* possible overflow */
1481     + /* An integer overflow is normally not possible since MPFR_EXP_MIN
1482     + is twice as large as MPFR_EMIN_MIN. */
1483     + MPFR_ASSERTN (exp > MPFR_EXP_MIN);
1484     --exp;
1485     }
1486     }
1487     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
1488     --- mpfr-3.1.2-a/src/version.c 2014-06-30 15:17:53.337268149 +0000
1489     +++ mpfr-3.1.2-b/src/version.c 2014-06-30 15:17:53.413270206 +0000
1490     @@ -25,5 +25,5 @@
1491     const char *
1492     mpfr_get_version (void)
1493     {
1494     - return "3.1.2-p9";
1495     + return "3.1.2-p10";
1496     }
1497     diff -Naurd mpfr-3.1.2-a/tests/tsprintf.c mpfr-3.1.2-b/tests/tsprintf.c
1498     --- mpfr-3.1.2-a/tests/tsprintf.c 2013-11-15 00:51:49.267334408 +0000
1499     +++ mpfr-3.1.2-b/tests/tsprintf.c 2014-06-30 15:17:53.377269231 +0000
1500     @@ -1184,6 +1184,69 @@
1501     check_emax_aux (MPFR_EMAX_MAX);
1502     }
1503    
1504     +static void
1505     +check_emin_aux (mpfr_exp_t e)
1506     +{
1507     + mpfr_t x;
1508     + char *s1, s2[256];
1509     + int i;
1510     + mpfr_exp_t emin;
1511     + mpz_t ee;
1512     +
1513     + MPFR_ASSERTN (e >= LONG_MIN);
1514     + emin = mpfr_get_emin ();
1515     + set_emin (e);
1516     +
1517     + mpfr_init2 (x, 16);
1518     + mpz_init (ee);
1519     +
1520     + mpfr_setmin (x, e);
1521     + mpz_set_si (ee, e);
1522     + mpz_sub_ui (ee, ee, 1);
1523     +
1524     + i = mpfr_asprintf (&s1, "%Ra", x);
1525     + MPFR_ASSERTN (i > 0);
1526     +
1527     + gmp_snprintf (s2, 256, "0x1p%Zd", ee);
1528     +
1529     + if (strcmp (s1, s2) != 0)
1530     + {
1531     + printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
1532     + printf ("Expected %s\n", s2);
1533     + printf ("Got %s\n", s1);
1534     + exit (1);
1535     + }
1536     +
1537     + mpfr_free_str (s1);
1538     +
1539     + i = mpfr_asprintf (&s1, "%Rb", x);
1540     + MPFR_ASSERTN (i > 0);
1541     +
1542     + gmp_snprintf (s2, 256, "1p%Zd", ee);
1543     +
1544     + if (strcmp (s1, s2) != 0)
1545     + {
1546     + printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
1547     + printf ("Expected %s\n", s2);
1548     + printf ("Got %s\n", s1);
1549     + exit (1);
1550     + }
1551     +
1552     + mpfr_free_str (s1);
1553     +
1554     + mpfr_clear (x);
1555     + mpz_clear (ee);
1556     + set_emin (emin);
1557     +}
1558     +
1559     +static void
1560     +check_emin (void)
1561     +{
1562     + check_emin_aux (-15);
1563     + check_emin_aux (mpfr_get_emin ());
1564     + check_emin_aux (MPFR_EMIN_MIN);
1565     +}
1566     +
1567     int
1568     main (int argc, char **argv)
1569     {
1570     @@ -1203,6 +1266,7 @@
1571     decimal ();
1572     mixed ();
1573     check_emax ();
1574     + check_emin ();
1575    
1576     #if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE)
1577     locale_da_DK ();
1578     diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
1579     --- mpfr-3.1.2-a/PATCHES 2014-12-04 01:41:57.131789485 +0000
1580     +++ mpfr-3.1.2-b/PATCHES 2014-12-04 01:41:57.339791833 +0000
1581     @@ -0,0 +1 @@
1582     +strtofr
1583     diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
1584     --- mpfr-3.1.2-a/VERSION 2014-12-04 01:41:57.127789443 +0000
1585     +++ mpfr-3.1.2-b/VERSION 2014-12-04 01:41:57.339791833 +0000
1586     @@ -1 +1 @@
1587     -3.1.2-p10
1588     +3.1.2-p11
1589     diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
1590     --- mpfr-3.1.2-a/src/mpfr.h 2014-12-04 01:41:57.127789443 +0000
1591     +++ mpfr-3.1.2-b/src/mpfr.h 2014-12-04 01:41:57.335791790 +0000
1592     @@ -27,7 +27,7 @@
1593     #define MPFR_VERSION_MAJOR 3
1594     #define MPFR_VERSION_MINOR 1
1595     #define MPFR_VERSION_PATCHLEVEL 2
1596     -#define MPFR_VERSION_STRING "3.1.2-p10"
1597     +#define MPFR_VERSION_STRING "3.1.2-p11"
1598    
1599     /* Macros dealing with MPFR VERSION */
1600     #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
1601     diff -Naurd mpfr-3.1.2-a/src/strtofr.c mpfr-3.1.2-b/src/strtofr.c
1602     --- mpfr-3.1.2-a/src/strtofr.c 2013-03-13 15:37:32.000000000 +0000
1603     +++ mpfr-3.1.2-b/src/strtofr.c 2014-12-04 01:41:57.287791246 +0000
1604     @@ -473,8 +473,10 @@
1605     /* prec bits corresponds to ysize limbs */
1606     ysize_bits = ysize * GMP_NUMB_BITS;
1607     /* and to ysize_bits >= prec > MPFR_PREC (x) bits */
1608     - y = MPFR_TMP_LIMBS_ALLOC (2 * ysize + 1);
1609     - y += ysize; /* y has (ysize+1) allocated limbs */
1610     + /* we need to allocate one more limb to work around bug
1611     + https://gmplib.org/list-archives/gmp-bugs/2013-December/003267.html */
1612     + y = MPFR_TMP_LIMBS_ALLOC (2 * ysize + 2);
1613     + y += ysize; /* y has (ysize+2) allocated limbs */
1614    
1615     /* pstr_size is the number of characters we read in pstr->mant
1616     to have at least ysize full limbs.
1617     diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
1618     --- mpfr-3.1.2-a/src/version.c 2014-12-04 01:41:57.131789485 +0000
1619     +++ mpfr-3.1.2-b/src/version.c 2014-12-04 01:41:57.339791833 +0000
1620     @@ -25,5 +25,5 @@
1621     const char *
1622     mpfr_get_version (void)
1623     {
1624     - return "3.1.2-p10";
1625     + return "3.1.2-p11";
1626     }