RS: fix for fix
[minix.git] / external / lgpl3 / mpfr / patches / 0000-mpfr.patch
blobcc6b27e00de8d88502439714905ea55c90a7bff7
1 diff -r -x CVS -N -U 3 dist/ansi2knr.c dist.orig/ansi2knr.c
2 --- dist/ansi2knr.c 2011-04-04 12:19:46.000000000 +0200
3 +++ dist.orig/ansi2knr.c 2011-06-20 07:53:13.000000000 +0200
4 @@ -1,6 +1,6 @@
5 /* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */
7 -/*$Id: ansi2knr.c,v 1.14 2003/09/06 05:36:56 eggert Exp $*/
8 +/*$Id: ansi2knr.c,v 1.1.1.1 2011/06/20 05:53:13 mrg Exp $*/
9 /* Convert ANSI C function definitions to K&R ("traditional C") syntax */
12 diff -r -x CVS -N -U 3 dist/asin.c dist.orig/asin.c
13 --- dist/asin.c 2011-04-04 12:19:18.000000000 +0200
14 +++ dist.orig/asin.c 2011-07-06 21:53:24.000000000 +0200
15 @@ -63,11 +63,14 @@
17 compared = mpfr_cmp_ui (xp, 1);
19 + MPFR_SAVE_EXPO_MARK (expo);
21 if (MPFR_UNLIKELY (compared >= 0))
23 mpfr_clear (xp);
24 if (compared > 0) /* asin(x) = NaN for |x| > 1 */
26 + MPFR_SAVE_EXPO_FREE (expo);
27 MPFR_SET_NAN (asin);
28 MPFR_RET_NAN;
30 @@ -80,13 +83,11 @@
31 inexact = -mpfr_const_pi (asin, MPFR_INVERT_RND(rnd_mode));
32 MPFR_CHANGE_SIGN (asin);
34 - mpfr_div_2ui (asin, asin, 1, rnd_mode); /* May underflow */
35 - return inexact;
36 + mpfr_div_2ui (asin, asin, 1, rnd_mode);
40 - MPFR_SAVE_EXPO_MARK (expo);
42 + else
43 + {
44 /* Compute exponent of 1 - ABS(x) */
45 mpfr_ui_sub (xp, 1, xp, MPFR_RNDD);
46 MPFR_ASSERTD (MPFR_GET_EXP (xp) <= 0);
47 @@ -115,6 +116,7 @@
48 inexact = mpfr_set (asin, xp, rnd_mode);
50 mpfr_clear (xp);
51 + }
53 MPFR_SAVE_EXPO_FREE (expo);
54 return mpfr_check_range (asin, inexact, rnd_mode);
55 diff -r -x CVS -N -U 3 dist/atan.c dist.orig/atan.c
56 --- dist/atan.c 2011-04-04 12:19:18.000000000 +0200
57 +++ dist.orig/atan.c 2011-07-06 21:53:24.000000000 +0200
58 @@ -431,5 +431,5 @@
59 MPFR_GROUP_CLEAR (group);
61 MPFR_SAVE_EXPO_FREE (expo);
62 - return mpfr_check_range (arctgt, inexact, rnd_mode);
63 + return mpfr_check_range (atan, inexact, rnd_mode);
65 diff -r -x CVS -N -U 3 dist/config.guess dist.orig/config.guess
66 --- dist/config.guess 2011-04-04 12:19:46.000000000 +0200
67 +++ dist.orig/config.guess 2012-07-19 21:34:26.000000000 +0200
68 @@ -968,6 +968,9 @@
69 sparc:Linux:*:* | sparc64:Linux:*:*)
70 echo ${UNAME_MACHINE}-unknown-linux-gnu
71 exit ;;
72 + tile*:Linux:*:*)
73 + echo ${UNAME_MACHINE}-unknown-linux-gnu
74 + exit ;;
75 vax:Linux:*:*)
76 echo ${UNAME_MACHINE}-dec-linux-gnu
77 exit ;;
78 diff -r -x CVS -N -U 3 dist/Makefile.in dist.orig/Makefile.in
79 --- dist/Makefile.in 2011-04-04 12:19:46.000000000 +0200
80 +++ dist.orig/Makefile.in 2011-06-21 06:03:33.000000000 +0200
81 @@ -464,8 +464,12 @@
82 $(SHELL) ./config.status --recheck
84 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
85 + @echo "NOT REBUILDING $@"
86 +NetBSD_DISABLED_configure:
87 $(am__cd) $(srcdir) && $(AUTOCONF)
88 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
89 + @echo "NOT REBUILDING $@"
90 +NetBSD_DISABLED_aclocal:
91 $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
92 $(am__aclocal_m4_deps):
93 mparam.h: $(top_builddir)/config.status $(srcdir)/mparam_h.in
94 @@ -2048,6 +2052,8 @@
95 # should not be a problem in practice, in particular because "make dist"
96 # automatically rebuilds get_patches.c before generating the archives.
97 $(srcdir)/get_patches.c: PATCHES get_patches.sh
98 + @echo "NOT REBUILDING $@"
99 +NetBSD_DISABLED_get_patches.c:
100 (cd $(srcdir) && ./get_patches.sh) > $@ || rm -f $@
102 tune:
103 diff -r -x CVS -N -U 3 dist/mpfr.h dist.orig/mpfr.h
104 --- dist/mpfr.h 2011-04-04 12:19:18.000000000 +0200
105 +++ dist.orig/mpfr.h 2011-07-06 21:53:24.000000000 +0200
106 @@ -27,7 +27,7 @@
107 #define MPFR_VERSION_MAJOR 3
108 #define MPFR_VERSION_MINOR 0
109 #define MPFR_VERSION_PATCHLEVEL 1
110 -#define MPFR_VERSION_STRING "3.0.1"
111 +#define MPFR_VERSION_STRING "3.0.1-p4"
113 /* Macros dealing with MPFR VERSION */
114 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
115 diff -r -x CVS -N -U 3 dist/PATCHES dist.orig/PATCHES
116 --- dist/PATCHES 2011-04-04 12:19:18.000000000 +0200
117 +++ dist.orig/PATCHES 2011-07-06 21:53:24.000000000 +0200
118 @@ -0,0 +1,4 @@
119 +texp-zero
120 +atan-expo-range
121 +rec_sqrt-carry
122 +asin_exprange
123 diff -r -x CVS -N -U 3 dist/rec_sqrt.c dist.orig/rec_sqrt.c
124 --- dist/rec_sqrt.c 2011-04-04 12:19:18.000000000 +0200
125 +++ dist.orig/rec_sqrt.c 2011-07-06 21:53:24.000000000 +0200
126 @@ -375,20 +375,37 @@
127 MPFR_ASSERTD(un == ln + 1 || un == ln + 2);
128 /* the high un-ln limbs of u will overlap the low part of {x+ln,xn},
129 we need to add or subtract the overlapping part {u + ln, un - ln} */
130 + /* Warning! th may be 0, in which case the mpn_add_1 and mpn_sub_1
131 + below (with size = th) mustn't be used. In such a case, the limb
132 + (carry) will be 0, so that this is semantically a no-op, but if
133 + mpn_add_1 and mpn_sub_1 are used, GMP (currently) still does a
134 + non-atomic read/write in a place that is not always allocated,
135 + with the possible consequences: a crash if the corresponding
136 + address is not mapped, or (rather unlikely) memory corruption
137 + if another process/thread writes at the same place; things may
138 + be worse with future GMP versions. Hence the tests carry != 0. */
139 if (neg == 0)
141 if (ln > 0)
142 MPN_COPY (x, u, ln);
143 cy = mpn_add (x + ln, x + ln, xn, u + ln, un - ln);
144 /* add cu at x+un */
145 - cy += mpn_add_1 (x + un, x + un, th, cu);
146 + if (cu != 0)
148 + MPFR_ASSERTD (th != 0);
149 + cy += mpn_add_1 (x + un, x + un, th, cu);
152 else /* negative case */
154 /* subtract {u+ln, un-ln} from {x+ln,un} */
155 cy = mpn_sub (x + ln, x + ln, xn, u + ln, un - ln);
156 /* carry cy is at x+un, like cu */
157 - cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
158 + if (cy + cu != 0)
160 + MPFR_ASSERTD (th != 0);
161 + cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
163 /* cy cannot be zero, since the most significant bit of Xh is 1,
164 and the correction is bounded by 2^{-h+3} */
165 MPFR_ASSERTD(cy == 0);
166 diff -r -x CVS -N -U 3 dist/tests/tasin.c dist.orig/tests/tasin.c
167 --- dist/tests/tasin.c 2011-04-04 12:19:17.000000000 +0200
168 +++ dist.orig/tests/tasin.c 2011-07-06 21:53:24.000000000 +0200
169 @@ -219,6 +219,49 @@
170 mpfr_clear (y);
173 +static void
174 +reduced_expo_range (void)
176 + mpfr_exp_t emin, emax;
177 + mpfr_t x, y, ex_y;
178 + int inex, ex_inex;
179 + unsigned int flags, ex_flags;
181 + emin = mpfr_get_emin ();
182 + emax = mpfr_get_emax ();
184 + mpfr_inits2 (4, x, y, ex_y, (mpfr_ptr) 0);
185 + mpfr_set_str (x, "-0.1e1", 2, MPFR_RNDN);
187 + mpfr_set_emin (1);
188 + mpfr_set_emax (1);
189 + mpfr_clear_flags ();
190 + inex = mpfr_asin (y, x, MPFR_RNDA);
191 + flags = __gmpfr_flags;
192 + mpfr_set_emin (emin);
193 + mpfr_set_emax (emax);
195 + mpfr_set_str (ex_y, "-0.1101e1", 2, MPFR_RNDN);
196 + ex_inex = -1;
197 + ex_flags = MPFR_FLAGS_INEXACT;
199 + if (SIGN (inex) != ex_inex || flags != ex_flags ||
200 + ! mpfr_equal_p (y, ex_y))
202 + printf ("Error in reduced_expo_range\non x = ");
203 + mpfr_dump (x);
204 + printf ("Expected y = ");
205 + mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
206 + printf ("\n inex = %d, flags = %u\n", ex_inex, ex_flags);
207 + printf ("Got y = ");
208 + mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
209 + printf ("\n inex = %d, flags = %u\n", SIGN (inex), flags);
210 + exit (1);
213 + mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
217 main (void)
219 @@ -226,6 +269,7 @@
221 special ();
222 special_overflow ();
223 + reduced_expo_range ();
225 test_generic (2, 100, 15);
227 diff -r -x CVS -N -U 3 dist/tests/tatan.c dist.orig/tests/tatan.c
228 --- dist/tests/tatan.c 2011-04-04 12:19:17.000000000 +0200
229 +++ dist.orig/tests/tatan.c 2011-07-06 21:53:24.000000000 +0200
230 @@ -535,6 +535,52 @@
231 mpfr_clears (a, x, y, (mpfr_ptr) 0);
234 +/* http://websympa.loria.fr/wwsympa/arc/mpfr/2011-05/msg00008.html
235 + * Incorrect flags (in debug mode on a 32-bit machine, assertion failure).
236 + */
237 +static void
238 +reduced_expo_range (void)
240 + mpfr_exp_t emin, emax;
241 + mpfr_t x, y, ex_y;
242 + int inex, ex_inex;
243 + unsigned int flags, ex_flags;
245 + emin = mpfr_get_emin ();
246 + emax = mpfr_get_emax ();
248 + mpfr_inits2 (12, x, y, ex_y, (mpfr_ptr) 0);
249 + mpfr_set_str (x, "0.1e-5", 2, MPFR_RNDN);
251 + mpfr_set_emin (-5);
252 + mpfr_set_emax (-5);
253 + mpfr_clear_flags ();
254 + inex = mpfr_atan (y, x, MPFR_RNDN);
255 + flags = __gmpfr_flags;
256 + mpfr_set_emin (emin);
257 + mpfr_set_emax (emax);
259 + mpfr_set_str (ex_y, "0.1e-5", 2, MPFR_RNDN);
260 + ex_inex = 1;
261 + ex_flags = MPFR_FLAGS_INEXACT;
263 + if (SIGN (inex) != ex_inex || flags != ex_flags ||
264 + ! mpfr_equal_p (y, ex_y))
266 + printf ("Error in reduced_expo_range\non x = ");
267 + mpfr_dump (x);
268 + printf ("Expected y = ");
269 + mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
270 + printf ("\n inex = %d, flags = %u\n", ex_inex, ex_flags);
271 + printf ("Got y = ");
272 + mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
273 + printf ("\n inex = %d, flags = %u\n", SIGN (inex), flags);
274 + exit (1);
277 + mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
281 main (int argc, char *argv[])
283 @@ -546,6 +592,7 @@
284 smallvals_atan2 ();
285 atan2_bug_20071003 ();
286 atan2_different_prec ();
287 + reduced_expo_range ();
289 test_generic_atan (2, 200, 17);
290 test_generic_atan2 (2, 200, 17);
291 diff -r -x CVS -N -U 3 dist/tests/texp.c dist.orig/tests/texp.c
292 --- dist/tests/texp.c 2011-04-04 12:19:17.000000000 +0200
293 +++ dist.orig/tests/texp.c 2011-07-06 21:53:24.000000000 +0200
294 @@ -170,7 +170,9 @@
295 mpfr_set_prec (x, prec);
296 mpfr_set_prec (y, prec);
297 mpfr_set_prec (z, prec);
298 - mpfr_urandomb (x, RANDS);
299 + do
300 + mpfr_urandomb (x, RANDS);
301 + while (MPFR_IS_ZERO (x)); /* 0 is handled by mpfr_exp only */
302 rnd = RND_RAND ();
303 mpfr_exp_2 (y, x, rnd);
304 mpfr_exp_3 (z, x, rnd);
305 diff -r -x CVS -N -U 3 dist/VERSION dist.orig/VERSION
306 --- dist/VERSION 2011-04-04 12:19:18.000000000 +0200
307 +++ dist.orig/VERSION 2011-07-06 21:53:24.000000000 +0200
308 @@ -1 +1 @@
309 -3.0.1
310 +3.0.1-p4
311 diff -r -x CVS -N -U 3 dist/version.c dist.orig/version.c
312 --- dist/version.c 2011-04-04 12:19:18.000000000 +0200
313 +++ dist.orig/version.c 2011-07-06 21:53:24.000000000 +0200
314 @@ -25,5 +25,5 @@
315 const char *
316 mpfr_get_version (void)
318 - return "3.0.1";
319 + return "3.0.1-p4";