summaryrefslogtreecommitdiffstats
path: root/package/mpfr/mpfr-3.0.1_p4.patch
blob: 9604635a283a93fe1c6b86c937fc457f6a04aa72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
--- mpfr-3.0.1-a/PATCHES	2011-04-12 10:50:02.000000000 +0000
+++ mpfr-3.0.1-b/PATCHES	2011-04-12 10:50:02.000000000 +0000
@@ -0,0 +1 @@
+asin_exprange
diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
--- mpfr-3.0.1-a/VERSION	2011-04-04 10:19:18.000000000 +0000
+++ mpfr-3.0.1-b/VERSION	2011-04-12 10:50:02.000000000 +0000
@@ -1 +1 @@
-3.0.1
+3.0.1-p1
diff -Naurd mpfr-3.0.1-a/asin.c mpfr-3.0.1-b/asin.c
--- mpfr-3.0.1-a/asin.c	2011-04-04 10:19:18.000000000 +0000
+++ mpfr-3.0.1-b/asin.c	2011-04-12 10:50:02.000000000 +0000
@@ -63,11 +63,14 @@
 
   compared = mpfr_cmp_ui (xp, 1);
 
+  MPFR_SAVE_EXPO_MARK (expo);
+
   if (MPFR_UNLIKELY (compared >= 0))
     {
       mpfr_clear (xp);
       if (compared > 0)                  /* asin(x) = NaN for |x| > 1 */
         {
+          MPFR_SAVE_EXPO_FREE (expo);
           MPFR_SET_NAN (asin);
           MPFR_RET_NAN;
         }
@@ -80,13 +83,11 @@
               inexact = -mpfr_const_pi (asin, MPFR_INVERT_RND(rnd_mode));
               MPFR_CHANGE_SIGN (asin);
             }
-          mpfr_div_2ui (asin, asin, 1, rnd_mode); /* May underflow */
-          return inexact;
+          mpfr_div_2ui (asin, asin, 1, rnd_mode);
         }
     }
-
-  MPFR_SAVE_EXPO_MARK (expo);
-
+  else
+    {
   /* Compute exponent of 1 - ABS(x) */
   mpfr_ui_sub (xp, 1, xp, MPFR_RNDD);
   MPFR_ASSERTD (MPFR_GET_EXP (xp) <= 0);
@@ -115,6 +116,7 @@
   inexact = mpfr_set (asin, xp, rnd_mode);
 
   mpfr_clear (xp);
+    }
 
   MPFR_SAVE_EXPO_FREE (expo);
   return mpfr_check_range (asin, inexact, rnd_mode);
diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
--- mpfr-3.0.1-a/mpfr.h	2011-04-04 10:19:18.000000000 +0000
+++ mpfr-3.0.1-b/mpfr.h	2011-04-12 10:50:02.000000000 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 3
 #define MPFR_VERSION_MINOR 0
 #define MPFR_VERSION_PATCHLEVEL 1
-#define MPFR_VERSION_STRING "3.0.1"
+#define MPFR_VERSION_STRING "3.0.1-p1"
 
 /* Macros dealing with MPFR VERSION */
 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.0.1-a/tests/tasin.c mpfr-3.0.1-b/tests/tasin.c
--- mpfr-3.0.1-a/tests/tasin.c	2011-04-04 10:19:17.000000000 +0000
+++ mpfr-3.0.1-b/tests/tasin.c	2011-04-12 10:50:02.000000000 +0000
@@ -219,6 +219,49 @@
   mpfr_clear (y);
 }
 
