summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-libs/mpc/files/mpc-1.0.3-mpfr-4.0.0.patch')
-rw-r--r--dev-libs/mpc/files/mpc-1.0.3-mpfr-4.0.0.patch85
1 files changed, 85 insertions, 0 deletions
diff --git a/dev-libs/mpc/files/mpc-1.0.3-mpfr-4.0.0.patch b/dev-libs/mpc/files/mpc-1.0.3-mpfr-4.0.0.patch
new file mode 100644
index 000000000000..7f9f7e2b9743
--- /dev/null
+++ b/dev-libs/mpc/files/mpc-1.0.3-mpfr-4.0.0.patch
@@ -0,0 +1,85 @@
+https://bugs.gentoo.org/642300
+
+From 36a84f43f326de14db888ba07936cc9621c23f19 Mon Sep 17 00:00:00 2001
+From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
+Date: Sun, 10 Jan 2016 23:19:37 +0100
+Subject: [PATCH] use mpfr_fmma and mpfr_fmms if provided by mpfr
+
+---
+ configure.ac | 16 ++++++++++++++++
+ src/mul.c | 15 ++++++++++++---
+ 2 files changed, 28 insertions(+), 3 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index b6fa199..bdb21ff 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -165,6 +165,22 @@ AC_LINK_IFELSE(
+ AC_MSG_ERROR([libmpfr not found or uses a different ABI (including static vs shared).])
+ ])
+
++AC_MSG_CHECKING(for mpfr_fmma)
++LIBS="-lmpfr $LIBS"
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM(
++ [[#include "mpfr.h"]],
++ [[mpfr_t x; mpfr_fmma (x, x, x, x, x, 0);]]
++ )],
++ [
++ AC_MSG_RESULT(yes)
++ AC_DEFINE(HAVE_MPFR_FMMA, 1, [mpfr_fmma is present])
++ ],
++ [
++ AC_MSG_RESULT(no)
++ AC_DEFINE(HAVE_MPFR_FMMA, 0, [mpfr_fmma is not present])
++ ])
++
+ # Check for a recent GMP
+ # We only guarantee that with a *functional* and recent enough GMP version,
+ # MPC will compile; we do not guarantee that GMP will compile.
+diff --git a/src/mul.c b/src/mul.c
+index 3c9c0a7..8c4afe4 100644
+--- a/src/mul.c
++++ b/src/mul.c
+@@ -175,8 +175,9 @@ mul_imag (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
+ #define MPFR_EXP(x) ((x)->_mpfr_exp)
+ #define MPFR_LIMB_SIZE(x) ((MPFR_PREC (x) - 1) / GMP_NUMB_BITS + 1)
+
++#if HAVE_MPFR_FMMA == 0
+ static int
+-mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
++mpc_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
+ mpfr_srcptr d, int sign, mpfr_rnd_t rnd)
+ {
+ /* Computes z = ab+cd if sign >= 0, or z = ab-cd if sign < 0.
+@@ -359,6 +360,7 @@ mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
+ return inex;
+ }
++#endif
+
+
+ int
+ mpc_mul_naive (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
+@@ -375,10 +377,17 @@ mpc_mul_naive (mpc_ptr z, mpc_srcptr x, mpc_srcptr y, mpc_rnd_t rnd)
+ else
+ rop [0] = z [0];
+
+- inex = MPC_INEX (mpfr_fmma (mpc_realref (rop), mpc_realref (x), mpc_realref (y), mpc_imagref (x),
+- mpc_imagref (y), -1, MPC_RND_RE (rnd)),
++#if HAVE_MPFR_FMMA
++ inex = MPC_INEX (mpfr_fmms (mpc_realref (rop), mpc_realref (x), mpc_realref (y), mpc_imagref (x),
++ mpc_imagref (y), MPC_RND_RE (rnd)),
+ mpfr_fmma (mpc_imagref (rop), mpc_realref (x), mpc_imagref (y), mpc_imagref (x),
++ mpc_realref (y), MPC_RND_IM (rnd)));
++#else
++ inex = MPC_INEX (mpc_fmma (mpc_realref (rop), mpc_realref (x), mpc_realref (y), mpc_imagref (x),
++ mpc_imagref (y), -1, MPC_RND_RE (rnd)),
++ mpc_fmma (mpc_imagref (rop), mpc_realref (x), mpc_imagref (y), mpc_imagref (x),
+ mpc_realref (y), +1, MPC_RND_IM (rnd)));
++#endif
+
+ mpc_set (z, rop, MPC_RNDNN);
+ if (overlap)
+--
+2.15.1
+