mpfr-3.0.1_p4.patch 12 KB

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