+static void
+reduced_expo_range (void)
+{
+  mpfr_exp_t emin, emax;
+  mpfr_t x, y, ex_y;
+  int inex, ex_inex;
+  unsigned int flags, ex_flags;
+
+  emin = mpfr_get_emin ();
+  emax = mpfr_get_emax ();
+
+  mpfr_inits2 (4, x, y, ex_y, (mpfr_ptr) 0);
+  mpfr_set_str (x, "-0.1e1", 2, MPFR_RNDN);
+
+  mpfr_set_emin (1);
+  mpfr_set_emax (1);
+  mpfr_clear_flags ();
+  inex = mpfr_asin (y, x, MPFR_RNDA);
+  flags = __gmpfr_flags;
+  mpfr_set_emin (emin);
+  mpfr_set_emax (emax);
+
+  mpfr_set_str (ex_y, "-0.1101e1", 2, MPFR_RNDN);
+  ex_inex = -1;
+  ex_flags = MPFR_FLAGS_INEXACT;
+
+  if (SIGN (inex) != ex_inex || flags != ex_flags ||
+      ! mpfr_equal_p (y, ex_y))
+    {
+      printf ("Error in reduced_expo_range\non x = ");
+      mpfr_dump (x);
+      printf ("Expected y = ");
+      mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
+      printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
+      printf ("Got      y = ");
+      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
+      printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
+      exit (1);
+    }
+
+  mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
+}
+
 int
 main (void)
 {
@@ -226,6 +269,7 @@
 
   special ();
   special_overflow ();
+  reduced_expo_range ();
 
   test_generic (2, 100, 15);
 
diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
--- mpfr-3.0.1-a/version.c	2011-04-04 10:19:18.000000000 +0000
+++ mpfr-3.0.1-b/version.c	2011-04-12 10:50:02.000000000 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "3.0.1";
+  return "3.0.1-p1";
 }
diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
--- mpfr-3.0.1-a/PATCHES	2011-05-04 11:18:33.000000000 +0000
+++ mpfr-3.0.1-b/PATCHES	2011-05-04 11:18:33.000000000 +0000
@@ -0,0 +1 @@
+rec_sqrt-carry
diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
--- mpfr-3.0.1-a/VERSION	2011-04-12 10:50:02.000000000 +0000
+++ mpfr-3.0.1-b/VERSION	2011-05-04 11:18:33.000000000 +0000
@@ -1 +1 @@
-3.0.1-p1
+3.0.1-p2
diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
--- mpfr-3.0.1-a/mpfr.h	2011-04-12 10:50:02.000000000 +0000
+++ mpfr-3.0.1-b/mpfr.h	2011-05-04 11:18:33.000000000 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 3
 #define MPFR_VERSION_MINOR 0
 #define MPFR_VERSION_PATCHLEVEL 1
-#define MPFR_VERSION_STRING "3.0.1-p1"
+#define MPFR_VERSION_STRING "3.0.1-p2"
 
 /* Macros dealing with MPFR VERSION */
 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.0.1-a/rec_sqrt.c mpfr-3.0.1-b/rec_sqrt.c
--- mpfr-3.0.1-a/rec_sqrt.c	2011-04-04 10:19:18.000000000 +0000
+++ mpfr-3.0.1-b/rec_sqrt.c	2011-05-04 11:18:33.000000000 +0000
@@ -375,20 +375,37 @@
       MPFR_ASSERTD(un == ln + 1 || un == ln + 2);
       /* the high un-ln limbs of u will overlap the low part of {x+ln,xn},
          we need to add or subtract the overlapping part {u + ln, un - ln} */
