summaryrefslogtreecommitdiff
path: root/patches/mpfr/3.1.3/180-sqrt.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/mpfr/3.1.3/180-sqrt.patch')
-rw-r--r--patches/mpfr/3.1.3/180-sqrt.patch97
1 files changed, 97 insertions, 0 deletions
diff --git a/patches/mpfr/3.1.3/180-sqrt.patch b/patches/mpfr/3.1.3/180-sqrt.patch
new file mode 100644
index 0000000..4887009
--- /dev/null
+++ b/patches/mpfr/3.1.3/180-sqrt.patch
@@ -0,0 +1,97 @@
+diff -Naurd mpfr-3.1.3-a/PATCHES mpfr-3.1.3-b/PATCHES
+--- mpfr-3.1.3-a/PATCHES 2016-02-15 15:12:59.450314624 +0000
++++ mpfr-3.1.3-b/PATCHES 2016-02-15 15:12:59.510314695 +0000
+@@ -0,0 +1 @@
++sqrt
+diff -Naurd mpfr-3.1.3-a/VERSION mpfr-3.1.3-b/VERSION
+--- mpfr-3.1.3-a/VERSION 2016-02-15 15:11:00.966156445 +0000
++++ mpfr-3.1.3-b/VERSION 2016-02-15 15:12:59.510314695 +0000
+@@ -1 +1 @@
+-3.1.3-p7
++3.1.3-p8
+diff -Naurd mpfr-3.1.3-a/src/mpfr.h mpfr-3.1.3-b/src/mpfr.h
+--- mpfr-3.1.3-a/src/mpfr.h 2016-02-15 15:11:00.962156439 +0000
++++ mpfr-3.1.3-b/src/mpfr.h 2016-02-15 15:12:59.510314695 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 3
+-#define MPFR_VERSION_STRING "3.1.3-p7"
++#define MPFR_VERSION_STRING "3.1.3-p8"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.3-a/src/sqrt.c mpfr-3.1.3-b/src/sqrt.c
+--- mpfr-3.1.3-a/src/sqrt.c 2015-06-19 19:55:09.000000000 +0000
++++ mpfr-3.1.3-b/src/sqrt.c 2016-02-15 15:12:59.490314671 +0000
+@@ -211,10 +211,11 @@
+ rsize --;
+ sh = 0;
+ }
++ /* now rsize = MPFR_LIMB_SIZE(r) */
+ if (mpn_add_1 (rp0, rp, rsize, MPFR_LIMB_ONE << sh))
+ {
+ expr ++;
+- rp[rsize - 1] = MPFR_LIMB_HIGHBIT;
++ rp0[rsize - 1] = MPFR_LIMB_HIGHBIT;
+ }
+ goto end;
+
+diff -Naurd mpfr-3.1.3-a/src/version.c mpfr-3.1.3-b/src/version.c
+--- mpfr-3.1.3-a/src/version.c 2016-02-15 15:11:00.966156445 +0000
++++ mpfr-3.1.3-b/src/version.c 2016-02-15 15:12:59.510314695 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.3-p7";
++ return "3.1.3-p8";
+ }
+diff -Naurd mpfr-3.1.3-a/tests/tsqrt.c mpfr-3.1.3-b/tests/tsqrt.c
+--- mpfr-3.1.3-a/tests/tsqrt.c 2015-06-19 19:55:10.000000000 +0000
++++ mpfr-3.1.3-b/tests/tsqrt.c 2016-02-15 15:12:59.490314671 +0000
+@@ -569,6 +569,35 @@
+ mpfr_clear (y);
+ }
+
++/* Bug reported by Fredrik Johansson, occurring when:
++ - the precision of the result is a multiple of the number of bits
++ per word (GMP_NUMB_BITS),
++ - the rounding mode is to nearest (MPFR_RNDN),
++ - internally, the result has to be rounded up to a power of 2.
++*/
++static void
++bug20160120 (void)
++{
++ mpfr_t x, y;
++
++ mpfr_init2 (x, 4 * GMP_NUMB_BITS);
++ mpfr_init2 (y, GMP_NUMB_BITS);
++
++ mpfr_set_ui (x, 1, MPFR_RNDN);
++ mpfr_nextbelow (x);
++ mpfr_sqrt (y, x, MPFR_RNDN);
++ MPFR_ASSERTN(mpfr_check (y));
++ MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0);
++
++ mpfr_set_prec (y, 2 * GMP_NUMB_BITS);
++ mpfr_sqrt (y, x, MPFR_RNDN);
++ MPFR_ASSERTN(mpfr_check (y));
++ MPFR_ASSERTN(mpfr_cmp_ui (y, 1) == 0);
++
++ mpfr_clear(x);
++ mpfr_clear(y);
++}
++
+ #define TEST_FUNCTION test_sqrt
+ #define TEST_RANDOM_POS 8
+ #include "tgeneric.c"
+@@ -704,6 +733,8 @@
+ data_check ("data/sqrt", mpfr_sqrt, "mpfr_sqrt");
+ bad_cases (mpfr_sqrt, mpfr_sqr, "mpfr_sqrt", 8, -256, 255, 4, 128, 800, 50);
+
++ bug20160120 ();
++
+ tests_end_mpfr ();
+ return 0;
+ }