arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh731833-libm-2.patch

147e83
From 66bf22e129f0b8621903a8b0489b2684e70fad65 Mon Sep 17 00:00:00 2001
147e83
From: Siddhesh Poyarekar <siddhesh@redhat.com>
147e83
Date: Fri, 8 Mar 2013 11:38:41 +0530
147e83
Subject: [PATCH 17/42] Consolidate copies of mp code in powerpc
147e83
147e83
Retain a single copy of the mp code in power4 instead of the two
147e83
identical copies in powerpc32 and powerpc64.
147e83
(backported from commit 6d9145d817e570cd986bb088cf2af0bf51ac7dde)
147e83
---
147e83
 sysdeps/powerpc/power4/fpu/Makefile           |   5 +
147e83
 sysdeps/powerpc/power4/fpu/mpa.c              | 548 ++++++++++++++++++++++++++
147e83
 sysdeps/powerpc/powerpc32/power4/Implies      |   2 +
147e83
 sysdeps/powerpc/powerpc32/power4/fpu/Makefile |   5 -
147e83
 sysdeps/powerpc/powerpc32/power4/fpu/mpa.c    | 548 --------------------------
147e83
 sysdeps/powerpc/powerpc64/power4/Implies      |   2 +
147e83
 sysdeps/powerpc/powerpc64/power4/fpu/Makefile |   5 -
147e83
 sysdeps/powerpc/powerpc64/power4/fpu/mpa.c    | 548 --------------------------
147e83
 9 files changed, 568 insertions(+), 1106 deletions(-)
147e83
 create mode 100644 sysdeps/powerpc/power4/fpu/Makefile
147e83
 create mode 100644 sysdeps/powerpc/power4/fpu/mpa.c
147e83
 create mode 100644 sysdeps/powerpc/powerpc32/power4/Implies
147e83
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/Makefile
147e83
 delete mode 100644 sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
147e83
 create mode 100644 sysdeps/powerpc/powerpc64/power4/Implies
147e83
 delete mode 100644 sysdeps/powerpc/powerpc64/power4/fpu/Makefile
147e83
 delete mode 100644 sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