+      /* Warning! th may be 0, in which case the mpn_add_1 and mpn_sub_1
+         below (with size = th) mustn't be used. In such a case, the limb
+         (carry) will be 0, so that this is semantically a no-op, but if
+         mpn_add_1 and mpn_sub_1 are used, GMP (currently) still does a
+         non-atomic read/write in a place that is not always allocated,
+         with the possible consequences: a crash if the corresponding
+         address is not mapped, or (rather unlikely) memory corruption
+         if another process/thread writes at the same place; things may
+         be worse with future GMP versions. Hence the tests carry != 0. */
       if (neg == 0)
         {
           if (ln > 0)
             MPN_COPY (x, u, ln);
           cy = mpn_add (x + ln, x + ln, xn, u + ln, un - ln);
           /* add cu at x+un */
-          cy += mpn_add_1 (x + un, x + un, th, cu);
+          if (cu != 0)
+            {
+              MPFR_ASSERTD (th != 0);
+              cy += mpn_add_1 (x + un, x + un, th, cu);
+            }
         }
       else /* negative case */
         {
           /* subtract {u+ln, un-ln} from {x+ln,un} */
           cy = mpn_sub (x + ln, x + ln, xn, u + ln, un - ln);
           /* carry cy is at x+un, like cu */
-          cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
+          if (cy + cu != 0)
+            {
+              MPFR_ASSERTD (th != 0);
+              cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
+            }
           /* cy cannot be zero, since the most significant bit of Xh is 1,
              and the correction is bounded by 2^{-h+3} */
           MPFR_ASSERTD(cy == 0);
diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
--- mpfr-3.0.1-a/version.c	2011-04-12 10:50:02.000000000 +0000
+++ mpfr-3.0.1-b/version.c	2011-05-04 11:18:33.000000000 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "3.0.1-p1";
+  return "3.0.1-p2";
 }
diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
--- mpfr-3.0.1-a/PATCHES	2011-05-05 00:00:35.000000000 +0000
+++ mpfr-3.0.1-b/PATCHES	2011-05-05 00:00:35.000000000 +0000
@@ -0,0 +1 @@
+atan-expo-range
diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
--- mpfr-3.0.1-a/VERSION	2011-05-04 11:18:33.000000000 +0000
+++ mpfr-3.0.1-b/VERSION	2011-05-05 00:00:35.000000000 +0000
@@ -1 +1 @@
-3.0.1-p2
+3.0.1-p3
diff -Naurd mpfr-3.0.1-a/atan.c mpfr-3.0.1-b/atan.c
--- mpfr-3.0.1-a/atan.c	2011-04-04 10:19:18.000000000 +0000
+++ mpfr-3.0.1-b/atan.c	2011-05-05 00:00:35.000000000 +0000
@@ -431,5 +431,5 @@
   MPFR_GROUP_CLEAR (group);
 
   MPFR_SAVE_EXPO_FREE (expo);
-  return mpfr_check_range (arctgt, inexact, rnd_mode);
+  return mpfr_check_range (atan, inexact, rnd_mode);
 }
diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
--- mpfr-3.0.1-a/mpfr.h	2011-05-04 11:18:33.000000000 +0000
+++ mpfr-3.0.1-b/mpfr.h	2011-05-05 00:00:35.000000000 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 3
 #define MPFR_VERSION_MINOR 0
 #define MPFR_VERSION_PATCHLEVEL 1
-#define MPFR_VERSION_STRING "3.0.1-p2"
+#define MPFR_VERSION_STRING "3.0.1-p3"
 
 /* Macros dealing with MPFR VERSION */
 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.0.1-a/tests/tatan.c mpfr-3.0.1-b/tests/tatan.c
--- mpfr-3.0.1-a/tests/tatan.c	2011-04-04 10:19:17.000000000 +0000
+++ mpfr-3.0.1-b/tests/tatan.c	2011-05-05 00:00:35.000000000 +0000
@@ -535,6 +535,52 @@
   mpfr_clears (a, x, y, (mpfr_ptr) 0);
 }
 
