source: patches/mpfr-3.1.2-fixes-2.patch@ 89306f9

clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 89306f9 was c8b646b, checked in by William Harrington <kb0iic@…>, 11 years ago

Add MPFR patch level 5 patch.

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