147e83
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/power4/fpu/Makefile glibc-2.17-c758a686/sysdeps/powerpc/power4/fpu/Makefile
147e83
new file mode 100644
147e83
index 0000000..f487ed6
147e83
--- /dev/null
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/power4/fpu/Makefile
147e83
@@ -0,0 +1,5 @@
147e83
+# Makefile fragment for POWER4/5/5+ with FPU.
147e83
+
147e83
+ifeq ($(subdir),math)
147e83
+CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
147e83
+endif
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/power4/fpu/mpa.c glibc-2.17-c758a686/sysdeps/powerpc/power4/fpu/mpa.c
147e83
new file mode 100644
147e83
index 0000000..d15680e
147e83
--- /dev/null
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/power4/fpu/mpa.c
147e83
@@ -0,0 +1,548 @@
147e83
+
147e83
+/*
147e83
+ * IBM Accurate Mathematical Library
147e83
+ * written by International Business Machines Corp.
147e83
+ * Copyright (C) 2001, 2006 Free Software Foundation
147e83
+ *
147e83
+ * This program is free software; you can redistribute it and/or modify
147e83
+ * it under the terms of the GNU Lesser General Public License as published by
147e83
+ * the Free Software Foundation; either version 2.1 of the License, or
147e83
+ * (at your option) any later version.
147e83
+ *
147e83
+ * This program is distributed in the hope that it will be useful,
147e83
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147e83
+ * GNU Lesser General Public License for more details.
147e83
+ *
147e83
+ * You should have received a copy of the GNU Lesser General Public License
147e83
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
147e83
+ */
147e83
+/************************************************************************/
147e83
+/*  MODULE_NAME: mpa.c                                                  */
147e83
+/*                                                                      */
147e83
+/*  FUNCTIONS:                                                          */
147e83
+/*               mcr                                                    */
147e83
+/*               acr                                                    */
147e83
+/*               cr                                                     */
147e83
+/*               cpy                                                    */
147e83
+/*               cpymn                                                  */
147e83
+/*               norm                                                   */
147e83
+/*               denorm                                                 */
147e83
+/*               mp_dbl                                                 */
147e83
+/*               dbl_mp                                                 */
147e83
+/*               add_magnitudes                                         */
147e83
+/*               sub_magnitudes                                         */
147e83
+/*               add                                                    */
147e83
+/*               sub                                                    */
147e83
+/*               mul                                                    */
147e83
+/*               inv                                                    */
147e83
+/*               dvd                                                    */
147e83
+/*                                                                      */
147e83
+/* Arithmetic functions for multiple precision numbers.                 */
147e83
+/* Relative errors are bounded                                          */
147e83
+/************************************************************************/
147e83
+
147e83
+
147e83
+#include "endian.h"
147e83
+#include "mpa.h"
147e83
+#include "mpa2.h"
147e83
+#include <sys/param.h>	/* For MIN() */
147e83
+/* mcr() compares the sizes of the mantissas of two multiple precision  */
147e83
+/* numbers. Mantissas are compared regardless of the signs of the       */
147e83
+/* numbers, even if x->d[0] or y->d[0] are zero. Exponents are also     */
147e83
+/* disregarded.                                                         */
147e83
+static int mcr(const mp_no *x, const mp_no *y, int p) {
147e83
+  long i;
147e83
+  long p2 = p;
147e83
+  for (i=1; i<=p2; i++) {
147e83
+    if      (X[i] == Y[i])  continue;
147e83
+    else if (X[i] >  Y[i])  return  1;
147e83
+    else                    return -1; }
147e83
+  return 0;
147e83
+}
147e83
+
147e83
+
147e83
+
147e83
+/* acr() compares the absolute values of two multiple precision numbers */
147e83
+int __acr(const mp_no *x, const mp_no *y, int p) {
147e83
+  long i;
147e83
+
147e83
+  if      (X[0] == ZERO) {
147e83
+    if    (Y[0] == ZERO) i= 0;
147e83
+    else                 i=-1;
147e83
+  }
147e83
+  else if (Y[0] == ZERO) i= 1;
147e83
+  else {
147e83
+    if      (EX >  EY)   i= 1;
147e83
+    else if (EX <  EY)   i=-1;
147e83
+    else                 i= mcr(x,y,p);
147e83
+  }
147e83
+
147e83
+  return i;
147e83
+}
147e83
+
147e83
+
147e83
+/* cr90 compares the values of two multiple precision numbers           */
147e83
+int  __cr(const mp_no *x, const mp_no *y, int p) {
147e83
+  int i;
147e83
+
147e83
+  if      (X[0] > Y[0])  i= 1;
147e83
+  else if (X[0] < Y[0])  i=-1;
147e83
+  else if (X[0] < ZERO ) i= __acr(y,x,p);
147e83
+  else                   i= __acr(x,y,p);
147e83
+
147e83
+  return i;
147e83
+}
147e83
+
147e83
+
147e83
+/* Copy a multiple precision number. Set *y=*x. x=y is permissible.      */
147e83
+void __cpy(const mp_no *x, mp_no *y, int p) {
147e83
+  long i;
147e83
+
147e83
+  EY = EX;
147e83
+  for (i=0; i <= p; i++)    Y[i] = X[i];
147e83
+
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/* Copy a multiple precision number x of precision m into a */
147e83
+/* multiple precision number y of precision n. In case n>m, */
147e83
+/* the digits of y beyond the m'th are set to zero. In case */
147e83
+/* n
147e83
+/* x=y is permissible.                                      */
147e83
+
147e83
+void __cpymn(const mp_no *x, int m, mp_no *y, int n) {
147e83
+
147e83
+  long i,k;
147e83
+  long n2 = n;
147e83
+  long m2 = m;
147e83
+
147e83
+  EY = EX;     k=MIN(m2,n2);
147e83
+  for (i=0; i <= k; i++)    Y[i] = X[i];
147e83
+  for (   ; i <= n2; i++)    Y[i] = ZERO;
147e83
+
147e83
+  return;
147e83
+}
147e83
+
147e83
+/* Convert a multiple precision number *x into a double precision */
147e83
+/* number *y, normalized case  (|x| >= 2**(-1022))) */
147e83
+static void norm(const mp_no *x, double *y, int p)
147e83
+{
147e83
+  #define R  radixi.d
147e83
+  long i;
147e83
+#if 0
147e83
+  int k;
147e83
+#endif
147e83
+  double a,c,u,v,z[5];
147e83
+  if (p<5) {
147e83
+    if      (p==1) c = X[1];
147e83
+    else if (p==2) c = X[1] + R* X[2];
147e83
+    else if (p==3) c = X[1] + R*(X[2]  +   R* X[3]);
147e83
+    else if (p==4) c =(X[1] + R* X[2]) + R*R*(X[3] + R*X[4]);
147e83
+  }
147e83
+  else {
147e83
+    for (a=ONE, z[1]=X[1]; z[1] < TWO23; )
147e83
+        {a *= TWO;   z[1] *= TWO; }
147e83
+
147e83
+    for (i=2; i<5; i++) {
147e83
+      z[i] = X[i]*a;
147e83
+      u = (z[i] + CUTTER)-CUTTER;
147e83
+      if  (u > z[i])  u -= RADIX;
147e83
+      z[i] -= u;
147e83
+      z[i-1] += u*RADIXI;
147e83
+    }
147e83
+
147e83
+    u = (z[3] + TWO71) - TWO71;
147e83
+    if (u > z[3])   u -= TWO19;
147e83
+    v = z[3]-u;
147e83
+
147e83
+    if (v == TWO18) {
147e83
+      if (z[4] == ZERO) {
147e83
+        for (i=5; i <= p; i++) {
147e83
+          if (X[i] == ZERO)   continue;
147e83
+          else                {z[3] += ONE;   break; }
147e83
+        }
147e83
+      }
147e83
+      else              z[3] += ONE;
147e83
+    }
147e83
+
147e83
+    c = (z[1] + R *(z[2] + R * z[3]))/a;
147e83
+  }
147e83
+
147e83
+  c *= X[0];
147e83
+
147e83
+  for (i=1; i
147e83
+  for (i=1; i>EX; i--)   c *= RADIXI;
147e83
+
147e83
+  *y = c;
147e83
+  return;
147e83
+#undef R
147e83
+}
147e83
+
147e83
+/* Convert a multiple precision number *x into a double precision */
147e83
+/* number *y, denormalized case  (|x| < 2**(-1022))) */
147e83
+static void denorm(const mp_no *x, double *y, int p)
147e83
+{
147e83
+  long i,k;
147e83
+  long p2 = p;
147e83
+  double c,u,z[5];
147e83
+#if 0
147e83
+  double a,v;
147e83
+#endif
147e83
+
147e83
+#define R  radixi.d
147e83
+  if (EX<-44 || (EX==-44 && X[1]
147e83
+     { *y=ZERO; return; }
147e83
+
147e83
+  if      (p2==1) {
147e83
+    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=ZERO;  z[3]=ZERO;  k=3;}
147e83
+    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=ZERO;  k=2;}
147e83
+    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
147e83
+  }
147e83
+  else if (p2==2) {
147e83
+    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  z[3]=ZERO;  k=3;}
147e83
+    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=X[2];  k=2;}
147e83
+    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
147e83
+  }
147e83
+  else {
147e83
+    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  k=3;}
147e83
+    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  k=2;}
147e83
+    else              {z[1]=     TWO10;  z[2]=ZERO;  k=1;}
147e83
+    z[3] = X[k];
147e83
+  }
147e83
+
147e83
+  u = (z[3] + TWO57) - TWO57;
147e83
+  if  (u > z[3])   u -= TWO5;
147e83
+
147e83
+  if (u==z[3]) {
147e83
+    for (i=k+1; i <= p2; i++) {
147e83
+      if (X[i] == ZERO)   continue;
147e83
+      else {z[3] += ONE;   break; }
147e83
+    }
147e83
+  }
147e83
+
147e83
+  c = X[0]*((z[1] + R*(z[2] + R*z[3])) - TWO10);
147e83
+
147e83
+  *y = c*TWOM1032;
147e83
+  return;
147e83
+
147e83
+#undef R
147e83
+}
147e83
+
147e83
+/* Convert a multiple precision number *x into a double precision number *y. */
147e83
+/* The result is correctly rounded to the nearest/even. *x is left unchanged */
147e83
+
147e83
+void __mp_dbl(const mp_no *x, double *y, int p) {
147e83
+#if 0
147e83
+  int i,k;
147e83
+  double a,c,u,v,z[5];
147e83
+#endif
147e83
+
147e83
+  if (X[0] == ZERO)  {*y = ZERO;  return; }
147e83
+
147e83
+  if      (EX> -42)                 norm(x,y,p);
147e83
+  else if (EX==-42 && X[1]>=TWO10)  norm(x,y,p);
147e83
+  else                              denorm(x,y,p);
147e83
+}
147e83
+
147e83
+
147e83
+/* dbl_mp() converts a double precision number x into a multiple precision  */
147e83
+/* number *y. If the precision p is too small the result is truncated. x is */
147e83
+/* left unchanged.                                                          */
147e83
+
147e83
+void __dbl_mp(double x, mp_no *y, int p) {
147e83
+
147e83
+  long i,n;
147e83
+  long p2 = p;
147e83
+  double u;
147e83
+
147e83
+  /* Sign */
147e83
+  if      (x == ZERO)  {Y[0] = ZERO;  return; }
147e83
+  else if (x >  ZERO)   Y[0] = ONE;
147e83
+  else                 {Y[0] = MONE;  x=-x;   }
147e83
+
147e83
+  /* Exponent */
147e83
+  for (EY=ONE; x >= RADIX; EY += ONE)   x *= RADIXI;
147e83
+  for (      ; x <  ONE;   EY -= ONE)   x *= RADIX;
147e83
+
147e83
+  /* Digits */
147e83
+  n=MIN(p2,4);
147e83
+  for (i=1; i<=n; i++) {
147e83
+    u = (x + TWO52) - TWO52;
147e83
+    if (u>x)   u -= ONE;
147e83
+    Y[i] = u;     x -= u;    x *= RADIX; }
147e83
+  for (   ; i<=p2; i++)     Y[i] = ZERO;
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/*  add_magnitudes() adds the magnitudes of *x & *y assuming that           */
147e83
+/*  abs(*x) >= abs(*y) > 0.                                                 */
147e83
+/* The sign of the sum *z is undefined. x&y may overlap but not x&z or y&z. */
147e83
+/* No guard digit is used. The result equals the exact sum, truncated.      */
147e83
+/* *x & *y are left unchanged.                                              */
147e83
+
147e83
+static void add_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
+
147e83
+  long i,j,k;
147e83
+  long p2 = p;
147e83
+
147e83
+  EZ = EX;
147e83
+
147e83
+  i=p2;    j=p2+ EY - EX;    k=p2+1;
147e83
+
147e83
+  if (j<1)
147e83
+     {__cpy(x,z,p);  return; }
147e83
+  else   Z[k] = ZERO;
147e83
+
147e83
+  for (; j>0; i--,j--) {
147e83
+    Z[k] += X[i] + Y[j];
147e83
+    if (Z[k] >= RADIX) {
147e83
+      Z[k]  -= RADIX;
147e83
+      Z[--k] = ONE; }
147e83
+    else
147e83
+      Z[--k] = ZERO;
147e83
+  }
147e83
+
147e83
+  for (; i>0; i--) {
147e83
+    Z[k] += X[i];
147e83
+    if (Z[k] >= RADIX) {
147e83
+      Z[k]  -= RADIX;
147e83
+      Z[--k] = ONE; }
147e83
+    else
147e83
+      Z[--k] = ZERO;
147e83
+  }
147e83
+
147e83
+  if (Z[1] == ZERO) {
147e83
+    for (i=1; i<=p2; i++)    Z[i] = Z[i+1]; }
147e83
+  else   EZ += ONE;
147e83
+}
147e83
+
147e83
+
147e83
+/*  sub_magnitudes() subtracts the magnitudes of *x & *y assuming that      */
147e83
+/*  abs(*x) > abs(*y) > 0.                                                  */
147e83
+/* The sign of the difference *z is undefined. x&y may overlap but not x&z  */
147e83
+/* or y&z. One guard digit is used. The error is less than one ulp.         */
147e83
+/* *x & *y are left unchanged.                                              */
147e83
+
147e83
+static void sub_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
+
147e83
+  long i,j,k;
147e83
+  long p2 = p;
147e83
+
147e83
+  EZ = EX;
147e83
+
147e83
+  if (EX == EY) {
147e83
+    i=j=k=p2;
147e83
+    Z[k] = Z[k+1] = ZERO; }
147e83
+  else {
147e83
+    j= EX - EY;
147e83
+    if (j > p2)  {__cpy(x,z,p);  return; }
147e83
+    else {
147e83
+      i=p2;   j=p2+1-j;   k=p2;
147e83
+      if (Y[j] > ZERO) {
147e83
+        Z[k+1] = RADIX - Y[j--];
147e83
+        Z[k]   = MONE; }
147e83
+      else {
147e83
+        Z[k+1] = ZERO;
147e83
+        Z[k]   = ZERO;   j--;}
147e83
+    }
147e83
+  }
147e83
+
147e83
+  for (; j>0; i--,j--) {
147e83
+    Z[k] += (X[i] - Y[j]);
147e83
+    if (Z[k] < ZERO) {
147e83
+      Z[k]  += RADIX;
147e83
+      Z[--k] = MONE; }
147e83
+    else
147e83
+      Z[--k] = ZERO;
147e83
+  }
147e83
+
147e83
+  for (; i>0; i--) {
147e83
+    Z[k] += X[i];
147e83
+    if (Z[k] < ZERO) {
147e83
+      Z[k]  += RADIX;
147e83
+      Z[--k] = MONE; }
147e83
+    else
147e83
+      Z[--k] = ZERO;
147e83
+  }
147e83
+
147e83
+  for (i=1; Z[i] == ZERO; i++) ;
147e83
+  EZ = EZ - i + 1;
147e83
+  for (k=1; i <= p2+1; )
147e83
+    Z[k++] = Z[i++];
147e83
+  for (; k <= p2; )
147e83
+    Z[k++] = ZERO;
147e83
+
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/* Add two multiple precision numbers. Set *z = *x + *y. x&y may overlap  */
147e83
+/* but not x&z or y&z. One guard digit is used. The error is less than    */
147e83
+/* one ulp. *x & *y are left unchanged.                                   */
147e83
+
147e83
+void __add(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
+
147e83
+  int n;
147e83
+
147e83
+  if      (X[0] == ZERO)     {__cpy(y,z,p);  return; }
147e83
+  else if (Y[0] == ZERO)     {__cpy(x,z,p);  return; }
147e83
+
147e83
+  if (X[0] == Y[0])   {
147e83
+    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] = X[0]; }
147e83
+    else                     {add_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
147e83
+  }
147e83
+  else                       {
147e83
+    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] = X[0]; }
147e83
+    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
147e83
+    else                      Z[0] = ZERO;
147e83
+  }
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/* Subtract two multiple precision numbers. *z is set to *x - *y. x&y may */
147e83
+/* overlap but not x&z or y&z. One guard digit is used. The error is      */
147e83
+/* less than one ulp. *x & *y are left unchanged.                         */
147e83
+
147e83
+void __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
+
147e83
+  int n;
147e83
+
147e83
+  if      (X[0] == ZERO)     {__cpy(y,z,p);  Z[0] = -Z[0];  return; }
147e83
+  else if (Y[0] == ZERO)     {__cpy(x,z,p);                 return; }
147e83
+
147e83
+  if (X[0] != Y[0])    {
147e83
+    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
147e83
+    else                     {add_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
147e83
+  }
147e83
+  else                       {
147e83
+    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
147e83
+    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
147e83
+    else                      Z[0] = ZERO;
147e83
+  }
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/* Multiply two multiple precision numbers. *z is set to *x * *y. x&y      */
147e83
+/* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is     */
147e83
+/* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp.   */
147e83
+/* *x & *y are left unchanged.                                             */
147e83
+
147e83
+void __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
+
147e83
+  long i, i1, i2, j, k, k2;
147e83
+  long p2 = p;
147e83
+  double u, zk, zk2;
147e83
+
147e83
+                      /* Is z=0? */
147e83
+  if (X[0]*Y[0]==ZERO)
147e83
+     { Z[0]=ZERO;  return; }
147e83
+
147e83
+                       /* Multiply, add and carry */
147e83
+  k2 = (p2<3) ? p2+p2 : p2+3;
147e83
+  zk = Z[k2]=ZERO;
147e83
+  for (k=k2; k>1; ) {
147e83
+    if (k > p2)  {i1=k-p2; i2=p2+1; }
147e83
+    else        {i1=1;   i2=k;   }
147e83
+#if 1
147e83
+    /* rearange this inner loop to allow the fmadd instructions to be
147e83
+       independent and execute in parallel on processors that have
147e83
+       dual symetrical FP pipelines.  */
147e83
+    if (i1 < (i2-1))
147e83
+    {
147e83
+	/* make sure we have at least 2 iterations */
147e83
+	if (((i2 - i1) & 1L) == 1L)
147e83
+	{
147e83
+                /* Handle the odd iterations case.  */
147e83
+		zk2 = x->d[i2-1]*y->d[i1];
147e83
+	}
147e83
+	else
147e83
+		zk2 = zero.d;
147e83
+	/* Do two multiply/adds per loop iteration, using independent
147e83
+           accumulators; zk and zk2.  */
147e83
+	for (i=i1,j=i2-1; i
147e83
+	{
147e83
+		zk += x->d[i]*y->d[j];
147e83
+		zk2 += x->d[i+1]*y->d[j-1];
147e83
+	}
147e83
+	zk += zk2; /* final sum.  */
147e83
+    }
147e83
+    else
147e83
+    {
147e83
+        /* Special case when iterations is 1.  */
147e83
+	zk += x->d[i1]*y->d[i1];
147e83
+    }
147e83
+#else
147e83
+    /* The orginal code.  */
147e83
+    for (i=i1,j=i2-1; i
147e83
+#endif
147e83
+
147e83
+    u = (zk + CUTTER)-CUTTER;
147e83
+    if  (u > zk)  u -= RADIX;
147e83
+    Z[k]  = zk - u;
147e83
+    zk = u*RADIXI;
147e83
+    --k;
147e83
+  }
147e83
+  Z[k] = zk;
147e83
+
147e83
+                 /* Is there a carry beyond the most significant digit? */
147e83
+  if (Z[1] == ZERO) {
147e83
+    for (i=1; i<=p2; i++)  Z[i]=Z[i+1];
147e83
+    EZ = EX + EY - 1; }
147e83
+  else
147e83
+    EZ = EX + EY;
147e83
+
147e83
+  Z[0] = X[0] * Y[0];
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/* Invert a multiple precision number. Set *y = 1 / *x.                     */
147e83
+/* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3,   */
147e83
+/* 2.001*r**(1-p) for p>3.                                                  */
147e83
+/* *x=0 is not permissible. *x is left unchanged.                           */
147e83
+
147e83
+void __inv(const mp_no *x, mp_no *y, int p) {
147e83
+  long i;
147e83
+#if 0
147e83
+  int l;
147e83
+#endif
147e83
+  double t;
147e83
+  mp_no z,w;
147e83
+  static const int np1[] = {0,0,0,0,1,2,2,2,2,3,3,3,3,3,3,3,3,3,
147e83
+                            4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
147e83
+  const mp_no mptwo = {1,{1.0,2.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
+                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
+                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
+                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
147e83
+
147e83
+  __cpy(x,&z,p);  z.e=0;  __mp_dbl(&z,&t,p);
147e83
+  t=ONE/t;   __dbl_mp(t,y,p);    EY -= EX;
147e83
+
147e83
+  for (i=0; i
147e83
+    __cpy(y,&w,p);
147e83
+    __mul(x,&w,y,p);
147e83
+    __sub(&mptwo,y,&z,p);
147e83
+    __mul(&w,&z,y,p);
147e83
+  }
147e83
+  return;
147e83
+}
147e83
+
147e83
+
147e83
+/* Divide one multiple precision number by another.Set *z = *x / *y. *x & *y */
147e83
+/* are left unchanged. x&y may overlap but not x&z or y&z.                   */
147e83
+/* Relative error bound = 2.001*r**(1-p) for p=2, 2.063*r**(1-p) for p=3     */
147e83
+/* and 3.001*r**(1-p) for p>3. *y=0 is not permissible.                      */
147e83
+
147e83
+void __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
+
147e83
+  mp_no w;
147e83
+
147e83
+  if (X[0] == ZERO)    Z[0] = ZERO;
147e83
+  else                {__inv(y,&w,p);   __mul(x,&w,z,p);}
147e83
+  return;
147e83
+}
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/Implies glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/Implies
147e83
new file mode 100644
147e83
index 0000000..a372141
147e83
--- /dev/null
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/Implies
147e83
@@ -0,0 +1,2 @@
147e83
+powerpc/power4/fpu
147e83
+powerpc/power4
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/fpu/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/fpu/Makefile
147e83
deleted file mode 100644
147e83
index f487ed6..0000000
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/fpu/Makefile
147e83
+++ /dev/null
147e83
@@ -1,5 +0,0 @@
147e83
-# Makefile fragment for POWER4/5/5+ with FPU.
147e83
-
147e83
-ifeq ($(subdir),math)
147e83
-CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
147e83
-endif
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
147e83
deleted file mode 100644
147e83
index d15680e..0000000
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/fpu/mpa.c
147e83
+++ /dev/null
147e83
@@ -1,548 +0,0 @@
147e83
-
147e83
-/*
147e83
- * IBM Accurate Mathematical Library
147e83
- * written by International Business Machines Corp.
147e83
- * Copyright (C) 2001, 2006 Free Software Foundation
147e83
- *
147e83
- * This program is free software; you can redistribute it and/or modify
147e83
- * it under the terms of the GNU Lesser General Public License as published by
147e83
- * the Free Software Foundation; either version 2.1 of the License, or
147e83
- * (at your option) any later version.
147e83
- *
147e83
- * This program is distributed in the hope that it will be useful,
147e83
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147e83
- * GNU Lesser General Public License for more details.
147e83
- *
147e83
- * You should have received a copy of the GNU Lesser General Public License
147e83
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
147e83
- */
147e83
-/************************************************************************/
147e83
-/*  MODULE_NAME: mpa.c                                                  */
147e83
-/*                                                                      */
147e83
-/*  FUNCTIONS:                                                          */
147e83
-/*               mcr                                                    */
147e83
-/*               acr                                                    */
147e83
-/*               cr                                                     */
147e83
-/*               cpy                                                    */
147e83
-/*               cpymn                                                  */
147e83
-/*               norm                                                   */
147e83
-/*               denorm                                                 */
147e83
-/*               mp_dbl                                                 */
147e83
-/*               dbl_mp                                                 */
147e83
-/*               add_magnitudes                                         */
147e83
-/*               sub_magnitudes                                         */
147e83
-/*               add                                                    */
147e83
-/*               sub                                                    */
147e83
-/*               mul                                                    */
147e83
-/*               inv                                                    */
147e83
-/*               dvd                                                    */
147e83
-/*                                                                      */
147e83
-/* Arithmetic functions for multiple precision numbers.                 */
147e83
-/* Relative errors are bounded                                          */
147e83
-/************************************************************************/
147e83
-
147e83
-
147e83
-#include "endian.h"
147e83
-#include "mpa.h"
147e83
-#include "mpa2.h"
147e83
-#include <sys/param.h>	/* For MIN() */
147e83
-/* mcr() compares the sizes of the mantissas of two multiple precision  */
147e83
-/* numbers. Mantissas are compared regardless of the signs of the       */
147e83
-/* numbers, even if x->d[0] or y->d[0] are zero. Exponents are also     */
147e83
-/* disregarded.                                                         */
147e83
-static int mcr(const mp_no *x, const mp_no *y, int p) {
147e83
-  long i;
147e83
-  long p2 = p;
147e83
-  for (i=1; i<=p2; i++) {
147e83
-    if      (X[i] == Y[i])  continue;
147e83
-    else if (X[i] >  Y[i])  return  1;
147e83
-    else                    return -1; }
147e83
-  return 0;
147e83
-}
147e83
-
147e83
-
147e83
-
147e83
-/* acr() compares the absolute values of two multiple precision numbers */
147e83
-int __acr(const mp_no *x, const mp_no *y, int p) {
147e83
-  long i;
147e83
-
147e83
-  if      (X[0] == ZERO) {
147e83
-    if    (Y[0] == ZERO) i= 0;
147e83
-    else                 i=-1;
147e83
-  }
147e83
-  else if (Y[0] == ZERO) i= 1;
147e83
-  else {
147e83
-    if      (EX >  EY)   i= 1;
147e83
-    else if (EX <  EY)   i=-1;
147e83
-    else                 i= mcr(x,y,p);
147e83
-  }
147e83
-
147e83
-  return i;
147e83
-}
147e83
-
147e83
-
147e83
-/* cr90 compares the values of two multiple precision numbers           */
147e83
-int  __cr(const mp_no *x, const mp_no *y, int p) {
147e83
-  int i;
147e83
-
147e83
-  if      (X[0] > Y[0])  i= 1;
147e83
-  else if (X[0] < Y[0])  i=-1;
147e83
-  else if (X[0] < ZERO ) i= __acr(y,x,p);
147e83
-  else                   i= __acr(x,y,p);
147e83
-
147e83
-  return i;
147e83
-}
147e83
-
147e83
-
147e83
-/* Copy a multiple precision number. Set *y=*x. x=y is permissible.      */
147e83
-void __cpy(const mp_no *x, mp_no *y, int p) {
147e83
-  long i;
147e83
-
147e83
-  EY = EX;
147e83
-  for (i=0; i <= p; i++)    Y[i] = X[i];
147e83
-
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Copy a multiple precision number x of precision m into a */
147e83
-/* multiple precision number y of precision n. In case n>m, */
147e83
-/* the digits of y beyond the m'th are set to zero. In case */
147e83
-/* n
147e83
-/* x=y is permissible.                                      */
147e83
-
147e83
-void __cpymn(const mp_no *x, int m, mp_no *y, int n) {
147e83
-
147e83
-  long i,k;
147e83
-  long n2 = n;
147e83
-  long m2 = m;
147e83
-
147e83
-  EY = EX;     k=MIN(m2,n2);
147e83
-  for (i=0; i <= k; i++)    Y[i] = X[i];
147e83
-  for (   ; i <= n2; i++)    Y[i] = ZERO;
147e83
-
147e83
-  return;
147e83
-}
147e83
-
147e83
-/* Convert a multiple precision number *x into a double precision */
147e83
-/* number *y, normalized case  (|x| >= 2**(-1022))) */
147e83
-static void norm(const mp_no *x, double *y, int p)
147e83
-{
147e83
-  #define R  radixi.d
147e83
-  long i;
147e83
-#if 0
147e83
-  int k;
147e83
-#endif
147e83
-  double a,c,u,v,z[5];
147e83
-  if (p<5) {
147e83
-    if      (p==1) c = X[1];
147e83
-    else if (p==2) c = X[1] + R* X[2];
147e83
-    else if (p==3) c = X[1] + R*(X[2]  +   R* X[3]);
147e83
-    else if (p==4) c =(X[1] + R* X[2]) + R*R*(X[3] + R*X[4]);
147e83
-  }
147e83
-  else {
147e83
-    for (a=ONE, z[1]=X[1]; z[1] < TWO23; )
147e83
-        {a *= TWO;   z[1] *= TWO; }
147e83
-
147e83
-    for (i=2; i<5; i++) {
147e83
-      z[i] = X[i]*a;
147e83
-      u = (z[i] + CUTTER)-CUTTER;
147e83
-      if  (u > z[i])  u -= RADIX;
147e83
-      z[i] -= u;
147e83
-      z[i-1] += u*RADIXI;
147e83
-    }
147e83
-
147e83
-    u = (z[3] + TWO71) - TWO71;
147e83
-    if (u > z[3])   u -= TWO19;
147e83
-    v = z[3]-u;
147e83
-
147e83
-    if (v == TWO18) {
147e83
-      if (z[4] == ZERO) {
147e83
-        for (i=5; i <= p; i++) {
147e83
-          if (X[i] == ZERO)   continue;
147e83
-          else                {z[3] += ONE;   break; }
147e83
-        }
147e83
-      }
147e83
-      else              z[3] += ONE;
147e83
-    }
147e83
-
147e83
-    c = (z[1] + R *(z[2] + R * z[3]))/a;
147e83
-  }
147e83
-
147e83
-  c *= X[0];
147e83
-
147e83
-  for (i=1; i
147e83
-  for (i=1; i>EX; i--)   c *= RADIXI;
147e83
-
147e83
-  *y = c;
147e83
-  return;
147e83
-#undef R
147e83
-}
147e83
-
147e83
-/* Convert a multiple precision number *x into a double precision */
147e83
-/* number *y, denormalized case  (|x| < 2**(-1022))) */
147e83
-static void denorm(const mp_no *x, double *y, int p)
147e83
-{
147e83
-  long i,k;
147e83
-  long p2 = p;
147e83
-  double c,u,z[5];
147e83
-#if 0
147e83
-  double a,v;
147e83
-#endif
147e83
-
147e83
-#define R  radixi.d
147e83
-  if (EX<-44 || (EX==-44 && X[1]
147e83
-     { *y=ZERO; return; }
147e83
-
147e83
-  if      (p2==1) {
147e83
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=ZERO;  z[3]=ZERO;  k=3;}
147e83
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=ZERO;  k=2;}
147e83
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
147e83
-  }
147e83
-  else if (p2==2) {
147e83
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  z[3]=ZERO;  k=3;}
147e83
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=X[2];  k=2;}
147e83
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
147e83
-  }
147e83
-  else {
147e83
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  k=3;}
147e83
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  k=2;}
147e83
-    else              {z[1]=     TWO10;  z[2]=ZERO;  k=1;}
147e83
-    z[3] = X[k];
147e83
-  }
147e83
-
147e83
-  u = (z[3] + TWO57) - TWO57;
147e83
-  if  (u > z[3])   u -= TWO5;
147e83
-
147e83
-  if (u==z[3]) {
147e83
-    for (i=k+1; i <= p2; i++) {
147e83
-      if (X[i] == ZERO)   continue;
147e83
-      else {z[3] += ONE;   break; }
147e83
-    }
147e83
-  }
147e83
-
147e83
-  c = X[0]*((z[1] + R*(z[2] + R*z[3])) - TWO10);
147e83
-
147e83
-  *y = c*TWOM1032;
147e83
-  return;
147e83
-
147e83
-#undef R
147e83
-}
147e83
-
147e83
-/* Convert a multiple precision number *x into a double precision number *y. */
147e83
-/* The result is correctly rounded to the nearest/even. *x is left unchanged */
147e83
-
147e83
-void __mp_dbl(const mp_no *x, double *y, int p) {
147e83
-#if 0
147e83
-  int i,k;
147e83
-  double a,c,u,v,z[5];
147e83
-#endif
147e83
-
147e83
-  if (X[0] == ZERO)  {*y = ZERO;  return; }
147e83
-
147e83
-  if      (EX> -42)                 norm(x,y,p);
147e83
-  else if (EX==-42 && X[1]>=TWO10)  norm(x,y,p);
147e83
-  else                              denorm(x,y,p);
147e83
-}
147e83
-
147e83
-
147e83
-/* dbl_mp() converts a double precision number x into a multiple precision  */
147e83
-/* number *y. If the precision p is too small the result is truncated. x is */
147e83
-/* left unchanged.                                                          */
147e83
-
147e83
-void __dbl_mp(double x, mp_no *y, int p) {
147e83
-
147e83
-  long i,n;
147e83
-  long p2 = p;
147e83
-  double u;
147e83
-
147e83
-  /* Sign */
147e83
-  if      (x == ZERO)  {Y[0] = ZERO;  return; }
147e83
-  else if (x >  ZERO)   Y[0] = ONE;
147e83
-  else                 {Y[0] = MONE;  x=-x;   }
147e83
-
147e83
-  /* Exponent */
147e83
-  for (EY=ONE; x >= RADIX; EY += ONE)   x *= RADIXI;
147e83
-  for (      ; x <  ONE;   EY -= ONE)   x *= RADIX;
147e83
-
147e83
-  /* Digits */
147e83
-  n=MIN(p2,4);
147e83
-  for (i=1; i<=n; i++) {
147e83
-    u = (x + TWO52) - TWO52;
147e83
-    if (u>x)   u -= ONE;
147e83
-    Y[i] = u;     x -= u;    x *= RADIX; }
147e83
-  for (   ; i<=p2; i++)     Y[i] = ZERO;
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/*  add_magnitudes() adds the magnitudes of *x & *y assuming that           */
147e83
-/*  abs(*x) >= abs(*y) > 0.                                                 */
147e83
-/* The sign of the sum *z is undefined. x&y may overlap but not x&z or y&z. */
147e83
-/* No guard digit is used. The result equals the exact sum, truncated.      */
147e83
-/* *x & *y are left unchanged.                                              */
147e83
-
147e83
-static void add_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  long i,j,k;
147e83
-  long p2 = p;
147e83
-
147e83
-  EZ = EX;
147e83
-
147e83
-  i=p2;    j=p2+ EY - EX;    k=p2+1;
147e83
-
147e83
-  if (j<1)
147e83
-     {__cpy(x,z,p);  return; }
147e83
-  else   Z[k] = ZERO;
147e83
-
147e83
-  for (; j>0; i--,j--) {
147e83
-    Z[k] += X[i] + Y[j];
147e83
-    if (Z[k] >= RADIX) {
147e83
-      Z[k]  -= RADIX;
147e83
-      Z[--k] = ONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  for (; i>0; i--) {
147e83
-    Z[k] += X[i];
147e83
-    if (Z[k] >= RADIX) {
147e83
-      Z[k]  -= RADIX;
147e83
-      Z[--k] = ONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  if (Z[1] == ZERO) {
147e83
-    for (i=1; i<=p2; i++)    Z[i] = Z[i+1]; }
147e83
-  else   EZ += ONE;
147e83
-}
147e83
-
147e83
-
147e83
-/*  sub_magnitudes() subtracts the magnitudes of *x & *y assuming that      */
147e83
-/*  abs(*x) > abs(*y) > 0.                                                  */
147e83
-/* The sign of the difference *z is undefined. x&y may overlap but not x&z  */
147e83
-/* or y&z. One guard digit is used. The error is less than one ulp.         */
147e83
-/* *x & *y are left unchanged.                                              */
147e83
-
147e83
-static void sub_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  long i,j,k;
147e83
-  long p2 = p;
147e83
-
147e83
-  EZ = EX;
147e83
-
147e83
-  if (EX == EY) {
147e83
-    i=j=k=p2;
147e83
-    Z[k] = Z[k+1] = ZERO; }
147e83
-  else {
147e83
-    j= EX - EY;
147e83
-    if (j > p2)  {__cpy(x,z,p);  return; }
147e83
-    else {
147e83
-      i=p2;   j=p2+1-j;   k=p2;
147e83
-      if (Y[j] > ZERO) {
147e83
-        Z[k+1] = RADIX - Y[j--];
147e83
-        Z[k]   = MONE; }
147e83
-      else {
147e83
-        Z[k+1] = ZERO;
147e83
-        Z[k]   = ZERO;   j--;}
147e83
-    }
147e83
-  }
147e83
-
147e83
-  for (; j>0; i--,j--) {
147e83
-    Z[k] += (X[i] - Y[j]);
147e83
-    if (Z[k] < ZERO) {
147e83
-      Z[k]  += RADIX;
147e83
-      Z[--k] = MONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  for (; i>0; i--) {
147e83
-    Z[k] += X[i];
147e83
-    if (Z[k] < ZERO) {
147e83
-      Z[k]  += RADIX;
147e83
-      Z[--k] = MONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  for (i=1; Z[i] == ZERO; i++) ;
147e83
-  EZ = EZ - i + 1;
147e83
-  for (k=1; i <= p2+1; )
147e83
-    Z[k++] = Z[i++];
147e83
-  for (; k <= p2; )
147e83
-    Z[k++] = ZERO;
147e83
-
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Add two multiple precision numbers. Set *z = *x + *y. x&y may overlap  */
147e83
-/* but not x&z or y&z. One guard digit is used. The error is less than    */
147e83
-/* one ulp. *x & *y are left unchanged.                                   */
147e83
-
147e83
-void __add(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  int n;
147e83
-
147e83
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  return; }
147e83
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);  return; }
147e83
-
147e83
-  if (X[0] == Y[0])   {
147e83
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] = X[0]; }
147e83
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
147e83
-  }
147e83
-  else                       {
147e83
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] = X[0]; }
147e83
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
147e83
-    else                      Z[0] = ZERO;
147e83
-  }
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Subtract two multiple precision numbers. *z is set to *x - *y. x&y may */
147e83
-/* overlap but not x&z or y&z. One guard digit is used. The error is      */
147e83
-/* less than one ulp. *x & *y are left unchanged.                         */
147e83
-
147e83
-void __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  int n;
147e83
-
147e83
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  Z[0] = -Z[0];  return; }
147e83
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);                 return; }
147e83
-
147e83
-  if (X[0] != Y[0])    {
147e83
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
147e83
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
147e83
-  }
147e83
-  else                       {
147e83
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
147e83
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
147e83
-    else                      Z[0] = ZERO;
147e83
-  }
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Multiply two multiple precision numbers. *z is set to *x * *y. x&y      */
147e83
-/* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is     */
147e83
-/* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp.   */
147e83
-/* *x & *y are left unchanged.                                             */
147e83
-
147e83
-void __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  long i, i1, i2, j, k, k2;
147e83
-  long p2 = p;
147e83
-  double u, zk, zk2;
147e83
-
147e83
-                      /* Is z=0? */
147e83
-  if (X[0]*Y[0]==ZERO)
147e83
-     { Z[0]=ZERO;  return; }
147e83
-
147e83
-                       /* Multiply, add and carry */
147e83
-  k2 = (p2<3) ? p2+p2 : p2+3;
147e83
-  zk = Z[k2]=ZERO;
147e83
-  for (k=k2; k>1; ) {
147e83
-    if (k > p2)  {i1=k-p2; i2=p2+1; }
147e83
-    else        {i1=1;   i2=k;   }
147e83
-#if 1
147e83
-    /* rearange this inner loop to allow the fmadd instructions to be
147e83
-       independent and execute in parallel on processors that have
147e83
-       dual symetrical FP pipelines.  */
147e83
-    if (i1 < (i2-1))
147e83
-    {
147e83
-	/* make sure we have at least 2 iterations */
147e83
-	if (((i2 - i1) & 1L) == 1L)
147e83
-	{
147e83
-                /* Handle the odd iterations case.  */
147e83
-		zk2 = x->d[i2-1]*y->d[i1];
147e83
-	}
147e83
-	else
147e83
-		zk2 = zero.d;
147e83
-	/* Do two multiply/adds per loop iteration, using independent
147e83
-           accumulators; zk and zk2.  */
147e83
-	for (i=i1,j=i2-1; i
147e83
-	{
147e83
-		zk += x->d[i]*y->d[j];
147e83
-		zk2 += x->d[i+1]*y->d[j-1];
147e83
-	}
147e83
-	zk += zk2; /* final sum.  */
147e83
-    }
147e83
-    else
147e83
-    {
147e83
-        /* Special case when iterations is 1.  */
147e83
-	zk += x->d[i1]*y->d[i1];
147e83
-    }
147e83
-#else
147e83
-    /* The orginal code.  */
147e83
-    for (i=i1,j=i2-1; i
147e83
-#endif
147e83
-
147e83
-    u = (zk + CUTTER)-CUTTER;
147e83
-    if  (u > zk)  u -= RADIX;
147e83
-    Z[k]  = zk - u;
147e83
-    zk = u*RADIXI;
147e83
-    --k;
147e83
-  }
147e83
-  Z[k] = zk;
147e83
-
147e83
-                 /* Is there a carry beyond the most significant digit? */
147e83
-  if (Z[1] == ZERO) {
147e83
-    for (i=1; i<=p2; i++)  Z[i]=Z[i+1];
147e83
-    EZ = EX + EY - 1; }
147e83
-  else
147e83
-    EZ = EX + EY;
147e83
-
147e83
-  Z[0] = X[0] * Y[0];
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Invert a multiple precision number. Set *y = 1 / *x.                     */
147e83
-/* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3,   */
147e83
-/* 2.001*r**(1-p) for p>3.                                                  */
147e83
-/* *x=0 is not permissible. *x is left unchanged.                           */
147e83
-
147e83
-void __inv(const mp_no *x, mp_no *y, int p) {
147e83
-  long i;
147e83
-#if 0
147e83
-  int l;
147e83
-#endif
147e83
-  double t;
147e83
-  mp_no z,w;
147e83
-  static const int np1[] = {0,0,0,0,1,2,2,2,2,3,3,3,3,3,3,3,3,3,
147e83
-                            4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
147e83
-  const mp_no mptwo = {1,{1.0,2.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
147e83
-
147e83
-  __cpy(x,&z,p);  z.e=0;  __mp_dbl(&z,&t,p);
147e83
-  t=ONE/t;   __dbl_mp(t,y,p);    EY -= EX;
147e83
-
147e83
-  for (i=0; i
147e83
-    __cpy(y,&w,p);
147e83
-    __mul(x,&w,y,p);
147e83
-    __sub(&mptwo,y,&z,p);
147e83
-    __mul(&w,&z,y,p);
147e83
-  }
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Divide one multiple precision number by another.Set *z = *x / *y. *x & *y */
147e83
-/* are left unchanged. x&y may overlap but not x&z or y&z.                   */
147e83
-/* Relative error bound = 2.001*r**(1-p) for p=2, 2.063*r**(1-p) for p=3     */
147e83
-/* and 3.001*r**(1-p) for p>3. *y=0 is not permissible.                      */
147e83
-
147e83
-void __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  mp_no w;
147e83
-
147e83
-  if (X[0] == ZERO)    Z[0] = ZERO;
147e83
-  else                {__inv(y,&w,p);   __mul(x,&w,z,p);}
147e83
-  return;
147e83
-}
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/Implies glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/Implies
147e83
new file mode 100644
147e83
index 0000000..a372141
147e83
--- /dev/null
147e83
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/Implies
147e83
@@ -0,0 +1,2 @@
147e83
+powerpc/power4/fpu
147e83
+powerpc/power4
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/fpu/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/fpu/Makefile
147e83
deleted file mode 100644
147e83
index f8bb3ef..0000000
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/fpu/Makefile
147e83
+++ /dev/null
147e83
@@ -1,5 +0,0 @@
147e83
-# Makefile fragment for POWER4/5/5+ platforms with FPU.
147e83
-
147e83
-ifeq ($(subdir),math)
147e83
-CFLAGS-mpa.c += --param max-unroll-times=4 -funroll-loops -fpeel-loops
147e83
-endif
147e83
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
147e83
deleted file mode 100644
147e83
index d15680e..0000000
147e83
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power4/fpu/mpa.c
147e83
+++ /dev/null
147e83
@@ -1,548 +0,0 @@
147e83
-
147e83
-/*
147e83
- * IBM Accurate Mathematical Library
147e83
- * written by International Business Machines Corp.
147e83
- * Copyright (C) 2001, 2006 Free Software Foundation
147e83
- *
147e83
- * This program is free software; you can redistribute it and/or modify
147e83
- * it under the terms of the GNU Lesser General Public License as published by
147e83
- * the Free Software Foundation; either version 2.1 of the License, or
147e83
- * (at your option) any later version.
147e83
- *
147e83
- * This program is distributed in the hope that it will be useful,
147e83
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
147e83
- * GNU Lesser General Public License for more details.
147e83
- *
147e83
- * You should have received a copy of the GNU Lesser General Public License
147e83
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
147e83
- */
147e83
-/************************************************************************/
147e83
-/*  MODULE_NAME: mpa.c                                                  */
147e83
-/*                                                                      */
147e83
-/*  FUNCTIONS:                                                          */
147e83
-/*               mcr                                                    */
147e83
-/*               acr                                                    */
147e83
-/*               cr                                                     */
147e83
-/*               cpy                                                    */
147e83
-/*               cpymn                                                  */
147e83
-/*               norm                                                   */
147e83
-/*               denorm                                                 */
147e83
-/*               mp_dbl                                                 */
147e83
-/*               dbl_mp                                                 */
147e83
-/*               add_magnitudes                                         */
147e83
-/*               sub_magnitudes                                         */
147e83
-/*               add                                                    */
147e83
-/*               sub                                                    */
147e83
-/*               mul                                                    */
147e83
-/*               inv                                                    */
147e83
-/*               dvd                                                    */
147e83
-/*                                                                      */
147e83
-/* Arithmetic functions for multiple precision numbers.                 */
147e83
-/* Relative errors are bounded                                          */
147e83
-/************************************************************************/
147e83
-
147e83
-
147e83
-#include "endian.h"
147e83
-#include "mpa.h"
147e83
-#include "mpa2.h"
147e83
-#include <sys/param.h>	/* For MIN() */
147e83
-/* mcr() compares the sizes of the mantissas of two multiple precision  */
147e83
-/* numbers. Mantissas are compared regardless of the signs of the       */
147e83
-/* numbers, even if x->d[0] or y->d[0] are zero. Exponents are also     */
147e83
-/* disregarded.                                                         */
147e83
-static int mcr(const mp_no *x, const mp_no *y, int p) {
147e83
-  long i;
147e83
-  long p2 = p;
147e83
-  for (i=1; i<=p2; i++) {
147e83
-    if      (X[i] == Y[i])  continue;
147e83
-    else if (X[i] >  Y[i])  return  1;
147e83
-    else                    return -1; }
147e83
-  return 0;
147e83
-}
147e83
-
147e83
-
147e83
-
147e83
-/* acr() compares the absolute values of two multiple precision numbers */
147e83
-int __acr(const mp_no *x, const mp_no *y, int p) {
147e83
-  long i;
147e83
-
147e83
-  if      (X[0] == ZERO) {
147e83
-    if    (Y[0] == ZERO) i= 0;
147e83
-    else                 i=-1;
147e83
-  }
147e83
-  else if (Y[0] == ZERO) i= 1;
147e83
-  else {
147e83
-    if      (EX >  EY)   i= 1;
147e83
-    else if (EX <  EY)   i=-1;
147e83
-    else                 i= mcr(x,y,p);
147e83
-  }
147e83
-
147e83
-  return i;
147e83
-}
147e83
-
147e83
-
147e83
-/* cr90 compares the values of two multiple precision numbers           */
147e83
-int  __cr(const mp_no *x, const mp_no *y, int p) {
147e83
-  int i;
147e83
-
147e83
-  if      (X[0] > Y[0])  i= 1;
147e83
-  else if (X[0] < Y[0])  i=-1;
147e83
-  else if (X[0] < ZERO ) i= __acr(y,x,p);
147e83
-  else                   i= __acr(x,y,p);
147e83
-
147e83
-  return i;
147e83
-}
147e83
-
147e83
-
147e83
-/* Copy a multiple precision number. Set *y=*x. x=y is permissible.      */
147e83
-void __cpy(const mp_no *x, mp_no *y, int p) {
147e83
-  long i;
147e83
-
147e83
-  EY = EX;
147e83
-  for (i=0; i <= p; i++)    Y[i] = X[i];
147e83
-
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Copy a multiple precision number x of precision m into a */
147e83
-/* multiple precision number y of precision n. In case n>m, */
147e83
-/* the digits of y beyond the m'th are set to zero. In case */
147e83
-/* n
147e83
-/* x=y is permissible.                                      */
147e83
-
147e83
-void __cpymn(const mp_no *x, int m, mp_no *y, int n) {
147e83
-
147e83
-  long i,k;
147e83
-  long n2 = n;
147e83
-  long m2 = m;
147e83
-
147e83
-  EY = EX;     k=MIN(m2,n2);
147e83
-  for (i=0; i <= k; i++)    Y[i] = X[i];
147e83
-  for (   ; i <= n2; i++)    Y[i] = ZERO;
147e83
-
147e83
-  return;
147e83
-}
147e83
-
147e83
-/* Convert a multiple precision number *x into a double precision */
147e83
-/* number *y, normalized case  (|x| >= 2**(-1022))) */
147e83
-static void norm(const mp_no *x, double *y, int p)
147e83
-{
147e83
-  #define R  radixi.d
147e83
-  long i;
147e83
-#if 0
147e83
-  int k;
147e83
-#endif
147e83
-  double a,c,u,v,z[5];
147e83
-  if (p<5) {
147e83
-    if      (p==1) c = X[1];
147e83
-    else if (p==2) c = X[1] + R* X[2];
147e83
-    else if (p==3) c = X[1] + R*(X[2]  +   R* X[3]);
147e83
-    else if (p==4) c =(X[1] + R* X[2]) + R*R*(X[3] + R*X[4]);
147e83
-  }
147e83
-  else {
147e83
-    for (a=ONE, z[1]=X[1]; z[1] < TWO23; )
147e83
-        {a *= TWO;   z[1] *= TWO; }
147e83
-
147e83
-    for (i=2; i<5; i++) {
147e83
-      z[i] = X[i]*a;
147e83
-      u = (z[i] + CUTTER)-CUTTER;
147e83
-      if  (u > z[i])  u -= RADIX;
147e83
-      z[i] -= u;
147e83
-      z[i-1] += u*RADIXI;
147e83
-    }
147e83
-
147e83
-    u = (z[3] + TWO71) - TWO71;
147e83
-    if (u > z[3])   u -= TWO19;
147e83
-    v = z[3]-u;
147e83
-
147e83
-    if (v == TWO18) {
147e83
-      if (z[4] == ZERO) {
147e83
-        for (i=5; i <= p; i++) {
147e83
-          if (X[i] == ZERO)   continue;
147e83
-          else                {z[3] += ONE;   break; }
147e83
-        }
147e83
-      }
147e83
-      else              z[3] += ONE;
147e83
-    }
147e83
-
147e83
-    c = (z[1] + R *(z[2] + R * z[3]))/a;
147e83
-  }
147e83
-
147e83
-  c *= X[0];
147e83
-
147e83
-  for (i=1; i
147e83
-  for (i=1; i>EX; i--)   c *= RADIXI;
147e83
-
147e83
-  *y = c;
147e83
-  return;
147e83
-#undef R
147e83
-}
147e83
-
147e83
-/* Convert a multiple precision number *x into a double precision */
147e83
-/* number *y, denormalized case  (|x| < 2**(-1022))) */
147e83
-static void denorm(const mp_no *x, double *y, int p)
147e83
-{
147e83
-  long i,k;
147e83
-  long p2 = p;
147e83
-  double c,u,z[5];
147e83
-#if 0
147e83
-  double a,v;
147e83
-#endif
147e83
-
147e83
-#define R  radixi.d
147e83
-  if (EX<-44 || (EX==-44 && X[1]
147e83
-     { *y=ZERO; return; }
147e83
-
147e83
-  if      (p2==1) {
147e83
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=ZERO;  z[3]=ZERO;  k=3;}
147e83
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=ZERO;  k=2;}
147e83
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
147e83
-  }
147e83
-  else if (p2==2) {
147e83
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  z[3]=ZERO;  k=3;}
147e83
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  z[3]=X[2];  k=2;}
147e83
-    else              {z[1]=     TWO10;  z[2]=ZERO;  z[3]=X[1];  k=1;}
147e83
-  }
147e83
-  else {
147e83
-    if      (EX==-42) {z[1]=X[1]+TWO10;  z[2]=X[2];  k=3;}
147e83
-    else if (EX==-43) {z[1]=     TWO10;  z[2]=X[1];  k=2;}
147e83
-    else              {z[1]=     TWO10;  z[2]=ZERO;  k=1;}
147e83
-    z[3] = X[k];
147e83
-  }
147e83
-
147e83
-  u = (z[3] + TWO57) - TWO57;
147e83
-  if  (u > z[3])   u -= TWO5;
147e83
-
147e83
-  if (u==z[3]) {
147e83
-    for (i=k+1; i <= p2; i++) {
147e83
-      if (X[i] == ZERO)   continue;
147e83
-      else {z[3] += ONE;   break; }
147e83
-    }
147e83
-  }
147e83
-
147e83
-  c = X[0]*((z[1] + R*(z[2] + R*z[3])) - TWO10);
147e83
-
147e83
-  *y = c*TWOM1032;
147e83
-  return;
147e83
-
147e83
-#undef R
147e83
-}
147e83
-
147e83
-/* Convert a multiple precision number *x into a double precision number *y. */
147e83
-/* The result is correctly rounded to the nearest/even. *x is left unchanged */
147e83
-
147e83
-void __mp_dbl(const mp_no *x, double *y, int p) {
147e83
-#if 0
147e83
-  int i,k;
147e83
-  double a,c,u,v,z[5];
147e83
-#endif
147e83
-
147e83
-  if (X[0] == ZERO)  {*y = ZERO;  return; }
147e83
-
147e83
-  if      (EX> -42)                 norm(x,y,p);
147e83
-  else if (EX==-42 && X[1]>=TWO10)  norm(x,y,p);
147e83
-  else                              denorm(x,y,p);
147e83
-}
147e83
-
147e83
-
147e83
-/* dbl_mp() converts a double precision number x into a multiple precision  */
147e83
-/* number *y. If the precision p is too small the result is truncated. x is */
147e83
-/* left unchanged.                                                          */
147e83
-
147e83
-void __dbl_mp(double x, mp_no *y, int p) {
147e83
-
147e83
-  long i,n;
147e83
-  long p2 = p;
147e83
-  double u;
147e83
-
147e83
-  /* Sign */
147e83
-  if      (x == ZERO)  {Y[0] = ZERO;  return; }
147e83
-  else if (x >  ZERO)   Y[0] = ONE;
147e83
-  else                 {Y[0] = MONE;  x=-x;   }
147e83
-
147e83
-  /* Exponent */
147e83
-  for (EY=ONE; x >= RADIX; EY += ONE)   x *= RADIXI;
147e83
-  for (      ; x <  ONE;   EY -= ONE)   x *= RADIX;
147e83
-
147e83
-  /* Digits */
147e83
-  n=MIN(p2,4);
147e83
-  for (i=1; i<=n; i++) {
147e83
-    u = (x + TWO52) - TWO52;
147e83
-    if (u>x)   u -= ONE;
147e83
-    Y[i] = u;     x -= u;    x *= RADIX; }
147e83
-  for (   ; i<=p2; i++)     Y[i] = ZERO;
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/*  add_magnitudes() adds the magnitudes of *x & *y assuming that           */
147e83
-/*  abs(*x) >= abs(*y) > 0.                                                 */
147e83
-/* The sign of the sum *z is undefined. x&y may overlap but not x&z or y&z. */
147e83
-/* No guard digit is used. The result equals the exact sum, truncated.      */
147e83
-/* *x & *y are left unchanged.                                              */
147e83
-
147e83
-static void add_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  long i,j,k;
147e83
-  long p2 = p;
147e83
-
147e83
-  EZ = EX;
147e83
-
147e83
-  i=p2;    j=p2+ EY - EX;    k=p2+1;
147e83
-
147e83
-  if (j<1)
147e83
-     {__cpy(x,z,p);  return; }
147e83
-  else   Z[k] = ZERO;
147e83
-
147e83
-  for (; j>0; i--,j--) {
147e83
-    Z[k] += X[i] + Y[j];
147e83
-    if (Z[k] >= RADIX) {
147e83
-      Z[k]  -= RADIX;
147e83
-      Z[--k] = ONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  for (; i>0; i--) {
147e83
-    Z[k] += X[i];
147e83
-    if (Z[k] >= RADIX) {
147e83
-      Z[k]  -= RADIX;
147e83
-      Z[--k] = ONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  if (Z[1] == ZERO) {
147e83
-    for (i=1; i<=p2; i++)    Z[i] = Z[i+1]; }
147e83
-  else   EZ += ONE;
147e83
-}
147e83
-
147e83
-
147e83
-/*  sub_magnitudes() subtracts the magnitudes of *x & *y assuming that      */
147e83
-/*  abs(*x) > abs(*y) > 0.                                                  */
147e83
-/* The sign of the difference *z is undefined. x&y may overlap but not x&z  */
147e83
-/* or y&z. One guard digit is used. The error is less than one ulp.         */
147e83
-/* *x & *y are left unchanged.                                              */
147e83
-
147e83
-static void sub_magnitudes(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  long i,j,k;
147e83
-  long p2 = p;
147e83
-
147e83
-  EZ = EX;
147e83
-
147e83
-  if (EX == EY) {
147e83
-    i=j=k=p2;
147e83
-    Z[k] = Z[k+1] = ZERO; }
147e83
-  else {
147e83
-    j= EX - EY;
147e83
-    if (j > p2)  {__cpy(x,z,p);  return; }
147e83
-    else {
147e83
-      i=p2;   j=p2+1-j;   k=p2;
147e83
-      if (Y[j] > ZERO) {
147e83
-        Z[k+1] = RADIX - Y[j--];
147e83
-        Z[k]   = MONE; }
147e83
-      else {
147e83
-        Z[k+1] = ZERO;
147e83
-        Z[k]   = ZERO;   j--;}
147e83
-    }
147e83
-  }
147e83
-
147e83
-  for (; j>0; i--,j--) {
147e83
-    Z[k] += (X[i] - Y[j]);
147e83
-    if (Z[k] < ZERO) {
147e83
-      Z[k]  += RADIX;
147e83
-      Z[--k] = MONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  for (; i>0; i--) {
147e83
-    Z[k] += X[i];
147e83
-    if (Z[k] < ZERO) {
147e83
-      Z[k]  += RADIX;
147e83
-      Z[--k] = MONE; }
147e83
-    else
147e83
-      Z[--k] = ZERO;
147e83
-  }
147e83
-
147e83
-  for (i=1; Z[i] == ZERO; i++) ;
147e83
-  EZ = EZ - i + 1;
147e83
-  for (k=1; i <= p2+1; )
147e83
-    Z[k++] = Z[i++];
147e83
-  for (; k <= p2; )
147e83
-    Z[k++] = ZERO;
147e83
-
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Add two multiple precision numbers. Set *z = *x + *y. x&y may overlap  */
147e83
-/* but not x&z or y&z. One guard digit is used. The error is less than    */
147e83
-/* one ulp. *x & *y are left unchanged.                                   */
147e83
-
147e83
-void __add(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  int n;
147e83
-
147e83
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  return; }
147e83
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);  return; }
147e83
-
147e83
-  if (X[0] == Y[0])   {
147e83
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] = X[0]; }
147e83
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
147e83
-  }
147e83
-  else                       {
147e83
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] = X[0]; }
147e83
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = Y[0]; }
147e83
-    else                      Z[0] = ZERO;
147e83
-  }
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Subtract two multiple precision numbers. *z is set to *x - *y. x&y may */
147e83
-/* overlap but not x&z or y&z. One guard digit is used. The error is      */
147e83
-/* less than one ulp. *x & *y are left unchanged.                         */
147e83
-
147e83
-void __sub(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  int n;
147e83
-
147e83
-  if      (X[0] == ZERO)     {__cpy(y,z,p);  Z[0] = -Z[0];  return; }
147e83
-  else if (Y[0] == ZERO)     {__cpy(x,z,p);                 return; }
147e83
-
147e83
-  if (X[0] != Y[0])    {
147e83
-    if (__acr(x,y,p) > 0)      {add_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
147e83
-    else                     {add_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
147e83
-  }
147e83
-  else                       {
147e83
-    if ((n=__acr(x,y,p)) == 1) {sub_magnitudes(x,y,z,p);  Z[0] =  X[0]; }
147e83
-    else if (n == -1)        {sub_magnitudes(y,x,z,p);  Z[0] = -Y[0]; }
147e83
-    else                      Z[0] = ZERO;
147e83
-  }
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Multiply two multiple precision numbers. *z is set to *x * *y. x&y      */
147e83
-/* may overlap but not x&z or y&z. In case p=1,2,3 the exact result is     */
147e83
-/* truncated to p digits. In case p>3 the error is bounded by 1.001 ulp.   */
147e83
-/* *x & *y are left unchanged.                                             */
147e83
-
147e83
-void __mul(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  long i, i1, i2, j, k, k2;
147e83
-  long p2 = p;
147e83
-  double u, zk, zk2;
147e83
-
147e83
-                      /* Is z=0? */
147e83
-  if (X[0]*Y[0]==ZERO)
147e83
-     { Z[0]=ZERO;  return; }
147e83
-
147e83
-                       /* Multiply, add and carry */
147e83
-  k2 = (p2<3) ? p2+p2 : p2+3;
147e83
-  zk = Z[k2]=ZERO;
147e83
-  for (k=k2; k>1; ) {
147e83
-    if (k > p2)  {i1=k-p2; i2=p2+1; }
147e83
-    else        {i1=1;   i2=k;   }
147e83
-#if 1
147e83
-    /* rearange this inner loop to allow the fmadd instructions to be
147e83
-       independent and execute in parallel on processors that have
147e83
-       dual symetrical FP pipelines.  */
147e83
-    if (i1 < (i2-1))
147e83
-    {
147e83
-	/* make sure we have at least 2 iterations */
147e83
-	if (((i2 - i1) & 1L) == 1L)
147e83
-	{
147e83
-                /* Handle the odd iterations case.  */
147e83
-		zk2 = x->d[i2-1]*y->d[i1];
147e83
-	}
147e83
-	else
147e83
-		zk2 = zero.d;
147e83
-	/* Do two multiply/adds per loop iteration, using independent
147e83
-           accumulators; zk and zk2.  */
147e83
-	for (i=i1,j=i2-1; i
147e83
-	{
147e83
-		zk += x->d[i]*y->d[j];
147e83
-		zk2 += x->d[i+1]*y->d[j-1];
147e83
-	}
147e83
-	zk += zk2; /* final sum.  */
147e83
-    }
147e83
-    else
147e83
-    {
147e83
-        /* Special case when iterations is 1.  */
147e83
-	zk += x->d[i1]*y->d[i1];
147e83
-    }
147e83
-#else
147e83
-    /* The orginal code.  */
147e83
-    for (i=i1,j=i2-1; i
147e83
-#endif
147e83
-
147e83
-    u = (zk + CUTTER)-CUTTER;
147e83
-    if  (u > zk)  u -= RADIX;
147e83
-    Z[k]  = zk - u;
147e83
-    zk = u*RADIXI;
147e83
-    --k;
147e83
-  }
147e83
-  Z[k] = zk;
147e83
-
147e83
-                 /* Is there a carry beyond the most significant digit? */
147e83
-  if (Z[1] == ZERO) {
147e83
-    for (i=1; i<=p2; i++)  Z[i]=Z[i+1];
147e83
-    EZ = EX + EY - 1; }
147e83
-  else
147e83
-    EZ = EX + EY;
147e83
-
147e83
-  Z[0] = X[0] * Y[0];
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Invert a multiple precision number. Set *y = 1 / *x.                     */
147e83
-/* Relative error bound = 1.001*r**(1-p) for p=2, 1.063*r**(1-p) for p=3,   */
147e83
-/* 2.001*r**(1-p) for p>3.                                                  */
147e83
-/* *x=0 is not permissible. *x is left unchanged.                           */
147e83
-
147e83
-void __inv(const mp_no *x, mp_no *y, int p) {
147e83
-  long i;
147e83
-#if 0
147e83
-  int l;
147e83
-#endif
147e83
-  double t;
147e83
-  mp_no z,w;
147e83
-  static const int np1[] = {0,0,0,0,1,2,2,2,2,3,3,3,3,3,3,3,3,3,
147e83
-                            4,4,4,4,4,4,4,4,4,4,4,4,4,4,4};
147e83
-  const mp_no mptwo = {1,{1.0,2.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
147e83
-                         0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
147e83
-
147e83
-  __cpy(x,&z,p);  z.e=0;  __mp_dbl(&z,&t,p);
147e83
-  t=ONE/t;   __dbl_mp(t,y,p);    EY -= EX;
147e83
-
147e83
-  for (i=0; i
147e83
-    __cpy(y,&w,p);
147e83
-    __mul(x,&w,y,p);
147e83
-    __sub(&mptwo,y,&z,p);
147e83
-    __mul(&w,&z,y,p);
147e83
-  }
147e83
-  return;
147e83
-}
147e83
-
147e83
-
147e83
-/* Divide one multiple precision number by another.Set *z = *x / *y. *x & *y */
147e83
-/* are left unchanged. x&y may overlap but not x&z or y&z.                   */
147e83
-/* Relative error bound = 2.001*r**(1-p) for p=2, 2.063*r**(1-p) for p=3     */
147e83
-/* and 3.001*r**(1-p) for p>3. *y=0 is not permissible.                      */
147e83
-
147e83
-void __dvd(const mp_no *x, const mp_no *y, mp_no *z, int p) {
147e83
-
147e83
-  mp_no w;
147e83
-
147e83
-  if (X[0] == ZERO)    Z[0] = ZERO;
147e83
-  else                {__inv(y,&w,p);   __mul(x,&w,z,p);}
147e83
-  return;
147e83
-}
147e83
-- 
147e83
1.7.11.7
147e83