+/* http://websympa.loria.fr/wwsympa/arc/mpfr/2011-05/msg00008.html
+ * Incorrect flags (in debug mode on a 32-bit machine, assertion failure).
+ */
+static void
+reduced_expo_range (void)
+{
+  mpfr_exp_t emin, emax;
+  mpfr_t x, y, ex_y;
+  int inex, ex_inex;
+  unsigned int flags, ex_flags;
+
+  emin = mpfr_get_emin ();
+  emax = mpfr_get_emax ();
+
+  mpfr_inits2 (12, x, y, ex_y, (mpfr_ptr) 0);
+  mpfr_set_str (x, "0.1e-5", 2, MPFR_RNDN);
+
+  mpfr_set_emin (-5);
+  mpfr_set_emax (-5);
+  mpfr_clear_flags ();
+  inex = mpfr_atan (y, x, MPFR_RNDN);
+  flags = __gmpfr_flags;
+  mpfr_set_emin (emin);
+  mpfr_set_emax (emax);
+
+  mpfr_set_str (ex_y, "0.1e-5", 2, MPFR_RNDN);
+  ex_inex = 1;
+  ex_flags = MPFR_FLAGS_INEXACT;
+
+  if (SIGN (inex) != ex_inex || flags != ex_flags ||
+      ! mpfr_equal_p (y, ex_y))
+    {
+      printf ("Error in reduced_expo_range\non x = ");
+      mpfr_dump (x);
+      printf ("Expected y = ");
+      mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
+      printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
+      printf ("Got      y = ");
+      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
+      printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
+      exit (1);
+    }
+
+  mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -546,6 +592,7 @@
   smallvals_atan2 ();
   atan2_bug_20071003 ();
   atan2_different_prec ();
+  reduced_expo_range ();
 
   test_generic_atan  (2, 200, 17);
   test_generic_atan2 (2, 200, 17);
diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
--- mpfr-3.0.1-a/version.c	2011-05-04 11:18:33.000000000 +0000
+++ mpfr-3.0.1-b/version.c	2011-05-05 00:00:35.000000000 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "3.0.1-p2";
+  return "3.0.1-p3";
 }
diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
--- mpfr-3.0.1-a/PATCHES	2011-05-09 14:48:24.000000000 +0000
+++ mpfr-3.0.1-b/PATCHES	2011-05-09 14:48:24.000000000 +0000
@@ -0,0 +1 @@
+texp-zero
diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
--- mpfr-3.0.1-a/VERSION	2011-05-05 00:00:35.000000000 +0000
+++ mpfr-3.0.1-b/VERSION	2011-05-09 14:48:24.000000000 +0000
@@ -1 +1 @@
-3.0.1-p3
+3.0.1-p4
diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
--- mpfr-3.0.1-a/mpfr.h	2011-05-05 00:00:35.000000000 +0000
+++ mpfr-3.0.1-b/mpfr.h	2011-05-09 14:48:24.000000000 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 3
 #define MPFR_VERSION_MINOR 0
 #define MPFR_VERSION_PATCHLEVEL 1
-#define MPFR_VERSION_STRING "3.0.1-p3"
+#define MPFR_VERSION_STRING "3.0.1-p4"
 
 /* Macros dealing with MPFR VERSION */
 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.0.1-a/tests/texp.c mpfr-3.0.1-b/tests/texp.c
--- mpfr-3.0.1-a/tests/texp.c	2011-04-04 10:19:17.000000000 +0000
+++ mpfr-3.0.1-b/tests/texp.c	2011-05-09 14:48:24.000000000 +0000
@@ -170,7 +170,9 @@
       mpfr_set_prec (x, prec);
       mpfr_set_prec (y, prec);
       mpfr_set_prec (z, prec);
-      mpfr_urandomb (x, RANDS);
+      do
+        mpfr_urandomb (x, RANDS);
+      while (MPFR_IS_ZERO (x));  /* 0 is handled by mpfr_exp only */
       rnd = RND_RAND ();
       mpfr_exp_2 (y, x, rnd);
       mpfr_exp_3 (z, x, rnd);
diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
--- mpfr-3.0.1-a/version.c	2011-05-05 00:00:35.000000000 +0000
+++ mpfr-3.0.1-b/version.c	2011-05-09 14:48:24.000000000 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "3.0.1-p3";
+  return "3.0.1-p4";
 }