summaryrefslogtreecommitdiff
path: root/patches/gmp
diff options
context:
space:
mode:
Diffstat (limited to 'patches/gmp')
-rw-r--r--patches/gmp/4.2.2/100-mpf_set_str.patch38
-rw-r--r--patches/gmp/4.2.4/100-mpf_eq.patch219
-rw-r--r--patches/gmp/4.2.4/110-mpf_set_str.patch32
-rw-r--r--patches/gmp/4.2.4/120-perfpow.patch149
-rw-r--r--patches/gmp/4.3.0/100-multiplicity-that-does-not-fit-an-int.patch33
-rw-r--r--patches/gmp/4.3.0/110-unbounded-alloc.patch31
-rw-r--r--patches/gmp/5.0.1/110-get-mpn_sub_1-size-argument-right.patch38
-rw-r--r--patches/gmp/5.0.1/120-fix-r0-clobbering-issue.patch77
-rw-r--r--patches/gmp/5.0.2/110-get-mpn_sub_1-size-argument-right.patch38
-rw-r--r--patches/gmp/5.0.2/120-fix-r0-clobbering-issue.patch77
-rw-r--r--patches/gmp/5.1.1/100-fix-bulldozer-piledriver.patch21
-rw-r--r--patches/gmp/5.1.1/110-mpz_powm_ui.patch39
-rw-r--r--patches/gmp/5.1.1/120-fix-mpn_sbpi1_div_qr_sec.patch164
-rw-r--r--patches/gmp/5.1.1/130-do-not-clobber-f16-f18.patch73
-rw-r--r--patches/gmp/6.1.0/100-fix-broadwell-skylake.patch59
15 files changed, 650 insertions, 438 deletions
diff --git a/patches/gmp/4.2.2/100-mpf_set_str.patch b/patches/gmp/4.2.2/100-mpf_set_str.patch
deleted file mode 100644
index 6d9ac04..0000000
--- a/patches/gmp/4.2.2/100-mpf_set_str.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-Original patch from http://gmplib.org/patches/mpf_set_str.c.diff
-Re-diffed to match crosstool-NG conventions.
-
-diff -dur gmp-4.2.2.orig/mpf/set_str.c gmp-4.2.2/mpf/set_str.c
---- gmp-4.2.2.orig/mpf/set_str.c 2007-08-30 20:31:40.000000000 +0200
-+++ gmp-4.2.2/mpf/set_str.c 2008-01-28 23:05:29.000000000 +0100
-@@ -271,8 +271,29 @@
- }
-
- if (expptr != 0)
-- /* FIXME: Should do some error checking here. */
-- exp_in_base = strtol (expptr, (char **) 0, exp_base);
-+ {
-+ /* Scan and convert the exponent, in base exp_base. */
-+ long dig, neg = -(long) ('-' == expptr[0]);
-+ expptr -= neg; /* conditional increment */
-+ c = (unsigned char) *expptr++;
-+ dig = digit_value[c];
-+ if (dig >= exp_base)
-+ {
-+ TMP_FREE;
-+ return -1;
-+ }
-+ exp_in_base = dig;
-+ c = (unsigned char) *expptr++;
-+ dig = digit_value[c];
-+ while (dig < exp_base)
-+ {
-+ exp_in_base = exp_in_base * exp_base;
-+ exp_in_base += dig;
-+ c = (unsigned char) *expptr++;
-+ dig = digit_value[c];
-+ }
-+ exp_in_base = (exp_in_base ^ neg) - neg; /* conditional negation */
-+ }
- else
- exp_in_base = 0;
- if (dotpos != 0)
diff --git a/patches/gmp/4.2.4/100-mpf_eq.patch b/patches/gmp/4.2.4/100-mpf_eq.patch
deleted file mode 100644
index 942f7de..0000000
--- a/patches/gmp/4.2.4/100-mpf_eq.patch
+++ /dev/null
@@ -1,219 +0,0 @@
-Original patch from: mpf_eq.diff
-
--= BEGIN original header =-
--= END original header =-
-
-diff -durN gmp-4.2.4.orig/doc/gmp.texi gmp-4.2.4/doc/gmp.texi
---- gmp-4.2.4.orig/doc/gmp.texi 2008-09-18 17:36:14.000000000 +0200
-+++ gmp-4.2.4/doc/gmp.texi 2009-03-08 18:36:16.000000000 +0100
-@@ -4849,9 +4849,12 @@
- equal, zero otherwise. I.e., test if @var{op1} and @var{op2} are approximately
- equal.
-
--Caution: Currently only whole limbs are compared, and only in an exact
--fashion. In the future values like 1000 and 0111 may be considered the same
--to 3 bits (on the basis that their difference is that small).
-+Caution 1: All version of GMP up to version 4.2.4 compared just whole limbs,
-+meaning sometimes more than @var{op3} bits, sometimes fewer.
-+
-+Caution 2: This function will consider XXX11...111 and XX100...000 different,
-+even if ... is replaced by a semi-infinite number of bits. Such numbers are
-+really just one ulp off, and should be considered equal.
- @end deftypefun
-
- @deftypefun void mpf_reldiff (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2})
-diff -durN gmp-4.2.4.orig/mpf/eq.c gmp-4.2.4/mpf/eq.c
---- gmp-4.2.4.orig/mpf/eq.c 2007-08-30 20:31:40.000000000 +0200
-+++ gmp-4.2.4/mpf/eq.c 2009-03-08 18:36:16.000000000 +0100
-@@ -1,6 +1,6 @@
- /* mpf_eq -- Compare two floats up to a specified bit #.
-
--Copyright 1993, 1995, 1996, 2001, 2002 Free Software Foundation, Inc.
-+Copyright 1993, 1995, 1996, 2001, 2002, 2008 Free Software Foundation, Inc.
-
- This file is part of the GNU MP Library.
-
-@@ -19,6 +19,7 @@
-
- #include "gmp.h"
- #include "gmp-impl.h"
-+#include "longlong.h"
-
- int
- mpf_eq (mpf_srcptr u, mpf_srcptr v, unsigned long int n_bits)
-@@ -26,6 +27,8 @@
- mp_srcptr up, vp;
- mp_size_t usize, vsize, size, i;
- mp_exp_t uexp, vexp;
-+ mp_limb_t diff;
-+ int cnt;
-
- uexp = u->_mp_exp;
- vexp = v->_mp_exp;
-@@ -53,10 +56,8 @@
- /* U and V have the same sign and are both non-zero. */
-
- /* 2. Are the exponents different? */
-- if (uexp > vexp)
-- return 0; /* ??? handle (uexp = vexp + 1) */
-- if (vexp > uexp)
-- return 0; /* ??? handle (vexp = uexp + 1) */
-+ if (uexp != vexp)
-+ return 0;
-
- usize = ABS (usize);
- vsize = ABS (vsize);
-@@ -93,17 +94,26 @@
- size = usize;
- }
-
-- if (size > (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)
-- size = (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
-+ up += usize; /* point just above most significant limb */
-+ vp += vsize; /* point just above most significant limb */
-
-- up += usize - size;
-- vp += vsize - size;
-+ count_leading_zeros (cnt, up[-1]);
-+ if ((vp[-1] >> (GMP_LIMB_BITS - 1 - cnt)) != 1)
-+ return 0; /* msb positions different */
-
-- for (i = size - 1; i >= 0; i--)
-+ n_bits += cnt - GMP_NAIL_BITS;
-+
-+ size = MIN (size, (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS);
-+
-+ up -= size; /* point at least significant relevant limb */
-+ vp -= size; /* point at least significant relevant limb */
-+
-+ for (i = size - 1; i > 0; i--)
- {
- if (up[i] != vp[i])
- return 0;
- }
-
-- return 1;
-+ diff = (up[0] ^ vp[0]) >> GMP_NUMB_BITS - 1 - (n_bits - 1) % GMP_NUMB_BITS;
-+ return diff == 0;
- }
-diff -durN gmp-4.2.4.orig/tests/cxx/t-prec.cc gmp-4.2.4/tests/cxx/t-prec.cc
---- gmp-4.2.4.orig/tests/cxx/t-prec.cc 2007-09-01 12:09:03.000000000 +0200
-+++ gmp-4.2.4/tests/cxx/t-prec.cc 2009-03-08 18:36:16.000000000 +0100
-@@ -1,6 +1,6 @@
- /* Test precision of mpf_class expressions.
-
--Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
-+Copyright 2001, 2002, 2003, 2008 Free Software Foundation, Inc.
-
- This file is part of the GNU MP Library.
-
-@@ -61,7 +61,7 @@
- g = 1 / f;
- ASSERT_ALWAYS_PREC
- (g, "0.11111 11111 11111 11111 11111 11111 11111 11111 11111 11111"
-- " 11111 11111 11111 11111 11111 11", very_large_prec);
-+ " 11111 11111 11111 11111 11111 111", very_large_prec);
- }
- {
- mpf_class f(15.0, large_prec);
-@@ -69,7 +69,7 @@
- g = 1 / f;
- ASSERT_ALWAYS_PREC
- (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666"
-- " 66666 66666 66666 66666 66666 67", very_large_prec);
-+ " 66666 66666 66666 66666 66666 667", very_large_prec);
- }
-
- // compound expressions
-@@ -94,14 +94,14 @@
- i = f / g + h;
- ASSERT_ALWAYS_PREC
- (i, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333"
-- " 33333 33333 33333 333", very_large_prec);
-+ " 33333 33333 33333 33333 33333 3", very_large_prec);
- }
- {
- mpf_class f(3.0, small_prec);
- mpf_class g(-(1 + f) / 3, very_large_prec);
- ASSERT_ALWAYS_PREC
- (g, "-1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333"
-- " 33333 33333 33333 333", very_large_prec);
-+ " 33333 33333 33333 33333 33333 33", very_large_prec);
- }
- {
- mpf_class f(9.0, medium_prec);
-@@ -117,7 +117,7 @@
- g = hypot(1 + 5 / f, 1.0);
- ASSERT_ALWAYS_PREC
- (g, "1.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666"
-- " 66666 66666 66666 667", very_large_prec);
-+ " 66666 66666 66666 66666 66666 67", very_large_prec);
- }
-
- // compound assignments
-@@ -142,7 +142,7 @@
- mpf_class g(0.0, very_large_prec);
- g = mpf_class(1 / f);
- ASSERT_ALWAYS_PREC
-- (g, "0.11111 11111 11111 11111 11111 11111 11111 111", medium_prec);
-+ (g, "0.11111 11111 11111 11111 11111 11111 11111 1111", medium_prec);
- }
- {
- mpf_class f(15.0, large_prec);
-@@ -150,7 +150,7 @@
- g = mpf_class(1 / f);
- ASSERT_ALWAYS_PREC
- (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666"
-- " 66666 667", large_prec);
-+ " 66666 6667", large_prec);
- }
-
- {
-@@ -158,7 +158,8 @@
- mpf_class h(0.0, very_large_prec);
- h = mpf_class(f / g + 1, large_prec);
- ASSERT_ALWAYS_PREC
-- (h, "1.33333 33333 33333 33333 33333 33333 33333 33333 33333 3333",
-+ (h, "1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333"
-+ " 33333 333",
- large_prec);
- }
-
-@@ -170,7 +171,7 @@
- g = f - q;
- ASSERT_ALWAYS_PREC
- (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666"
-- " 66666 66666 66666 667", very_large_prec);
-+ " 66666 66666 66666 66666 66666 67", very_large_prec);
- }
-
- {
-@@ -179,7 +180,8 @@
- mpf_class g(0.0, very_large_prec);
- g = mpf_class(f - q, large_prec);
- ASSERT_ALWAYS_PREC
-- (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 6667",
-+ (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666"
-+ " 66666 667",
- large_prec);
- }
- {
-@@ -188,7 +190,7 @@
- mpf_class g(0.0, very_large_prec);
- g = mpf_class(f - q);
- ASSERT_ALWAYS_PREC
-- (g, "2.66666 66666 66666 66666 66666 6667", medium_prec);
-+ (g, "2.66666 66666 66666 66666 66666 66666 66666 667", medium_prec);
- }
- {
- mpf_class f(15.0, large_prec);
-@@ -196,7 +198,8 @@
- mpf_class g(0.0, very_large_prec);
- g = mpf_class(f + q);
- ASSERT_ALWAYS_PREC
-- (g, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 3333",
-+ (g, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333"
-+ " 33333 33",
- large_prec);
- }
- }
diff --git a/patches/gmp/4.2.4/110-mpf_set_str.patch b/patches/gmp/4.2.4/110-mpf_set_str.patch
deleted file mode 100644
index 9cb600b..0000000
--- a/patches/gmp/4.2.4/110-mpf_set_str.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-Original patch from: mpf_set_str.c.4.diff
-
--= BEGIN original header =-
--= END original header =-
-
-diff -durN gmp-4.2.4.orig/mpf/set_str.c gmp-4.2.4/mpf/set_str.c
---- gmp-4.2.4.orig/mpf/set_str.c 2008-08-25 16:11:37.000000000 +0200
-+++ gmp-4.2.4/mpf/set_str.c 2009-03-08 18:36:16.000000000 +0100
-@@ -137,7 +137,12 @@
- c = (unsigned char) *++str;
- }
-
-+ /* Default base to decimal. */
-+ if (base == 0)
-+ base = 10;
-+
- exp_base = base;
-+
- if (base < 0)
- {
- exp_base = 10;
-@@ -165,10 +170,6 @@
- return -1;
- }
-
-- /* Default base to decimal. */
-- if (base == 0)
-- base = 10;
--
- /* Locate exponent part of the input. Look from the right of the string,
- since the exponent is usually a lot shorter than the mantissa. */
- expptr = NULL;
diff --git a/patches/gmp/4.2.4/120-perfpow.patch b/patches/gmp/4.2.4/120-perfpow.patch
deleted file mode 100644
index f062b22..0000000
--- a/patches/gmp/4.2.4/120-perfpow.patch
+++ /dev/null
@@ -1,149 +0,0 @@
-Original patch from: perfpow.c.diff
-
--= BEGIN original header =-
-Copyright 1998, 1999, 2000, 2001, 2005, 2008 Free Software Foundation, Inc.
-
-This file is part of the GNU MP Library.
-
-The GNU MP Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-The GNU MP Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
-
--= END original header =-
-
-diff -durN gmp-4.2.4.orig/mpz/perfpow.c gmp-4.2.4/mpz/perfpow.c
---- gmp-4.2.4.orig/mpz/perfpow.c 2007-08-30 20:31:41.000000000 +0200
-+++ gmp-4.2.4/mpz/perfpow.c 2009-03-08 18:36:16.000000000 +0100
-@@ -1,7 +1,7 @@
- /* mpz_perfect_power_p(arg) -- Return non-zero if ARG is a perfect power,
- zero otherwise.
-
--Copyright 1998, 1999, 2000, 2001, 2005 Free Software Foundation, Inc.
-+Copyright 1998, 1999, 2000, 2001, 2005, 2008 Free Software Foundation, Inc.
-
- This file is part of the GNU MP Library.
-
-@@ -59,6 +59,8 @@
- #define SMALLEST_OMITTED_PRIME 1009
-
-
-+#define POW2P(a) (((a) & ((a) - 1)) == 0)
-+
- int
- mpz_perfect_power_p (mpz_srcptr u)
- {
-@@ -72,16 +74,13 @@
- mp_size_t usize = SIZ (u);
- TMP_DECL;
-
-- if (usize == 0)
-- return 1; /* consider 0 a perfect power */
-+ if (mpz_cmpabs_ui (u, 1) <= 0)
-+ return 1; /* -1, 0, and +1 are perfect powers */
-
- n2 = mpz_scan1 (u, 0);
- if (n2 == 1)
- return 0; /* 2 divides exactly once. */
-
-- if (n2 != 0 && (n2 & 1) == 0 && usize < 0)
-- return 0; /* 2 has even multiplicity with negative U */
--
- TMP_MARK;
-
- uns = ABS (usize) - n2 / BITS_PER_MP_LIMB;
-@@ -89,6 +88,14 @@
- MPZ_TMP_INIT (u2, uns);
-
- mpz_tdiv_q_2exp (u2, u, n2);
-+ mpz_abs (u2, u2);
-+
-+ if (mpz_cmp_ui (u2, 1) == 0)
-+ {
-+ TMP_FREE;
-+ /* factoring completed; consistent power */
-+ return ! (usize < 0 && POW2P(n2));
-+ }
-
- if (isprime (n2))
- goto n2prime;
-@@ -97,6 +104,9 @@
- {
- prime = primes[i];
-
-+ if (mpz_cmp_ui (u2, prime) < 0)
-+ break;
-+
- if (mpz_divisible_ui_p (u2, prime)) /* divisible by this prime? */
- {
- rem = mpz_tdiv_q_ui (q, u2, prime * prime);
-@@ -115,12 +125,6 @@
- n++;
- }
-
-- if ((n & 1) == 0 && usize < 0)
-- {
-- TMP_FREE;
-- return 0; /* even multiplicity with negative U, reject */
-- }
--
- n2 = gcd (n2, n);
- if (n2 == 1)
- {
-@@ -128,10 +132,11 @@
- return 0; /* we have multiplicity 1 of some factor */
- }
-
-- if (mpz_cmpabs_ui (u2, 1) == 0)
-+ if (mpz_cmp_ui (u2, 1) == 0)
- {
- TMP_FREE;
-- return 1; /* factoring completed; consistent power */
-+ /* factoring completed; consistent power */
-+ return ! (usize < 0 && POW2P(n2));
- }
-
- /* As soon as n2 becomes a prime number, stop factoring.
-@@ -169,6 +174,10 @@
- else
- {
- unsigned long int nth;
-+
-+ if (usize < 0 && POW2P(n2))
-+ return 0;
-+
- /* We found some factors above. We just need to consider values of n
- that divides n2. */
- for (nth = 2; nth <= n2; nth++)
-@@ -184,8 +193,11 @@
- exact = mpz_root (q, u2, nth);
- if (exact)
- {
-- TMP_FREE;
-- return 1;
-+ if (! (usize < 0 && POW2P(nth)))
-+ {
-+ TMP_FREE;
-+ return 1;
-+ }
- }
- if (mpz_cmp_ui (q, SMALLEST_OMITTED_PRIME) < 0)
- {
-@@ -199,6 +211,9 @@
- }
-
- n2prime:
-+ if (usize < 0 && POW2P(n2))
-+ return 0;
-+
- exact = mpz_root (NULL, u2, n2);
- TMP_FREE;
- return exact;
diff --git a/patches/gmp/4.3.0/100-multiplicity-that-does-not-fit-an-int.patch b/patches/gmp/4.3.0/100-multiplicity-that-does-not-fit-an-int.patch
new file mode 100644
index 0000000..f60e88f
--- /dev/null
+++ b/patches/gmp/4.3.0/100-multiplicity-that-does-not-fit-an-int.patch
@@ -0,0 +1,33 @@
+diff --git a/mpz/remove.c b/mpz/remove.c
+--- a/mpz/remove.c
++++ b/mpz/remove.c
+@@ -23,7 +23,7 @@
+ unsigned long int
+ mpz_remove (mpz_ptr dest, mpz_srcptr src, mpz_srcptr f)
+ {
+- mpz_t fpow[40]; /* inexhaustible...until year 2020 or so */
++ mpz_t fpow[GMP_LIMB_BITS]; /* Really MP_SIZE_T_BITS */
+ mpz_t x, rem;
+ unsigned long int pwr;
+ int p;
+@@ -69,7 +69,7 @@
+ mpz_set (dest, x);
+ }
+
+- pwr = (1 << p) - 1;
++ pwr = (1L << p) - 1;
+
+ mpz_clear (fpow[p]);
+
+diff --git a/mpz/remove.c b/mpz/remove.c
+--- a/mpz/remove.c
++++ b/mpz/remove.c
+@@ -80,7 +80,7 @@
+ mpz_tdiv_qr (x, rem, dest, fpow[p]);
+ if (SIZ (rem) == 0)
+ {
+- pwr += 1 << p;
++ pwr += 1L << p;
+ mpz_set (dest, x);
+ }
+ mpz_clear (fpow[p]);
diff --git a/patches/gmp/4.3.0/110-unbounded-alloc.patch b/patches/gmp/4.3.0/110-unbounded-alloc.patch
new file mode 100644
index 0000000..78e0588
--- /dev/null
+++ b/patches/gmp/4.3.0/110-unbounded-alloc.patch
@@ -0,0 +1,31 @@
+diff --git a/mpn/generic/toom44_mul.c b/mpn/generic/toom44_mul.c
+--- a/mpn/generic/toom44_mul.c
++++ b/mpn/generic/toom44_mul.c
+@@ -116,17 +116,16 @@
+
+ TMP_MARK;
+
+- as1 = TMP_SALLOC_LIMBS (n + 1);
+- asm1 = TMP_SALLOC_LIMBS (n + 1);
+- as2 = TMP_SALLOC_LIMBS (n + 1);
+- ash = TMP_SALLOC_LIMBS (n + 1);
+- asmh = TMP_SALLOC_LIMBS (n + 1);
+-
+- bs1 = TMP_SALLOC_LIMBS (n + 1);
+- bsm1 = TMP_SALLOC_LIMBS (n + 1);
+- bs2 = TMP_SALLOC_LIMBS (n + 1);
+- bsh = TMP_SALLOC_LIMBS (n + 1);
+- bsmh = TMP_SALLOC_LIMBS (n + 1);
++ as1 = TMP_ALLOC_LIMBS (10 * n + 10);
++ asm1 = as1 + n + 1;
++ as2 = asm1 + n + 1;
++ ash = as2 + n + 1;
++ asmh = ash + n + 1;
++ bs1 = asmh + n + 1;
++ bsm1 = bs1 + n + 1;
++ bs2 = bsm1 + n + 1;
++ bsh = bs2 + n + 1;
++ bsmh = bsh + n + 1;
+
+ gp = pp;
+ hp = pp + n + 1;
diff --git a/patches/gmp/5.0.1/110-get-mpn_sub_1-size-argument-right.patch b/patches/gmp/5.0.1/110-get-mpn_sub_1-size-argument-right.patch
new file mode 100644
index 0000000..2e0a1af
--- /dev/null
+++ b/patches/gmp/5.0.1/110-get-mpn_sub_1-size-argument-right.patch
@@ -0,0 +1,38 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1310730221 -7200
+# Node ID 538dfce27f410b910d5e2f011119269e224d16a3
+# Parent 03ed209dd7efd4f4fff0ce297bb3a8f7e7ba2366
+(mpn_dcpi1_bdiv_q): Get mpn_sub_1 size argument right.
+
+diff -r 03ed209dd7ef -r 538dfce27f41 mpn/generic/dcpi1_bdiv_q.c
+--- a/mpn/generic/dcpi1_bdiv_q.c Thu Jun 16 12:22:24 2011 +0200
++++ b/mpn/generic/dcpi1_bdiv_q.c Fri Jul 15 13:43:41 2011 +0200
+@@ -7,7 +7,7 @@
+ SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
+ GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
+
+-Copyright 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
++Copyright 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+ This file is part of the GNU MP Library.
+
+@@ -28,7 +28,6 @@
+ #include "gmp-impl.h"
+
+
+-
+ mp_size_t
+ mpn_dcpi1_bdiv_q_n_itch (mp_size_t n)
+ {
+@@ -130,7 +129,7 @@
+ qn = nn - qn;
+ while (qn > dn)
+ {
+- mpn_sub_1 (np + dn, np + dn, qn, cy);
++ mpn_sub_1 (np + dn, np + dn, qn - dn, cy);
+ cy = mpn_dcpi1_bdiv_qr_n (qp, np, dp, dn, dinv, tp);
+ qp += dn;
+ np += dn;
+
diff --git a/patches/gmp/5.0.1/120-fix-r0-clobbering-issue.patch b/patches/gmp/5.0.1/120-fix-r0-clobbering-issue.patch
new file mode 100644
index 0000000..d12d6b2
--- /dev/null
+++ b/patches/gmp/5.0.1/120-fix-r0-clobbering-issue.patch
@@ -0,0 +1,77 @@
+Removed ChangeLog part
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1342891151 -7200
+# Node ID 829215e83ff1db3cd00e510a737092df691442d5
+# Parent 816c18dbd492050ef8892e91602d9e758abc2988
+Fix r0 clobbering issue with "large" code affecting elf+darwin PIC.
+
+diff -r 816c18dbd492 -r 829215e83ff1 mpn/powerpc32/vmx/mod_34lsub1.asm
+--- a/mpn/powerpc32/vmx/mod_34lsub1.asm Tue Jun 19 15:02:48 2012 +0200
++++ b/mpn/powerpc32/vmx/mod_34lsub1.asm Sat Jul 21 19:19:11 2012 +0200
+@@ -1,6 +1,7 @@
+ dnl PowerPC-32 mpn_mod_34lsub1 -- mpn remainder mod 2^24-1.
+
+-dnl Copyright 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
++dnl Copyright 2002, 2003, 2005, 2006, 2007, 2012 Free Software Foundation,
++dnl Inc.
+
+ dnl This file is part of the GNU MP Library.
+
+@@ -135,15 +136,15 @@
+
+ andi. r7, up, 15
+ vxor a0, v0, v0
+- lis r0, 0xaaaa
++ lis r9, 0xaaaa
+ vxor a1, v0, v0
+- ori r0, r0, 0xaaab
++ ori r9, r9, 0xaaab
+ vxor a2, v0, v0
+ li r5, 16
+ vxor c0, v0, v0
+ li r6, 32
+ vxor c1, v0, v0
+- LEAL( r11, cnsts)
++ LEAL( r11, cnsts) C CAUTION clobbers r0 for elf, darwin
+ vxor c2, v0, v0
+ vxor z, v0, v0
+
+@@ -158,7 +159,7 @@
+ vsldoi a2, z, a2, 12
+
+ addi n, n, 9
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+@@ -174,7 +175,7 @@
+ vsldoi a1, z, a1, 8
+
+ addi n, n, 6
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+@@ -188,7 +189,7 @@
+ vsldoi a0, z, a0, 4
+
+ addi n, n, 3
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+@@ -197,7 +198,7 @@
+ b L(0)
+
+ L(aligned16):
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+
diff --git a/patches/gmp/5.0.2/110-get-mpn_sub_1-size-argument-right.patch b/patches/gmp/5.0.2/110-get-mpn_sub_1-size-argument-right.patch
new file mode 100644
index 0000000..2e0a1af
--- /dev/null
+++ b/patches/gmp/5.0.2/110-get-mpn_sub_1-size-argument-right.patch
@@ -0,0 +1,38 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1310730221 -7200
+# Node ID 538dfce27f410b910d5e2f011119269e224d16a3
+# Parent 03ed209dd7efd4f4fff0ce297bb3a8f7e7ba2366
+(mpn_dcpi1_bdiv_q): Get mpn_sub_1 size argument right.
+
+diff -r 03ed209dd7ef -r 538dfce27f41 mpn/generic/dcpi1_bdiv_q.c
+--- a/mpn/generic/dcpi1_bdiv_q.c Thu Jun 16 12:22:24 2011 +0200
++++ b/mpn/generic/dcpi1_bdiv_q.c Fri Jul 15 13:43:41 2011 +0200
+@@ -7,7 +7,7 @@
+ SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
+ GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GMP RELEASE.
+
+-Copyright 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
++Copyright 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+
+ This file is part of the GNU MP Library.
+
+@@ -28,7 +28,6 @@
+ #include "gmp-impl.h"
+
+
+-
+ mp_size_t
+ mpn_dcpi1_bdiv_q_n_itch (mp_size_t n)
+ {
+@@ -130,7 +129,7 @@
+ qn = nn - qn;
+ while (qn > dn)
+ {
+- mpn_sub_1 (np + dn, np + dn, qn, cy);
++ mpn_sub_1 (np + dn, np + dn, qn - dn, cy);
+ cy = mpn_dcpi1_bdiv_qr_n (qp, np, dp, dn, dinv, tp);
+ qp += dn;
+ np += dn;
+
diff --git a/patches/gmp/5.0.2/120-fix-r0-clobbering-issue.patch b/patches/gmp/5.0.2/120-fix-r0-clobbering-issue.patch
new file mode 100644
index 0000000..d12d6b2
--- /dev/null
+++ b/patches/gmp/5.0.2/120-fix-r0-clobbering-issue.patch
@@ -0,0 +1,77 @@
+Removed ChangeLog part
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1342891151 -7200
+# Node ID 829215e83ff1db3cd00e510a737092df691442d5
+# Parent 816c18dbd492050ef8892e91602d9e758abc2988
+Fix r0 clobbering issue with "large" code affecting elf+darwin PIC.
+
+diff -r 816c18dbd492 -r 829215e83ff1 mpn/powerpc32/vmx/mod_34lsub1.asm
+--- a/mpn/powerpc32/vmx/mod_34lsub1.asm Tue Jun 19 15:02:48 2012 +0200
++++ b/mpn/powerpc32/vmx/mod_34lsub1.asm Sat Jul 21 19:19:11 2012 +0200
+@@ -1,6 +1,7 @@
+ dnl PowerPC-32 mpn_mod_34lsub1 -- mpn remainder mod 2^24-1.
+
+-dnl Copyright 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
++dnl Copyright 2002, 2003, 2005, 2006, 2007, 2012 Free Software Foundation,
++dnl Inc.
+
+ dnl This file is part of the GNU MP Library.
+
+@@ -135,15 +136,15 @@
+
+ andi. r7, up, 15
+ vxor a0, v0, v0
+- lis r0, 0xaaaa
++ lis r9, 0xaaaa
+ vxor a1, v0, v0
+- ori r0, r0, 0xaaab
++ ori r9, r9, 0xaaab
+ vxor a2, v0, v0
+ li r5, 16
+ vxor c0, v0, v0
+ li r6, 32
+ vxor c1, v0, v0
+- LEAL( r11, cnsts)
++ LEAL( r11, cnsts) C CAUTION clobbers r0 for elf, darwin
+ vxor c2, v0, v0
+ vxor z, v0, v0
+
+@@ -158,7 +159,7 @@
+ vsldoi a2, z, a2, 12
+
+ addi n, n, 9
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+@@ -174,7 +175,7 @@
+ vsldoi a1, z, a1, 8
+
+ addi n, n, 6
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+@@ -188,7 +189,7 @@
+ vsldoi a0, z, a0, 4
+
+ addi n, n, 3
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+@@ -197,7 +198,7 @@
+ b L(0)
+
+ L(aligned16):
+- mulhwu r0, n, r0
++ mulhwu r0, n, r9
+ srwi r0, r0, 3 C r0 = floor(n/12)
+ mtctr r0
+
+
diff --git a/patches/gmp/5.1.1/100-fix-bulldozer-piledriver.patch b/patches/gmp/5.1.1/100-fix-bulldozer-piledriver.patch
new file mode 100644
index 0000000..f6faca1
--- /dev/null
+++ b/patches/gmp/5.1.1/100-fix-bulldozer-piledriver.patch
@@ -0,0 +1,21 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1368052461 -7200
+# Node ID 11fbd825bc45385d00b69c30bd7566acee11f0d2
+# Parent bd4c950486ab4c161ea69b91c25150719c3cb700
+Fix typo.
+
+diff -r bd4c950486ab -r 11fbd825bc45 mpn/x86_64/bd1/mul_1.asm
+--- a/mpn/x86_64/bd1/mul_1.asm Thu May 02 18:20:37 2013 +0200
++++ b/mpn/x86_64/bd1/mul_1.asm Thu May 09 00:34:21 2013 +0200
+@@ -53,7 +53,7 @@
+ IFDOS(` define(`v0', ``%r9'') ') dnl
+ IFDOS(` define(`r9', ``rdi'') ') dnl
+ IFDOS(` define(`n', ``%r8'') ') dnl
+-IFDOS(` define(`r8', ``r11'') ') dnl
++IFDOS(` define(`r8', ``rbx'') ') dnl
+
+ ASM_START()
+ TEXT
+
diff --git a/patches/gmp/5.1.1/110-mpz_powm_ui.patch b/patches/gmp/5.1.1/110-mpz_powm_ui.patch
new file mode 100644
index 0000000..f0d240c
--- /dev/null
+++ b/patches/gmp/5.1.1/110-mpz_powm_ui.patch
@@ -0,0 +1,39 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1363174284 -3600
+# Node ID ec4d88674036804b26f22c6a2bfca6ae1e92d370
+# Parent e616ff715c34e112d0a5f7535d31ffe1194a5c7d
+(mod): Adhere to mpn_mu_div_qr's overlap requirements.
+
+diff -r e616ff715c34 -r ec4d88674036 mpz/powm_ui.c
+--- a/mpz/powm_ui.c Sun Feb 17 19:40:16 2013 +0100
++++ b/mpz/powm_ui.c Wed Mar 13 12:31:24 2013 +0100
+@@ -2,8 +2,8 @@
+
+ Contributed to the GNU project by Torbjorn Granlund.
+
+-Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2005, 2008,
+-2009, 2011, 2012 Free Software Foundation, Inc.
++Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001, 2002, 2005, 2008, 2009,
++2011, 2012, 2013 Free Software Foundation, Inc.
+
+ This file is part of the GNU MP Library.
+
+@@ -70,9 +70,14 @@
+ }
+ else
+ {
++ /* We need to allocate separate remainder area, since mpn_mu_div_qr does
++ not handle overlap between the numerator and remainder areas.
++ FIXME: Make it handle such overlap. */
++ mp_ptr rp = TMP_ALLOC_LIMBS (dn);
+ mp_size_t itch = mpn_mu_div_qr_itch (nn, dn, 0);
+ mp_ptr scratch = TMP_ALLOC_LIMBS (itch);
+- mpn_mu_div_qr (qp, np, np, nn, dp, dn, scratch);
++ mpn_mu_div_qr (qp, rp, np, nn, dp, dn, scratch);
++ MPN_COPY (np, rp, dn);
+ }
+
+ TMP_FREE;
+
diff --git a/patches/gmp/5.1.1/120-fix-mpn_sbpi1_div_qr_sec.patch b/patches/gmp/5.1.1/120-fix-mpn_sbpi1_div_qr_sec.patch
new file mode 100644
index 0000000..13a50ad
--- /dev/null
+++ b/patches/gmp/5.1.1/120-fix-mpn_sbpi1_div_qr_sec.patch
@@ -0,0 +1,164 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1373624469 -7200
+# Node ID a447c0c537891ed23edf180594a89616364ee633
+# Parent 6540e0b2925ead29f7158bb182e4fabfb9441433
+Partial rewrite.
+
+diff -r 6540e0b2925e -r a447c0c53789 mpn/generic/sbpi1_div_sec.c
+--- a/mpn/generic/sbpi1_div_sec.c Mon Jul 01 19:16:32 2013 +0200
++++ b/mpn/generic/sbpi1_div_sec.c Fri Jul 12 12:21:09 2013 +0200
+@@ -8,7 +8,7 @@
+ SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
+ GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
+
+-Copyright 2011, 2012 Free Software Foundation, Inc.
++Copyright 2011, 2012, 2013 Free Software Foundation, Inc.
+
+ This file is part of the GNU MP Library.
+
+@@ -29,6 +29,28 @@
+ #include "gmp-impl.h"
+ #include "longlong.h"
+
++/* This side-channel silent division algorithm reduces the partial remainder by
++ GMP_NUMB_BITS/2 bits at a time, compared to GMP_NUMB_BITS for the main
++ division algorithm. We do not insists on reducing by exactly
++ GMP_NUMB_BITS/2, but may leave a partial remainder that is D*B^i to 3D*B^i
++ too large (B is the limb base, D is the divisor, and i is the induction
++ variable); the subsequent step will handle the extra partial remainder bits.
++
++ WIth that partial remainder reduction, each step generates a quotient "half
++ limb". The outer loop generates two quotient half limbs, an upper (q1h) and
++ a lower (q0h) which are stored sparsely in separate limb arrays. These
++ arrays are added at the end; using separate arrays avoids data-dependent
++ carry propagation which could else pose a side-channel leakage problem.
++
++ The quotient half limbs may be between -3 to 0 from the accurate value
++ ("accurate" being the one which corresponds to a reduction to a principal
++ partial remainder). Too small quotient half limbs correspond to too large
++ remainders, which we reduce later, as described above.
++
++ In order to keep quotients from getting too big, corresponding to a negative
++ partial remainder, we use an inverse which is sligtly smaller than usually.
++*/
++
+ #if OPERATION_sbpi1_div_qr_sec
+ /* Needs (dn + 1) + (nn - dn) + (nn - dn) = 2nn - dn + 1 limbs at tp. */
+ #define FNAME mpn_sbpi1_div_qr_sec
+@@ -49,7 +71,7 @@
+ mp_limb_t dinv,
+ mp_ptr tp)
+ {
+- mp_limb_t nh, cy, q1h, q0h, dummy, h;
++ mp_limb_t nh, cy, q1h, q0h, dummy, cnd;
+ mp_size_t i;
+ mp_ptr hp;
+ #if OPERATION_sbpi1_div_qr_sec
+@@ -72,77 +94,69 @@
+ #endif
+ }
+
++ /* Decremenet inverse to keep quotient half limbs from being too large. */
++ dinv -= dinv != 0; /* FIXME: cmp-to-int */
++
+ /* Create a divisor copy shifted half a limb. */
+ hp = tp; /* (dn + 1) limbs */
+- cy = mpn_lshift (hp, dp, dn, GMP_NUMB_BITS / 2);
+- hp[dn] = dp[dn - 1] >> GMP_NUMB_BITS / 2;
++ hp[dn] = mpn_lshift (hp, dp, dn, GMP_NUMB_BITS / 2);
+
+ #if OPERATION_sbpi1_div_qr_sec
+ qlp = tp + (dn + 1); /* (nn - dn) limbs */
+ qhp = tp + (nn + 1); /* (nn - dn) limbs */
+ #endif
+
+- np += nn;
++ np += nn - dn;
++ nh = 0;
+
+- /* Main loop. Develop one full limb per iteration, but do it in two steps in
+- order to avoid conditionals. Quotient bits will be either correct or
+- underestimates. When a quotient is underestimated, the next quotient will
+- compensate, since quotients are to be added at consecutive weight distance
+- GMP_NUMB_BITS/2. We make two quotient arrays, each with GMP_NUMB_BITS/2+2
+- bits per entry. The arrays are added late after the loop. Separate
+- arrays avoid data-dependent carry propagation. */
+- nh = 0;
+ for (i = nn - dn - 1; i >= 0; i--)
+ {
+ np--;
+
+- nh = (nh << GMP_NUMB_BITS/2) + (np[0] >> GMP_NUMB_BITS/2);
++ nh = (nh << GMP_NUMB_BITS/2) + (np[dn] >> GMP_NUMB_BITS/2);
+ umul_ppmm (q1h, dummy, nh, dinv);
+ q1h += nh;
+ #if OPERATION_sbpi1_div_qr_sec
+ qhp[i] = q1h;
+ #endif
+- cy = mpn_submul_1 (np - dn, hp, dn + 1, q1h);
++ mpn_submul_1 (np, hp, dn + 1, q1h);
+
+- nh = np[0];
++ nh = np[dn];
+ umul_ppmm (q0h, dummy, nh, dinv);
+ q0h += nh;
+ #if OPERATION_sbpi1_div_qr_sec
+ qlp[i] = q0h;
+ #endif
+- cy = mpn_submul_1 (np - dn, dp, dn, q0h);
+-
+- nh -= cy;
++ nh -= mpn_submul_1 (np, dp, dn, q0h);
+ }
+
+- np[0] = nh;
+-
+- np -= dn;
+-
+ /* 1st adjustment depends on extra high remainder limb. */
+- h = np[dn];
++ cnd = nh != 0; /* FIXME: cmp-to-int */
+ #if OPERATION_sbpi1_div_qr_sec
+- qlp[0] += h;
++ qlp[0] += cnd;
+ #endif
+- h -= mpn_subcnd_n (np, np, dp, dn, h);
++ nh -= mpn_subcnd_n (np, np, dp, dn, cnd);
+
+- /* 2nd adjustment depends on remainder/divisor comparision as well as whether
++ /* 2nd adjustment depends on remainder/divisor comparison as well as whether
+ extra remainder limb was nullified by previous subtract. */
+ cy = mpn_sub_n (np, np, dp, dn);
+- cy = cy == h; /* FIXME: might leak on some archs */
++ cy = cy - nh;
+ #if OPERATION_sbpi1_div_qr_sec
+- qlp[0] += cy;
++ qlp[0] += 1 - cy;
+ #endif
+- mpn_addcnd_n (np, np, dp, dn, 1 - cy);
++ mpn_addcnd_n (np, np, dp, dn, cy);
+
++ /* 3rd adjustment depends on remainder/divisor comparison. */
++ cy = mpn_sub_n (np, np, dp, dn);
++#if OPERATION_sbpi1_div_qr_sec
++ qlp[0] += 1 - cy;
++#endif
++ mpn_addcnd_n (np, np, dp, dn, cy);
++
++#if OPERATION_sbpi1_div_qr_sec
+ /* Combine quotient halves into final quotient. */
+-#if OPERATION_sbpi1_div_qr_sec
+- qh = 0;
+- if (nn - dn != 0)
+- {
+- qh = mpn_lshift (qhp, qhp, nn - dn, GMP_NUMB_BITS/2);
+- qh += mpn_add_n (qp, qhp, qlp, nn - dn);
+- }
++ qh = mpn_lshift (qhp, qhp, nn - dn, GMP_NUMB_BITS/2);
++ qh += mpn_add_n (qp, qhp, qlp, nn - dn);
+
+ return qh;
+ #else
+
diff --git a/patches/gmp/5.1.1/130-do-not-clobber-f16-f18.patch b/patches/gmp/5.1.1/130-do-not-clobber-f16-f18.patch
new file mode 100644
index 0000000..9f9f470
--- /dev/null
+++ b/patches/gmp/5.1.1/130-do-not-clobber-f16-f18.patch
@@ -0,0 +1,73 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <tege@gmplib.org>
+# Date 1369216954 -7200
+# Node ID 394bdf8fdaee749660cc5680cc0636ea0242fae7
+# Parent 0771124b9f13b218a3f07f7dd7c127961974489d
+Don't clobber f16-f18.
+
+diff -r 0771124b9f13 -r 394bdf8fdaee mpn/ia64/divrem_2.asm
+--- a/mpn/ia64/divrem_2.asm Mon May 20 16:56:05 2013 +0200
++++ b/mpn/ia64/divrem_2.asm Wed May 22 12:02:34 2013 +0200
+@@ -1,6 +1,6 @@
+ dnl IA-64 mpn_divrem_2 -- Divide an mpn number by a normalized 2-limb number.
+
+-dnl Copyright 2010 Free Software Foundation, Inc.
++dnl Copyright 2010, 2013 Free Software Foundation, Inc.
+
+ dnl This file is part of the GNU MP Library.
+
+@@ -98,17 +98,17 @@
+ br.call.sptk.many b0 = mpn_invert_limb
+ ;;
+ setf.sig f11 = r8 // di (non-final)
+- setf.sig f18 = r39 // d1
+- setf.sig f17 = r36 // d0
++ setf.sig f34 = r39 // d1
++ setf.sig f33 = r36 // d0
+ mov r1 = r43
+ ;;
+ mov r17 = 1
+ setf.sig f9 = r38 // n2
+- xma.l f6 = f11, f18, f0 // t0 = LO(di * d1)
++ xma.l f6 = f11, f34, f0 // t0 = LO(di * d1)
+ ;;
+ setf.sig f10 = r37 // n1
+ setf.sig f15 = r17 // 1
+- xma.hu f8 = f11, f17, f0 // s0 = HI(di * d0)
++ xma.hu f8 = f11, f33, f0 // s0 = HI(di * d0)
+ ;;
+ getf.sig r17 = f6
+ getf.sig r16 = f8
+@@ -178,7 +178,7 @@
+ (p9) br.cond.dptk .L52
+ .L46:
+ ')
+- setf.sig f16 = r8 // di
++ setf.sig f32 = r8 // di
+ shladd r32 = r35, 3, r32
+ ;;
+
+@@ -189,8 +189,8 @@
+ ;;
+ (p8) mov r37 = r0
+ (p9) ld8 r37 = [r34], -8
+- xma.hu f8 = f9, f16, f10 // 0,29
+- xma.l f12 = f9, f16, f10 // 0
++ xma.hu f8 = f9, f32, f10 // 0,29
++ xma.l f12 = f9, f32, f10 // 0
+ ;;
+ getf.sig r20 = f12 // q0 4
+ xma.l f13 = f15, f8, f9 // q += n2 4
+@@ -198,8 +198,8 @@
+ ;;
+ getf.sig r18 = f13 // 8
+ xma.l f7 = f14, f13, f10 // 8
+- xma.l f6 = f17, f13, f17 // t0 = LO(d0*q+d0) 8
+- xma.hu f9 = f17, f13, f17 // t1 = HI(d0*q+d0) 9
++ xma.l f6 = f33, f13, f33 // t0 = LO(d0*q+d0) 8
++ xma.hu f9 = f33, f13, f33 // t1 = HI(d0*q+d0) 9
+ ;;
+ getf.sig r38 = f7 // n1 12
+ getf.sig r16 = f6 // 13
+
diff --git a/patches/gmp/6.1.0/100-fix-broadwell-skylake.patch b/patches/gmp/6.1.0/100-fix-broadwell-skylake.patch
new file mode 100644
index 0000000..9afd339
--- /dev/null
+++ b/patches/gmp/6.1.0/100-fix-broadwell-skylake.patch
@@ -0,0 +1,59 @@
+
+# HG changeset patch
+# User Torbjorn Granlund <torbjorng@google.com>
+# Date 1450109109 -3600
+# Node ID 67d4ee9dead1ed8b1c9f4eb320ac72208fe1a015
+# Parent 20bf21d5f600710d62b040ea9b20da22871db1f1
+Add FUNC_EXITs.
+
+diff -r 20bf21d5f600 -r 67d4ee9dead1 NEWS
+--- a/NEWS Mon Dec 14 08:37:18 2015 +0100
++++ b/NEWS Mon Dec 14 17:05:09 2015 +0100
+@@ -4,6 +4,11 @@
+ medium, provided this notice is preserved.
+
+
++Changes between GMP version 6.1.1 and 6.1.0
++
++ BUGS FIXED
++ * .
++
+ Changes between GMP version 6.0.* and 6.1.0
+
+ BUGS FIXED
+diff -r 20bf21d5f600 -r 67d4ee9dead1 mpn/x86_64/coreibwl/mul_basecase.asm
+--- a/mpn/x86_64/coreibwl/mul_basecase.asm Mon Dec 14 08:37:18 2015 +0100
++++ b/mpn/x86_64/coreibwl/mul_basecase.asm Mon Dec 14 17:05:09 2015 +0100
+@@ -94,6 +94,7 @@
+
+ L(s11): mov %rax, (rp)
+ mov %r9, 8(rp)
++ FUNC_EXIT()
+ ret
+
+ L(s2x): cmp $2, vn
+@@ -105,6 +106,7 @@
+ mov %rax, (rp)
+ mov %r9, 8(rp)
+ mov %r10, 16(rp)
++ FUNC_EXIT()
+ ret
+
+ L(s22): add %r8, %r9 C 1
+@@ -121,6 +123,7 @@
+ mov %r9, 8(rp)
+ mov %r10, 16(rp)
+ mov %rdx, 24(rp)
++ FUNC_EXIT()
+ ret
+
+ ALIGN(16)
+@@ -294,6 +297,7 @@
+ pop %r12
+ pop %rbp
+ pop %rbx
++ FUNC_EXIT()
+ ret
+
+ L(f2):
+