This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.17-583-g6dbe713


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  6dbe713d85fecc1bee99713d745413106af200b7 (commit)
       via  f0ee064b7dcdbde6b28002a63be4b86c86e235b9 (commit)
       via  d569c6eeb48219993063f956e516704281602f7d (commit)
      from  a6a242fe7cc0d7fcac1c9741d8be2ca8c2a5c744 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6dbe713d85fecc1bee99713d745413106af200b7

commit 6dbe713d85fecc1bee99713d745413106af200b7
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Tue Apr 30 14:18:57 2013 +0530

    Format s_sin.c

diff --git a/ChangeLog b/ChangeLog
index afeadd7..9a9be01 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-04-30  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+	* sysdeps/ieee754/dbl-64/s_sin.c: Format code.
+
 	* benchtests/Makefile (bench): Remove slow benchmarks.
 	* benchtests/atan-inputs: Add slow benchmark inputs.
 	* benchtests/bench-modf.c (NUM_VARIANTS): Define.
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index 5038b72..5c388c8 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -66,299 +66,359 @@ extern const union
 } __sincostab attribute_hidden;
 
 static const double
-	  sn3 = -1.66666666666664880952546298448555E-01,
-	  sn5 =  8.33333214285722277379541354343671E-03,
-	  cs2 =  4.99999999999999999999950396842453E-01,
-	  cs4 = -4.16666666666664434524222570944589E-02,
-	  cs6 =  1.38888874007937613028114285595617E-03;
-
-void __dubsin(double x, double dx, double w[]);
-void __docos(double x, double dx, double w[]);
-double __mpsin(double x, double dx);
-double __mpcos(double x, double dx);
-double __mpsin1(double x);
-double __mpcos1(double x);
-static double slow(double x);
-static double slow1(double x);
-static double slow2(double x);
-static double sloww(double x, double dx, double orig);
-static double sloww1(double x, double dx, double orig);
-static double sloww2(double x, double dx, double orig, int n);
-static double bsloww(double x, double dx, double orig, int n);
-static double bsloww1(double x, double dx, double orig, int n);
-static double bsloww2(double x, double dx, double orig, int n);
-int __branred(double x, double *a, double *aa);
-static double cslow2(double x);
-static double csloww(double x, double dx, double orig);
-static double csloww1(double x, double dx, double orig);
-static double csloww2(double x, double dx, double orig, int n);
+  sn3 = -1.66666666666664880952546298448555E-01,
+  sn5 = 8.33333214285722277379541354343671E-03,
+  cs2 = 4.99999999999999999999950396842453E-01,
+  cs4 = -4.16666666666664434524222570944589E-02,
+  cs6 = 1.38888874007937613028114285595617E-03;
+
+void __dubsin (double x, double dx, double w[]);
+void __docos (double x, double dx, double w[]);
+double __mpsin (double x, double dx);
+double __mpcos (double x, double dx);
+double __mpsin1 (double x);
+double __mpcos1 (double x);
+static double slow (double x);
+static double slow1 (double x);
+static double slow2 (double x);
+static double sloww (double x, double dx, double orig);
+static double sloww1 (double x, double dx, double orig);
+static double sloww2 (double x, double dx, double orig, int n);
+static double bsloww (double x, double dx, double orig, int n);
+static double bsloww1 (double x, double dx, double orig, int n);
+static double bsloww2 (double x, double dx, double orig, int n);
+int __branred (double x, double *a, double *aa);
+static double cslow2 (double x);
+static double csloww (double x, double dx, double orig);
+static double csloww1 (double x, double dx, double orig);
+static double csloww2 (double x, double dx, double orig, int n);
+
 /*******************************************************************/
 /* An ultimate sin routine. Given an IEEE double machine number x   */
 /* it computes the correctly rounded (to nearest) value of sin(x)  */
 /*******************************************************************/
 double
 SECTION
-__sin(double x){
-	double xx,res,t,cor,y,s,c,sn,ssn,cs,ccs,xn,a,da,db,eps,xn1,xn2;
-	mynumber u,v;
-	int4 k,m,n;
-	double retval = 0;
-
-	SET_RESTORE_ROUND_53BIT (FE_TONEAREST);
-
-	u.x = x;
-	m = u.i[HIGH_HALF];
-	k = 0x7fffffff&m;              /* no sign           */
-	if (k < 0x3e500000)            /* if x->0 =>sin(x)=x */
-	  { retval = x; goto ret; }
+__sin (double x)
+{
+  double xx, res, t, cor, y, s, c, sn, ssn, cs, ccs, xn, a, da, db, eps, xn1,
+    xn2;
+  mynumber u, v;
+  int4 k, m, n;
+  double retval = 0;
+
+  SET_RESTORE_ROUND_53BIT (FE_TONEAREST);
+
+  u.x = x;
+  m = u.i[HIGH_HALF];
+  k = 0x7fffffff & m;		/* no sign           */
+  if (k < 0x3e500000)		/* if x->0 =>sin(x)=x */
+    {
+      retval = x;
+      goto ret;
+    }
  /*---------------------------- 2^-26 < |x|< 0.25 ----------------------*/
-	else  if (k < 0x3fd00000){
-	  xx = x*x;
-	  /*Taylor series */
-	  t = ((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + s1.x)*(xx*x);
-	  res = x+t;
-	  cor = (x-res)+t;
-	  retval = (res == res + 1.07*cor)? res : slow(x);
-	  goto ret;
-	}    /*  else  if (k < 0x3fd00000)    */
+  else if (k < 0x3fd00000)
+    {
+      xx = x * x;
+      /*Taylor series.  */
+      t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx + s1.x)
+	   * (xx * x));
+      res = x + t;
+      cor = (x - res) + t;
+      retval = (res == res + 1.07 * cor) ? res : slow (x);
+      goto ret;
+    }				/*  else  if (k < 0x3fd00000)    */
 /*---------------------------- 0.25<|x|< 0.855469---------------------- */
-	else if (k < 0x3feb6000)  {
-	  u.x=(m>0)?big.x+x:big.x-x;
-	  y=(m>0)?x-(u.x-big.x):x+(u.x-big.x);
-	  xx=y*y;
-	  s = y + y*xx*(sn3 +xx*sn5);
-	  c = xx*(cs2 +xx*(cs4 + xx*cs6));
-	  k=u.i[LOW_HALF]<<2;
-	  sn=(m>0)?__sincostab.x[k]:-__sincostab.x[k];
-	  ssn=(m>0)?__sincostab.x[k+1]:-__sincostab.x[k+1];
-	  cs=__sincostab.x[k+2];
-	  ccs=__sincostab.x[k+3];
-	  cor=(ssn+s*ccs-sn*c)+cs*s;
-	  res=sn+cor;
-	  cor=(sn-res)+cor;
-	  retval = (res==res+1.096*cor)? res : slow1(x);
-	  goto ret;
-	}    /*   else  if (k < 0x3feb6000)    */
+  else if (k < 0x3feb6000)
+    {
+      u.x = (m > 0) ? big.x + x : big.x - x;
+      y = (m > 0) ? x - (u.x - big.x) : x + (u.x - big.x);
+      xx = y * y;
+      s = y + y * xx * (sn3 + xx * sn5);
+      c = xx * (cs2 + xx * (cs4 + xx * cs6));
+      k = u.i[LOW_HALF] << 2;
+      sn = (m > 0) ? __sincostab.x[k] : -__sincostab.x[k];
+      ssn = (m > 0) ? __sincostab.x[k + 1] : -__sincostab.x[k + 1];
+      cs = __sincostab.x[k + 2];
+      ccs = __sincostab.x[k + 3];
+      cor = (ssn + s * ccs - sn * c) + cs * s;
+      res = sn + cor;
+      cor = (sn - res) + cor;
+      retval = (res == res + 1.096 * cor) ? res : slow1 (x);
+      goto ret;
+    }				/*   else  if (k < 0x3feb6000)    */
 
 /*----------------------- 0.855469  <|x|<2.426265  ----------------------*/
-	else if (k <  0x400368fd ) {
-
-	  y = (m>0)? hp0.x-x:hp0.x+x;
-	  if (y>=0) {
-	    u.x = big.x+y;
-	    y = (y-(u.x-big.x))+hp1.x;
-	  }
-	  else {
-	    u.x = big.x-y;
-	    y = (-hp1.x) - (y+(u.x-big.x));
-	  }
-	  xx=y*y;
-	  s = y + y*xx*(sn3 +xx*sn5);
-	  c = xx*(cs2 +xx*(cs4 + xx*cs6));
-	  k=u.i[LOW_HALF]<<2;
-	  sn=__sincostab.x[k];
-	  ssn=__sincostab.x[k+1];
-	  cs=__sincostab.x[k+2];
-	  ccs=__sincostab.x[k+3];
-	  cor=(ccs-s*ssn-cs*c)-sn*s;
-	  res=cs+cor;
-	  cor=(cs-res)+cor;
-	  retval = (res==res+1.020*cor)? ((m>0)?res:-res) : slow2(x);
-	  goto ret;
-	} /*   else  if (k < 0x400368fd)    */
+  else if (k < 0x400368fd)
+    {
+
+      y = (m > 0) ? hp0.x - x : hp0.x + x;
+      if (y >= 0)
+	{
+	  u.x = big.x + y;
+	  y = (y - (u.x - big.x)) + hp1.x;
+	}
+      else
+	{
+	  u.x = big.x - y;
+	  y = (-hp1.x) - (y + (u.x - big.x));
+	}
+      xx = y * y;
+      s = y + y * xx * (sn3 + xx * sn5);
+      c = xx * (cs2 + xx * (cs4 + xx * cs6));
+      k = u.i[LOW_HALF] << 2;
+      sn = __sincostab.x[k];
+      ssn = __sincostab.x[k + 1];
+      cs = __sincostab.x[k + 2];
+      ccs = __sincostab.x[k + 3];
+      cor = (ccs - s * ssn - cs * c) - sn * s;
+      res = cs + cor;
+      cor = (cs - res) + cor;
+      retval = (res == res + 1.020 * cor) ? ((m > 0) ? res : -res) : slow2 (x);
+      goto ret;
+    }				/*   else  if (k < 0x400368fd)    */
 
 /*-------------------------- 2.426265<|x|< 105414350 ----------------------*/
-	else if (k < 0x419921FB ) {
-	  t = (x*hpinv.x + toint.x);
-	  xn = t - toint.x;
-	  v.x = t;
-	  y = (x - xn*mp1.x) - xn*mp2.x;
-	  n =v.i[LOW_HALF]&3;
-	  da = xn*mp3.x;
-	  a=y-da;
-	  da = (y-a)-da;
-	  eps = ABS(x)*1.2e-30;
-
-	  switch (n) { /* quarter of unit circle */
-	  case 0:
-	  case 2:
-	    xx = a*a;
-	    if (n) {a=-a;da=-da;}
-	    if (xx < 0.01588) {
-		      /*Taylor series */
-	      t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + s1.x)*a - 0.5*da)*xx+da;
-	      res = a+t;
-	      cor = (a-res)+t;
-	      cor = (cor>0)? 1.02*cor+eps : 1.02*cor -eps;
-	      retval = (res == res + cor)? res : sloww(a,da,x);
+  else if (k < 0x419921FB)
+    {
+      t = (x * hpinv.x + toint.x);
+      xn = t - toint.x;
+      v.x = t;
+      y = (x - xn * mp1.x) - xn * mp2.x;
+      n = v.i[LOW_HALF] & 3;
+      da = xn * mp3.x;
+      a = y - da;
+      da = (y - a) - da;
+      eps = ABS (x) * 1.2e-30;
+
+      switch (n)
+	{			/* quarter of unit circle */
+	case 0:
+	case 2:
+	  xx = a * a;
+	  if (n)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  if (xx < 0.01588)
+	    {
+	      /*Taylor series */
+	      t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx
+		    + s1.x) * a - 0.5 * da) * xx + da;
+	      res = a + t;
+	      cor = (a - res) + t;
+	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
+	      retval = (res == res + cor) ? res : sloww (a, da, x);
 	      goto ret;
 	    }
-	    else  {
-	      if (a>0)
-		{m=1;t=a;db=da;}
+	  else
+	    {
+	      if (a > 0)
+		{
+		  m = 1;
+		  t = a;
+		  db = da;
+		}
 	      else
-		{m=0;t=-a;db=-da;}
-	      u.x=big.x+t;
-	      y=t-(u.x-big.x);
-	      xx=y*y;
-	      s = y + (db+y*xx*(sn3 +xx*sn5));
-	      c = y*db+xx*(cs2 +xx*(cs4 + xx*cs6));
-	      k=u.i[LOW_HALF]<<2;
-	      sn=__sincostab.x[k];
-	      ssn=__sincostab.x[k+1];
-	      cs=__sincostab.x[k+2];
-	      ccs=__sincostab.x[k+3];
-	      cor=(ssn+s*ccs-sn*c)+cs*s;
-	      res=sn+cor;
-	      cor=(sn-res)+cor;
-	      cor = (cor>0)? 1.035*cor+eps : 1.035*cor-eps;
-	      retval = (res==res+cor)? ((m)?res:-res) : sloww1(a,da,x);
+		{
+		  m = 0;
+		  t = -a;
+		  db = -da;
+		}
+	      u.x = big.x + t;
+	      y = t - (u.x - big.x);
+	      xx = y * y;
+	      s = y + (db + y * xx * (sn3 + xx * sn5));
+	      c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
+	      k = u.i[LOW_HALF] << 2;
+	      sn = __sincostab.x[k];
+	      ssn = __sincostab.x[k + 1];
+	      cs = __sincostab.x[k + 2];
+	      ccs = __sincostab.x[k + 3];
+	      cor = (ssn + s * ccs - sn * c) + cs * s;
+	      res = sn + cor;
+	      cor = (sn - res) + cor;
+	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
+	      retval = ((res == res + cor) ? ((m) ? res : -res)
+			: sloww1 (a, da, x));
 	      goto ret;
 	    }
-	    break;
-
-	  case 1:
-	  case 3:
-	    if (a<0)
-	      {a=-a;da=-da;}
-	    u.x=big.x+a;
-	    y=a-(u.x-big.x)+da;
-	    xx=y*y;
-	    k=u.i[LOW_HALF]<<2;
-	    sn=__sincostab.x[k];
-	    ssn=__sincostab.x[k+1];
-	    cs=__sincostab.x[k+2];
-	    ccs=__sincostab.x[k+3];
-	    s = y + y*xx*(sn3 +xx*sn5);
-	    c = xx*(cs2 +xx*(cs4 + xx*cs6));
-	    cor=(ccs-s*ssn-cs*c)-sn*s;
-	    res=cs+cor;
-	    cor=(cs-res)+cor;
-	    cor = (cor>0)? 1.025*cor+eps : 1.025*cor-eps;
-	    retval = (res==res+cor)? ((n&2)?-res:res) : sloww2(a,da,x,n);
-	    goto ret;
-
-	    break;
-
-	  }
-
-	}    /*   else  if (k <  0x419921FB )    */
+	  break;
+
+	case 1:
+	case 3:
+	  if (a < 0)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  u.x = big.x + a;
+	  y = a - (u.x - big.x) + da;
+	  xx = y * y;
+	  k = u.i[LOW_HALF] << 2;
+	  sn = __sincostab.x[k];
+	  ssn = __sincostab.x[k + 1];
+	  cs = __sincostab.x[k + 2];
+	  ccs = __sincostab.x[k + 3];
+	  s = y + y * xx * (sn3 + xx * sn5);
+	  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+	  cor = (ccs - s * ssn - cs * c) - sn * s;
+	  res = cs + cor;
+	  cor = (cs - res) + cor;
+	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
+	  retval = ((res == res + cor) ? ((n & 2) ? -res : res)
+		    : sloww2 (a, da, x, n));
+	  goto ret;
+
+	  break;
+	}
+
+    }				/*   else  if (k <  0x419921FB )    */
 
 /*---------------------105414350 <|x|< 281474976710656 --------------------*/
-	else if (k < 0x42F00000 ) {
-	  t = (x*hpinv.x + toint.x);
-	  xn = t - toint.x;
-	  v.x = t;
-	  xn1 = (xn+8.0e22)-8.0e22;
-	  xn2 = xn - xn1;
-	  y = ((((x - xn1*mp1.x) - xn1*mp2.x)-xn2*mp1.x)-xn2*mp2.x);
-	  n =v.i[LOW_HALF]&3;
-	  da = xn1*pp3.x;
-	  t=y-da;
-	  da = (y-t)-da;
-	  da = (da - xn2*pp3.x) -xn*pp4.x;
-	  a = t+da;
-	  da = (t-a)+da;
-	  eps = 1.0e-24;
-
-	  switch (n) {
-	  case 0:
-	  case 2:
-	    xx = a*a;
-	    if (n) {a=-a;da=-da;}
-	    if (xx < 0.01588) {
+  else if (k < 0x42F00000)
+    {
+      t = (x * hpinv.x + toint.x);
+      xn = t - toint.x;
+      v.x = t;
+      xn1 = (xn + 8.0e22) - 8.0e22;
+      xn2 = xn - xn1;
+      y = ((((x - xn1 * mp1.x) - xn1 * mp2.x) - xn2 * mp1.x) - xn2 * mp2.x);
+      n = v.i[LOW_HALF] & 3;
+      da = xn1 * pp3.x;
+      t = y - da;
+      da = (y - t) - da;
+      da = (da - xn2 * pp3.x) - xn * pp4.x;
+      a = t + da;
+      da = (t - a) + da;
+      eps = 1.0e-24;
+
+      switch (n)
+	{
+	case 0:
+	case 2:
+	  xx = a * a;
+	  if (n)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  if (xx < 0.01588)
+	    {
 	      /* Taylor series */
-	      t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + s1.x)*a - 0.5*da)*xx+da;
-	      res = a+t;
-	      cor = (a-res)+t;
-	      cor = (cor>0)? 1.02*cor+eps : 1.02*cor -eps;
-	      retval = (res == res + cor)? res : bsloww(a,da,x,n);
+	      t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx
+		    + s1.x) * a - 0.5 * da) * xx + da;
+	      res = a + t;
+	      cor = (a - res) + t;
+	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
+	      retval = (res == res + cor) ? res : bsloww (a, da, x, n);
 	      goto ret;
 	    }
-	    else  {
-	      if (a>0) {m=1;t=a;db=da;}
-	      else {m=0;t=-a;db=-da;}
-	      u.x=big.x+t;
-	      y=t-(u.x-big.x);
-	      xx=y*y;
-	      s = y + (db+y*xx*(sn3 +xx*sn5));
-	      c = y*db+xx*(cs2 +xx*(cs4 + xx*cs6));
-	      k=u.i[LOW_HALF]<<2;
-	      sn=__sincostab.x[k];
-	      ssn=__sincostab.x[k+1];
-	      cs=__sincostab.x[k+2];
-	      ccs=__sincostab.x[k+3];
-	      cor=(ssn+s*ccs-sn*c)+cs*s;
-	      res=sn+cor;
-	      cor=(sn-res)+cor;
-	      cor = (cor>0)? 1.035*cor+eps : 1.035*cor-eps;
-	      retval = (res==res+cor)? ((m)?res:-res) : bsloww1(a,da,x,n);
+	  else
+	    {
+	      if (a > 0)
+		{
+		  m = 1;
+		  t = a;
+		  db = da;
+		}
+	      else
+		{
+		  m = 0;
+		  t = -a;
+		  db = -da;
+		}
+	      u.x = big.x + t;
+	      y = t - (u.x - big.x);
+	      xx = y * y;
+	      s = y + (db + y * xx * (sn3 + xx * sn5));
+	      c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
+	      k = u.i[LOW_HALF] << 2;
+	      sn = __sincostab.x[k];
+	      ssn = __sincostab.x[k + 1];
+	      cs = __sincostab.x[k + 2];
+	      ccs = __sincostab.x[k + 3];
+	      cor = (ssn + s * ccs - sn * c) + cs * s;
+	      res = sn + cor;
+	      cor = (sn - res) + cor;
+	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
+	      retval = ((res == res + cor) ? ((m) ? res : -res)
+			: bsloww1 (a, da, x, n));
 	      goto ret;
-		   }
-	    break;
-
-	  case 1:
-	  case 3:
-	    if (a<0)
-	      {a=-a;da=-da;}
-	    u.x=big.x+a;
-	    y=a-(u.x-big.x)+da;
-	    xx=y*y;
-	    k=u.i[LOW_HALF]<<2;
-	    sn=__sincostab.x[k];
-	    ssn=__sincostab.x[k+1];
-	    cs=__sincostab.x[k+2];
-	    ccs=__sincostab.x[k+3];
-	    s = y + y*xx*(sn3 +xx*sn5);
-	    c = xx*(cs2 +xx*(cs4 + xx*cs6));
-	    cor=(ccs-s*ssn-cs*c)-sn*s;
-	    res=cs+cor;
-	    cor=(cs-res)+cor;
-	    cor = (cor>0)? 1.025*cor+eps : 1.025*cor-eps;
-	    retval = (res==res+cor)? ((n&2)?-res:res) : bsloww2(a,da,x,n);
-	    goto ret;
-
-	    break;
-
-	  }
-
-	}    /*   else  if (k <  0x42F00000 )   */
+	    }
+	  break;
+
+	case 1:
+	case 3:
+	  if (a < 0)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  u.x = big.x + a;
+	  y = a - (u.x - big.x) + da;
+	  xx = y * y;
+	  k = u.i[LOW_HALF] << 2;
+	  sn = __sincostab.x[k];
+	  ssn = __sincostab.x[k + 1];
+	  cs = __sincostab.x[k + 2];
+	  ccs = __sincostab.x[k + 3];
+	  s = y + y * xx * (sn3 + xx * sn5);
+	  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+	  cor = (ccs - s * ssn - cs * c) - sn * s;
+	  res = cs + cor;
+	  cor = (cs - res) + cor;
+	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
+	  retval = ((res == res + cor) ? ((n & 2) ? -res : res)
+		    : bsloww2 (a, da, x, n));
+	  goto ret;
+
+	  break;
+	}
+    }				/*   else  if (k <  0x42F00000 )   */
 
 /* -----------------281474976710656 <|x| <2^1024----------------------------*/
-	else if (k < 0x7ff00000) {
-
-	  n = __branred(x,&a,&da);
-	  switch (n) {
-	  case 0:
-	    if (a*a < 0.01588) retval = bsloww(a,da,x,n);
-	    else retval = bsloww1(a,da,x,n);
-	    goto ret;
-	    break;
-	  case 2:
-	    if (a*a < 0.01588) retval = bsloww(-a,-da,x,n);
-	    else retval = bsloww1(-a,-da,x,n);
-	    goto ret;
-	    break;
-
-	  case 1:
-	  case 3:
-	    retval = bsloww2(a,da,x,n);
-	    goto ret;
-	    break;
-	  }
-
-	}    /*   else  if (k <  0x7ff00000 )    */
+  else if (k < 0x7ff00000)
+    {
+      n = __branred (x, &a, &da);
+      switch (n)
+	{
+	case 0:
+	  if (a * a < 0.01588)
+	    retval = bsloww (a, da, x, n);
+	  else
+	    retval = bsloww1 (a, da, x, n);
+	  goto ret;
+	  break;
+	case 2:
+	  if (a * a < 0.01588)
+	    retval = bsloww (-a, -da, x, n);
+	  else
+	    retval = bsloww1 (-a, -da, x, n);
+	  goto ret;
+	  break;
 
-/*--------------------- |x| > 2^1024 ----------------------------------*/
-	else {
-	  if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
-	    __set_errno (EDOM);
-	  retval = x / x;
+	case 1:
+	case 3:
+	  retval = bsloww2 (a, da, x, n);
 	  goto ret;
+	  break;
 	}
+    }				/*   else  if (k <  0x7ff00000 )    */
+
+/*--------------------- |x| > 2^1024 ----------------------------------*/
+  else
+    {
+      if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
+	__set_errno (EDOM);
+      retval = x / x;
+      goto ret;
+    }
 
- ret:
-	return retval;
+ret:
+  return retval;
 }
 
 
@@ -369,11 +429,12 @@ __sin(double x){
 
 double
 SECTION
-__cos(double x)
+__cos (double x)
 {
-  double y,xx,res,t,cor,s,c,sn,ssn,cs,ccs,xn,a,da,db,eps,xn1,xn2;
-  mynumber u,v;
-  int4 k,m,n;
+  double y, xx, res, t, cor, s, c, sn, ssn, cs, ccs, xn, a, da, db, eps, xn1,
+    xn2;
+  mynumber u, v;
+  int4 k, m, n;
 
   double retval = 0;
 
@@ -381,251 +442,318 @@ __cos(double x)
 
   u.x = x;
   m = u.i[HIGH_HALF];
-  k = 0x7fffffff&m;
-
-  if (k < 0x3e400000 ) { retval = 1.0; goto ret; } /* |x|<2^-27 => cos(x)=1 */
-
-  else if (k < 0x3feb6000 ) {/* 2^-27 < |x| < 0.855469 */
-    y=ABS(x);
-    u.x = big.x+y;
-    y = y-(u.x-big.x);
-    xx=y*y;
-    s = y + y*xx*(sn3 +xx*sn5);
-    c = xx*(cs2 +xx*(cs4 + xx*cs6));
-    k=u.i[LOW_HALF]<<2;
-    sn=__sincostab.x[k];
-    ssn=__sincostab.x[k+1];
-    cs=__sincostab.x[k+2];
-    ccs=__sincostab.x[k+3];
-    cor=(ccs-s*ssn-cs*c)-sn*s;
-    res=cs+cor;
-    cor=(cs-res)+cor;
-    retval = (res==res+1.020*cor)? res : cslow2(x);
-    goto ret;
-
-}    /*   else  if (k < 0x3feb6000)    */
-
-  else if (k <  0x400368fd ) {/* 0.855469  <|x|<2.426265  */;
-    y=hp0.x-ABS(x);
-    a=y+hp1.x;
-    da=(y-a)+hp1.x;
-    xx=a*a;
-    if (xx < 0.01588) {
-      t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + s1.x)*a - 0.5*da)*xx+da;
-      res = a+t;
-      cor = (a-res)+t;
-      cor = (cor>0)? 1.02*cor+1.0e-31 : 1.02*cor -1.0e-31;
-      retval = (res == res + cor)? res : csloww(a,da,x);
-      goto ret;
-    }
-    else  {
-      if (a>0) {m=1;t=a;db=da;}
-      else {m=0;t=-a;db=-da;}
-      u.x=big.x+t;
-      y=t-(u.x-big.x);
-      xx=y*y;
-      s = y + (db+y*xx*(sn3 +xx*sn5));
-      c = y*db+xx*(cs2 +xx*(cs4 + xx*cs6));
-      k=u.i[LOW_HALF]<<2;
-      sn=__sincostab.x[k];
-      ssn=__sincostab.x[k+1];
-      cs=__sincostab.x[k+2];
-      ccs=__sincostab.x[k+3];
-      cor=(ssn+s*ccs-sn*c)+cs*s;
-      res=sn+cor;
-      cor=(sn-res)+cor;
-      cor = (cor>0)? 1.035*cor+1.0e-31 : 1.035*cor-1.0e-31;
-      retval = (res==res+cor)? ((m)?res:-res) : csloww1(a,da,x);
-      goto ret;
-}
+  k = 0x7fffffff & m;
 
-}    /*   else  if (k < 0x400368fd)    */
-
-
-  else if (k < 0x419921FB ) {/* 2.426265<|x|< 105414350 */
-    t = (x*hpinv.x + toint.x);
-    xn = t - toint.x;
-    v.x = t;
-    y = (x - xn*mp1.x) - xn*mp2.x;
-    n =v.i[LOW_HALF]&3;
-    da = xn*mp3.x;
-    a=y-da;
-    da = (y-a)-da;
-    eps = ABS(x)*1.2e-30;
-
-    switch (n) {
-    case 1:
-    case 3:
-      xx = a*a;
-      if (n == 1) {a=-a;da=-da;}
-      if (xx < 0.01588) {
-	t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + s1.x)*a - 0.5*da)*xx+da;
-	res = a+t;
-	cor = (a-res)+t;
-	cor = (cor>0)? 1.02*cor+eps : 1.02*cor -eps;
-	retval = (res == res + cor)? res : csloww(a,da,x);
-	goto ret;
-      }
-      else  {
-	if (a>0) {m=1;t=a;db=da;}
-	else {m=0;t=-a;db=-da;}
-	u.x=big.x+t;
-	y=t-(u.x-big.x);
-	xx=y*y;
-	s = y + (db+y*xx*(sn3 +xx*sn5));
-	c = y*db+xx*(cs2 +xx*(cs4 + xx*cs6));
-	k=u.i[LOW_HALF]<<2;
-	sn=__sincostab.x[k];
-	ssn=__sincostab.x[k+1];
-	cs=__sincostab.x[k+2];
-	ccs=__sincostab.x[k+3];
-	cor=(ssn+s*ccs-sn*c)+cs*s;
-	res=sn+cor;
-	cor=(sn-res)+cor;
-	cor = (cor>0)? 1.035*cor+eps : 1.035*cor-eps;
-	retval = (res==res+cor)? ((m)?res:-res) : csloww1(a,da,x);
-	goto ret;
-      }
-      break;
-
-  case 0:
-    case 2:
-      if (a<0) {a=-a;da=-da;}
-      u.x=big.x+a;
-      y=a-(u.x-big.x)+da;
-      xx=y*y;
-      k=u.i[LOW_HALF]<<2;
-      sn=__sincostab.x[k];
-      ssn=__sincostab.x[k+1];
-      cs=__sincostab.x[k+2];
-      ccs=__sincostab.x[k+3];
-      s = y + y*xx*(sn3 +xx*sn5);
-      c = xx*(cs2 +xx*(cs4 + xx*cs6));
-      cor=(ccs-s*ssn-cs*c)-sn*s;
-      res=cs+cor;
-      cor=(cs-res)+cor;
-      cor = (cor>0)? 1.025*cor+eps : 1.025*cor-eps;
-      retval = (res==res+cor)? ((n)?-res:res) : csloww2(a,da,x,n);
+  if (k < 0x3e400000)
+    {
+      retval = 1.0;
+      goto ret;
+    }				/* |x|<2^-27 => cos(x)=1 */
+
+  else if (k < 0x3feb6000)
+    {				/* 2^-27 < |x| < 0.855469 */
+      y = ABS (x);
+      u.x = big.x + y;
+      y = y - (u.x - big.x);
+      xx = y * y;
+      s = y + y * xx * (sn3 + xx * sn5);
+      c = xx * (cs2 + xx * (cs4 + xx * cs6));
+      k = u.i[LOW_HALF] << 2;
+      sn = __sincostab.x[k];
+      ssn = __sincostab.x[k + 1];
+      cs = __sincostab.x[k + 2];
+      ccs = __sincostab.x[k + 3];
+      cor = (ccs - s * ssn - cs * c) - sn * s;
+      res = cs + cor;
+      cor = (cs - res) + cor;
+      retval = (res == res + 1.020 * cor) ? res : cslow2 (x);
       goto ret;
+    }				/*   else  if (k < 0x3feb6000)    */
+
+  else if (k < 0x400368fd)
+    { /* 0.855469  <|x|<2.426265  */ ;
+      y = hp0.x - ABS (x);
+      a = y + hp1.x;
+      da = (y - a) + hp1.x;
+      xx = a * a;
+      if (xx < 0.01588)
+	{
+	  t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx + s1.x)
+	       * a - 0.5 * da) * xx + da;
+	  res = a + t;
+	  cor = (a - res) + t;
+	  cor = (cor > 0) ? 1.02 * cor + 1.0e-31 : 1.02 * cor - 1.0e-31;
+	  retval = (res == res + cor) ? res : csloww (a, da, x);
+	  goto ret;
+	}
+      else
+	{
+	  if (a > 0)
+	    {
+	      m = 1;
+	      t = a;
+	      db = da;
+	    }
+	  else
+	    {
+	      m = 0;
+	      t = -a;
+	      db = -da;
+	    }
+	  u.x = big.x + t;
+	  y = t - (u.x - big.x);
+	  xx = y * y;
+	  s = y + (db + y * xx * (sn3 + xx * sn5));
+	  c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
+	  k = u.i[LOW_HALF] << 2;
+	  sn = __sincostab.x[k];
+	  ssn = __sincostab.x[k + 1];
+	  cs = __sincostab.x[k + 2];
+	  ccs = __sincostab.x[k + 3];
+	  cor = (ssn + s * ccs - sn * c) + cs * s;
+	  res = sn + cor;
+	  cor = (sn - res) + cor;
+	  cor = (cor > 0) ? 1.035 * cor + 1.0e-31 : 1.035 * cor - 1.0e-31;
+	  retval = ((res == res + cor) ? ((m) ? res : -res)
+		    : csloww1 (a, da, x));
+	  goto ret;
+	}
 
-	   break;
+    }				/*   else  if (k < 0x400368fd)    */
 
-    }
 
-  }    /*   else  if (k <  0x419921FB )    */
-
-
-  else if (k < 0x42F00000 ) {
-    t = (x*hpinv.x + toint.x);
-    xn = t - toint.x;
-    v.x = t;
-    xn1 = (xn+8.0e22)-8.0e22;
-    xn2 = xn - xn1;
-    y = ((((x - xn1*mp1.x) - xn1*mp2.x)-xn2*mp1.x)-xn2*mp2.x);
-    n =v.i[LOW_HALF]&3;
-    da = xn1*pp3.x;
-    t=y-da;
-    da = (y-t)-da;
-    da = (da - xn2*pp3.x) -xn*pp4.x;
-    a = t+da;
-    da = (t-a)+da;
-    eps = 1.0e-24;
-
-    switch (n) {
-    case 1:
-    case 3:
-      xx = a*a;
-      if (n==1) {a=-a;da=-da;}
-      if (xx < 0.01588) {
-	t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + s1.x)*a - 0.5*da)*xx+da;
-	res = a+t;
-	cor = (a-res)+t;
-	cor = (cor>0)? 1.02*cor+eps : 1.02*cor -eps;
-	retval = (res == res + cor)? res : bsloww(a,da,x,n);
-	goto ret;
-      }
-      else  {
-	if (a>0) {m=1;t=a;db=da;}
-	else {m=0;t=-a;db=-da;}
-	u.x=big.x+t;
-	y=t-(u.x-big.x);
-	xx=y*y;
-	s = y + (db+y*xx*(sn3 +xx*sn5));
-	c = y*db+xx*(cs2 +xx*(cs4 + xx*cs6));
-	k=u.i[LOW_HALF]<<2;
-	sn=__sincostab.x[k];
-	ssn=__sincostab.x[k+1];
-	cs=__sincostab.x[k+2];
-	ccs=__sincostab.x[k+3];
-	cor=(ssn+s*ccs-sn*c)+cs*s;
-	res=sn+cor;
-	cor=(sn-res)+cor;
-	cor = (cor>0)? 1.035*cor+eps : 1.035*cor-eps;
-	retval = (res==res+cor)? ((m)?res:-res) : bsloww1(a,da,x,n);
-	goto ret;
-      }
-      break;
-
-    case 0:
-    case 2:
-      if (a<0) {a=-a;da=-da;}
-      u.x=big.x+a;
-      y=a-(u.x-big.x)+da;
-      xx=y*y;
-      k=u.i[LOW_HALF]<<2;
-      sn=__sincostab.x[k];
-      ssn=__sincostab.x[k+1];
-      cs=__sincostab.x[k+2];
-      ccs=__sincostab.x[k+3];
-      s = y + y*xx*(sn3 +xx*sn5);
-      c = xx*(cs2 +xx*(cs4 + xx*cs6));
-      cor=(ccs-s*ssn-cs*c)-sn*s;
-      res=cs+cor;
-      cor=(cs-res)+cor;
-      cor = (cor>0)? 1.025*cor+eps : 1.025*cor-eps;
-      retval = (res==res+cor)? ((n)?-res:res) : bsloww2(a,da,x,n);
-      goto ret;
-      break;
+  else if (k < 0x419921FB)
+    {				/* 2.426265<|x|< 105414350 */
+      t = (x * hpinv.x + toint.x);
+      xn = t - toint.x;
+      v.x = t;
+      y = (x - xn * mp1.x) - xn * mp2.x;
+      n = v.i[LOW_HALF] & 3;
+      da = xn * mp3.x;
+      a = y - da;
+      da = (y - a) - da;
+      eps = ABS (x) * 1.2e-30;
+
+      switch (n)
+	{
+	case 1:
+	case 3:
+	  xx = a * a;
+	  if (n == 1)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  if (xx < 0.01588)
+	    {
+	      t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx
+		    + s1.x) * a - 0.5 * da) * xx + da;
+	      res = a + t;
+	      cor = (a - res) + t;
+	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
+	      retval = (res == res + cor) ? res : csloww (a, da, x);
+	      goto ret;
+	    }
+	  else
+	    {
+	      if (a > 0)
+		{
+		  m = 1;
+		  t = a;
+		  db = da;
+		}
+	      else
+		{
+		  m = 0;
+		  t = -a;
+		  db = -da;
+		}
+	      u.x = big.x + t;
+	      y = t - (u.x - big.x);
+	      xx = y * y;
+	      s = y + (db + y * xx * (sn3 + xx * sn5));
+	      c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
+	      k = u.i[LOW_HALF] << 2;
+	      sn = __sincostab.x[k];
+	      ssn = __sincostab.x[k + 1];
+	      cs = __sincostab.x[k + 2];
+	      ccs = __sincostab.x[k + 3];
+	      cor = (ssn + s * ccs - sn * c) + cs * s;
+	      res = sn + cor;
+	      cor = (sn - res) + cor;
+	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
+	      retval = ((res == res + cor) ? ((m) ? res : -res)
+			: csloww1 (a, da, x));
+	      goto ret;
+	    }
+	  break;
+
+	case 0:
+	case 2:
+	  if (a < 0)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  u.x = big.x + a;
+	  y = a - (u.x - big.x) + da;
+	  xx = y * y;
+	  k = u.i[LOW_HALF] << 2;
+	  sn = __sincostab.x[k];
+	  ssn = __sincostab.x[k + 1];
+	  cs = __sincostab.x[k + 2];
+	  ccs = __sincostab.x[k + 3];
+	  s = y + y * xx * (sn3 + xx * sn5);
+	  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+	  cor = (ccs - s * ssn - cs * c) - sn * s;
+	  res = cs + cor;
+	  cor = (cs - res) + cor;
+	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
+	  retval = ((res == res + cor) ? ((n) ? -res : res)
+		    : csloww2 (a, da, x, n));
+	  goto ret;
 
-    }
+	  break;
+	}
+    }				/*   else  if (k <  0x419921FB )    */
 
-  }    /*   else  if (k <  0x42F00000 )    */
+  else if (k < 0x42F00000)
+    {
+      t = (x * hpinv.x + toint.x);
+      xn = t - toint.x;
+      v.x = t;
+      xn1 = (xn + 8.0e22) - 8.0e22;
+      xn2 = xn - xn1;
+      y = ((((x - xn1 * mp1.x) - xn1 * mp2.x) - xn2 * mp1.x) - xn2 * mp2.x);
+      n = v.i[LOW_HALF] & 3;
+      da = xn1 * pp3.x;
+      t = y - da;
+      da = (y - t) - da;
+      da = (da - xn2 * pp3.x) - xn * pp4.x;
+      a = t + da;
+      da = (t - a) + da;
+      eps = 1.0e-24;
+
+      switch (n)
+	{
+	case 1:
+	case 3:
+	  xx = a * a;
+	  if (n == 1)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  if (xx < 0.01588)
+	    {
+	      t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx
+		    + s1.x) * a - 0.5 * da) * xx + da;
+	      res = a + t;
+	      cor = (a - res) + t;
+	      cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
+	      retval = (res == res + cor) ? res : bsloww (a, da, x, n);
+	      goto ret;
+	    }
+	  else
+	    {
+	      if (a > 0)
+		{
+		  m = 1;
+		  t = a;
+		  db = da;
+		}
+	      else
+		{
+		  m = 0;
+		  t = -a;
+		  db = -da;
+		}
+	      u.x = big.x + t;
+	      y = t - (u.x - big.x);
+	      xx = y * y;
+	      s = y + (db + y * xx * (sn3 + xx * sn5));
+	      c = y * db + xx * (cs2 + xx * (cs4 + xx * cs6));
+	      k = u.i[LOW_HALF] << 2;
+	      sn = __sincostab.x[k];
+	      ssn = __sincostab.x[k + 1];
+	      cs = __sincostab.x[k + 2];
+	      ccs = __sincostab.x[k + 3];
+	      cor = (ssn + s * ccs - sn * c) + cs * s;
+	      res = sn + cor;
+	      cor = (sn - res) + cor;
+	      cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
+	      retval = ((res == res + cor) ? ((m) ? res : -res)
+			: bsloww1 (a, da, x, n));
+	      goto ret;
+	    }
+	  break;
+
+	case 0:
+	case 2:
+	  if (a < 0)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  u.x = big.x + a;
+	  y = a - (u.x - big.x) + da;
+	  xx = y * y;
+	  k = u.i[LOW_HALF] << 2;
+	  sn = __sincostab.x[k];
+	  ssn = __sincostab.x[k + 1];
+	  cs = __sincostab.x[k + 2];
+	  ccs = __sincostab.x[k + 3];
+	  s = y + y * xx * (sn3 + xx * sn5);
+	  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+	  cor = (ccs - s * ssn - cs * c) - sn * s;
+	  res = cs + cor;
+	  cor = (cs - res) + cor;
+	  cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
+	  retval = ((res == res + cor) ? ((n) ? -res : res)
+		    : bsloww2 (a, da, x, n));
+	  goto ret;
+	  break;
+	}
+    }				/*   else  if (k <  0x42F00000 )    */
+
+  else if (k < 0x7ff00000)
+    {				/* 281474976710656 <|x| <2^1024 */
+
+      n = __branred (x, &a, &da);
+      switch (n)
+	{
+	case 1:
+	  if (a * a < 0.01588)
+	    retval = bsloww (-a, -da, x, n);
+	  else
+	    retval = bsloww1 (-a, -da, x, n);
+	  goto ret;
+	  break;
+	case 3:
+	  if (a * a < 0.01588)
+	    retval = bsloww (a, da, x, n);
+	  else
+	    retval = bsloww1 (a, da, x, n);
+	  goto ret;
+	  break;
 
-  else if (k < 0x7ff00000) {/* 281474976710656 <|x| <2^1024 */
+	case 0:
+	case 2:
+	  retval = bsloww2 (a, da, x, n);
+	  goto ret;
+	  break;
+	}
+    }				/*   else  if (k <  0x7ff00000 )    */
 
-    n = __branred(x,&a,&da);
-    switch (n) {
-    case 1:
-      if (a*a < 0.01588) retval = bsloww(-a,-da,x,n);
-      else retval = bsloww1(-a,-da,x,n);
+  else
+    {
+      if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
+	__set_errno (EDOM);
+      retval = x / x;		/* |x| > 2^1024 */
       goto ret;
-      break;
-		case 3:
-		  if (a*a < 0.01588) retval = bsloww(a,da,x,n);
-		  else retval = bsloww1(a,da,x,n);
-		  goto ret;
-		  break;
-
-    case 0:
-    case 2:
-      retval = bsloww2(a,da,x,n);
-      goto ret;
-      break;
     }
 
-  }    /*   else  if (k <  0x7ff00000 )    */
-
-
-
-
-  else {
-    if (k == 0x7ff00000 && u.i[LOW_HALF] == 0)
-      __set_errno (EDOM);
-    retval = x / x; /* |x| > 2^1024 */
-    goto ret;
-  }
-
- ret:
+ret:
   return retval;
 }
 
@@ -636,25 +764,32 @@ __cos(double x)
 
 static double
 SECTION
-slow(double x) {
-static const double th2_36 = 206158430208.0;   /*    1.5*2**37   */
- double y,x1,x2,xx,r,t,res,cor,w[2];
- x1=(x+th2_36)-th2_36;
- y = aa.x*x1*x1*x1;
- r=x+y;
- x2=x-x1;
- xx=x*x;
- t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + bb.x)*xx + 3.0*aa.x*x1*x2)*x +aa.x*x2*x2*x2;
- t=((x-r)+y)+t;
- res=r+t;
- cor = (r-res)+t;
- if (res == res + 1.0007*cor) return res;
- else {
-   __dubsin(ABS(x),0,w);
-   if (w[0] == w[0]+1.000000001*w[1]) return (x>0)?w[0]:-w[0];
-   else return (x>0)?__mpsin(x,0):-__mpsin(-x,0);
- }
+slow (double x)
+{
+  static const double th2_36 = 206158430208.0;	/*    1.5*2**37   */
+  double y, x1, x2, xx, r, t, res, cor, w[2];
+  x1 = (x + th2_36) - th2_36;
+  y = aa.x * x1 * x1 * x1;
+  r = x + y;
+  x2 = x - x1;
+  xx = x * x;
+  t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx + bb.x) * xx
+       + 3.0 * aa.x * x1 * x2) * x + aa.x * x2 * x2 * x2;
+  t = ((x - r) + y) + t;
+  res = r + t;
+  cor = (r - res) + t;
+  if (res == res + 1.0007 * cor)
+    return res;
+  else
+    {
+      __dubsin (ABS (x), 0, w);
+      if (w[0] == w[0] + 1.000000001 * w[1])
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return (x > 0) ? __mpsin (x, 0) : -__mpsin (-x, 0);
+    }
 }
+
 /*******************************************************************************/
 /* Routine compute sin(x) for   0.25<|x|< 0.855469 by  __sincostab.tbl   and Taylor */
 /* and if result still doesn't accurate enough by mpsin   or dubsin            */
@@ -662,88 +797,102 @@ static const double th2_36 = 206158430208.0;   /*    1.5*2**37   */
 
 static double
 SECTION
-slow1(double x) {
+slow1 (double x)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,c1,c2,xx,cor,res;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  u.x=big.x+y;
-  y=y-(u.x-big.x);
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];          /* Data          */
-  ssn=__sincostab.x[k+1];       /*  from         */
-  cs=__sincostab.x[k+2];        /*   tables      */
-  ccs=__sincostab.x[k+3];       /*    __sincostab.tbl */
-  y1 = (y+t22)-t22;
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];	/* Data          */
+  ssn = __sincostab.x[k + 1];	/*  from         */
+  cs = __sincostab.x[k + 2];	/*   tables      */
+  ccs = __sincostab.x[k + 3];	/*    __sincostab.tbl */
+  y1 = (y + t22) - t22;
   y2 = y - y1;
-  c1 = (cs+t22)-t22;
-  c2=(cs-c1)+ccs;
-  cor=(ssn+s*ccs+cs*s+c2*y+c1*y2)-sn*c;
-  y=sn+c1*y1;
-  cor = cor+((sn-y)+c1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  if (res == res+1.0005*cor) return (x>0)?res:-res;
-  else {
-    __dubsin(ABS(x),0,w);
-    if (w[0] == w[0]+1.000000005*w[1]) return (x>0)?w[0]:-w[0];
-    else return (x>0)?__mpsin(x,0):-__mpsin(-x,0);
-  }
+  c1 = (cs + t22) - t22;
+  c2 = (cs - c1) + ccs;
+  cor = (ssn + s * ccs + cs * s + c2 * y + c1 * y2) - sn * c;
+  y = sn + c1 * y1;
+  cor = cor + ((sn - y) + c1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+  if (res == res + 1.0005 * cor)
+    return (x > 0) ? res : -res;
+  else
+    {
+      __dubsin (ABS (x), 0, w);
+      if (w[0] == w[0] + 1.000000005 * w[1])
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return (x > 0) ? __mpsin (x, 0) : -__mpsin (-x, 0);
+    }
 }
+
 /**************************************************************************/
 /*  Routine compute sin(x) for   0.855469  <|x|<2.426265  by  __sincostab.tbl  */
 /* and if result still doesn't accurate enough by mpsin   or dubsin       */
 /**************************************************************************/
 static double
 SECTION
-slow2(double x) {
+slow2 (double x)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,e1,e2,xx,cor,res,del;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res, del;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  y = hp0.x-y;
-  if (y>=0) {
-    u.x = big.x+y;
-    y = y-(u.x-big.x);
-    del = hp1.x;
-  }
-  else {
-    u.x = big.x-y;
-    y = -(y+(u.x-big.x));
-    del = -hp1.x;
-  }
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = y*del+xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];
-  ssn=__sincostab.x[k+1];
-  cs=__sincostab.x[k+2];
-  ccs=__sincostab.x[k+3];
-  y1 = (y+t22)-t22;
-  y2 = (y - y1)+del;
-  e1 = (sn+t22)-t22;
-  e2=(sn-e1)+ssn;
-  cor=(ccs-cs*c-e1*y2-e2*y)-sn*s;
-  y=cs-e1*y1;
-  cor = cor+((cs-y)-e1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  if (res == res+1.0005*cor) return (x>0)?res:-res;
-  else {
-    y=ABS(x)-hp0.x;
-    y1=y-hp1.x;
-    y2=(y-y1)-hp1.x;
-    __docos(y1,y2,w);
-    if (w[0] == w[0]+1.000000005*w[1]) return (x>0)?w[0]:-w[0];
-    else return (x>0)?__mpsin(x,0):-__mpsin(-x,0);
-  }
+  y = ABS (x);
+  y = hp0.x - y;
+  if (y >= 0)
+    {
+      u.x = big.x + y;
+      y = y - (u.x - big.x);
+      del = hp1.x;
+    }
+  else
+    {
+      u.x = big.x - y;
+      y = -(y + (u.x - big.x));
+      del = -hp1.x;
+    }
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = y * del + xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + del;
+  e1 = (sn + t22) - t22;
+  e2 = (sn - e1) + ssn;
+  cor = (ccs - cs * c - e1 * y2 - e2 * y) - sn * s;
+  y = cs - e1 * y1;
+  cor = cor + ((cs - y) - e1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+  if (res == res + 1.0005 * cor)
+    return (x > 0) ? res : -res;
+  else
+    {
+      y = ABS (x) - hp0.x;
+      y1 = y - hp1.x;
+      y2 = (y - y1) - hp1.x;
+      __docos (y1, y2, w);
+      if (w[0] == w[0] + 1.000000005 * w[1])
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return (x > 0) ? __mpsin (x, 0) : -__mpsin (-x, 0);
+    }
 }
+
 /***************************************************************************/
 /*  Routine compute sin(x+dx) (Double-Length number) where x is small enough*/
 /* to use Taylor series around zero and   (x+dx)                            */
@@ -754,46 +903,74 @@ slow2(double x) {
 
 static double
 SECTION
-sloww(double x,double dx, double orig) {
-  static const double th2_36 = 206158430208.0;   /*    1.5*2**37   */
-  double y,x1,x2,xx,r,t,res,cor,w[2],a,da,xn;
-  union {int4 i[2]; double x;} v;
+sloww (double x, double dx, double orig)
+{
+  static const double th2_36 = 206158430208.0;	/*    1.5*2**37   */
+  double y, x1, x2, xx, r, t, res, cor, w[2], a, da, xn;
+  union
+  {
+    int4 i[2];
+    double x;
+  } v;
   int4 n;
-  x1=(x+th2_36)-th2_36;
-  y = aa.x*x1*x1*x1;
-  r=x+y;
-  x2=(x-x1)+dx;
-  xx=x*x;
-  t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + bb.x)*xx + 3.0*aa.x*x1*x2)*x +aa.x*x2*x2*x2+dx;
-  t=((x-r)+y)+t;
-  res=r+t;
-  cor = (r-res)+t;
-  cor = (cor>0)? 1.0005*cor+ABS(orig)*3.1e-30 : 1.0005*cor-ABS(orig)*3.1e-30;
-  if (res == res + cor) return res;
-  else {
-    (x>0)? __dubsin(x,dx,w) : __dubsin(-x,-dx,w);
-    cor = (w[1]>0)? 1.000000001*w[1] + ABS(orig)*1.1e-30 : 1.000000001*w[1] - ABS(orig)*1.1e-30;
-    if (w[0] == w[0]+cor) return (x>0)?w[0]:-w[0];
-    else {
-      t = (orig*hpinv.x + toint.x);
-      xn = t - toint.x;
-      v.x = t;
-      y = (orig - xn*mp1.x) - xn*mp2.x;
-      n =v.i[LOW_HALF]&3;
-      da = xn*pp3.x;
-      t=y-da;
-      da = (y-t)-da;
-      y = xn*pp4.x;
-      a = t - y;
-      da = ((t-a)-y)+da;
-      if (n&2) {a=-a; da=-da;}
-      (a>0)? __dubsin(a,da,w) : __dubsin(-a,-da,w);
-      cor = (w[1]>0)? 1.000000001*w[1] + ABS(orig)*1.1e-40 : 1.000000001*w[1] - ABS(orig)*1.1e-40;
-      if (w[0] == w[0]+cor) return (a>0)?w[0]:-w[0];
-      else return __mpsin1(orig);
+  x1 = (x + th2_36) - th2_36;
+  y = aa.x * x1 * x1 * x1;
+  r = x + y;
+  x2 = (x - x1) + dx;
+  xx = x * x;
+  t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx + bb.x) * xx
+       + 3.0 * aa.x * x1 * x2) * x + aa.x * x2 * x2 * x2 + dx;
+  t = ((x - r) + y) + t;
+  res = r + t;
+  cor = (r - res) + t;
+  cor =
+    (cor >
+     0) ? 1.0005 * cor + ABS (orig) * 3.1e-30 : 1.0005 * cor -
+    ABS (orig) * 3.1e-30;
+  if (res == res + cor)
+    return res;
+  else
+    {
+      (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
+      if (w[1] > 0)
+	cor = 1.000000001 * w[1] + ABS (orig) * 1.1e-30;
+      else
+	cor = 1.000000001 * w[1] - ABS (orig) * 1.1e-30;
+
+      if (w[0] == w[0] + cor)
+	return (x > 0) ? w[0] : -w[0];
+      else
+	{
+	  t = (orig * hpinv.x + toint.x);
+	  xn = t - toint.x;
+	  v.x = t;
+	  y = (orig - xn * mp1.x) - xn * mp2.x;
+	  n = v.i[LOW_HALF] & 3;
+	  da = xn * pp3.x;
+	  t = y - da;
+	  da = (y - t) - da;
+	  y = xn * pp4.x;
+	  a = t - y;
+	  da = ((t - a) - y) + da;
+	  if (n & 2)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w);
+	  if (w[1] > 0)
+	    cor = 1.000000001 * w[1] + ABS (orig) * 1.1e-40;
+	  else
+	    cor = 1.000000001 * w[1] - ABS (orig) * 1.1e-40;
+
+	  if (w[0] == w[0] + cor)
+	    return (a > 0) ? w[0] : -w[0];
+	  else
+	    return __mpsin1 (orig);
+	}
     }
-  }
 }
+
 /***************************************************************************/
 /*  Routine compute sin(x+dx)   (Double-Length number) where x in first or  */
 /*  third quarter of unit circle.Routine receive also (right argument) the  */
@@ -803,41 +980,58 @@ sloww(double x,double dx, double orig) {
 
 static double
 SECTION
-sloww1(double x, double dx, double orig) {
+sloww1 (double x, double dx, double orig)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,c1,c2,xx,cor,res;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  u.x=big.x+y;
-  y=y-(u.x-big.x);
-  dx=(x>0)?dx:-dx;
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];
-  ssn=__sincostab.x[k+1];
-  cs=__sincostab.x[k+2];
-  ccs=__sincostab.x[k+3];
-  y1 = (y+t22)-t22;
-  y2 = (y - y1)+dx;
-  c1 = (cs+t22)-t22;
-  c2=(cs-c1)+ccs;
-  cor=(ssn+s*ccs+cs*s+c2*y+c1*y2-sn*y*dx)-sn*c;
-  y=sn+c1*y1;
-  cor = cor+((sn-y)+c1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  cor = (cor>0)? 1.0005*cor+3.1e-30*ABS(orig) : 1.0005*cor-3.1e-30*ABS(orig);
-  if (res == res + cor) return (x>0)?res:-res;
-  else {
-    __dubsin(ABS(x),dx,w);
-    cor = (w[1]>0)? 1.000000005*w[1]+1.1e-30*ABS(orig) : 1.000000005*w[1]-1.1e-30*ABS(orig);
-    if (w[0] == w[0]+cor) return (x>0)?w[0]:-w[0];
-  else  return __mpsin1(orig);
-  }
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  dx = (x > 0) ? dx : -dx;
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + dx;
+  c1 = (cs + t22) - t22;
+  c2 = (cs - c1) + ccs;
+  cor = (ssn + s * ccs + cs * s + c2 * y + c1 * y2 - sn * y * dx) - sn * c;
+  y = sn + c1 * y1;
+  cor = cor + ((sn - y) + c1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+
+  if (cor > 0)
+    cor = 1.0005 * cor + 3.1e-30 * ABS (orig);
+  else
+    cor = 1.0005 * cor - 3.1e-30 * ABS (orig);
+
+  if (res == res + cor)
+    return (x > 0) ? res : -res;
+  else
+    {
+      __dubsin (ABS (x), dx, w);
+
+      if (w[1] > 0)
+	cor = 1.000000005 * w[1] + 1.1e-30 * ABS (orig);
+      else
+	cor = 1.000000005 * w[1] - 1.1e-30 * ABS (orig);
+
+      if (w[0] == w[0] + cor)
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return __mpsin1 (orig);
+    }
 }
+
 /***************************************************************************/
 /*  Routine compute sin(x+dx)   (Double-Length number) where x in second or */
 /*  fourth quarter of unit circle.Routine receive also  the  original value */
@@ -847,42 +1041,59 @@ sloww1(double x, double dx, double orig) {
 
 static double
 SECTION
-sloww2(double x, double dx, double orig, int n) {
+sloww2 (double x, double dx, double orig, int n)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,e1,e2,xx,cor,res;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  u.x=big.x+y;
-  y=y-(u.x-big.x);
-  dx=(x>0)?dx:-dx;
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = y*dx+xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];
-  ssn=__sincostab.x[k+1];
-  cs=__sincostab.x[k+2];
-  ccs=__sincostab.x[k+3];
-
-  y1 = (y+t22)-t22;
-  y2 = (y - y1)+dx;
-  e1 = (sn+t22)-t22;
-  e2=(sn-e1)+ssn;
-  cor=(ccs-cs*c-e1*y2-e2*y)-sn*s;
-  y=cs-e1*y1;
-  cor = cor+((cs-y)-e1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  cor = (cor>0)? 1.0005*cor+3.1e-30*ABS(orig) : 1.0005*cor-3.1e-30*ABS(orig);
-  if (res == res + cor) return (n&2)?-res:res;
-  else {
-   __docos(ABS(x),dx,w);
-   cor = (w[1]>0)? 1.000000005*w[1]+1.1e-30*ABS(orig) : 1.000000005*w[1]-1.1e-30*ABS(orig);
-   if (w[0] == w[0]+cor) return (n&2)?-w[0]:w[0];
-   else  return __mpsin1(orig);
-  }
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  dx = (x > 0) ? dx : -dx;
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = y * dx + xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + dx;
+  e1 = (sn + t22) - t22;
+  e2 = (sn - e1) + ssn;
+  cor = (ccs - cs * c - e1 * y2 - e2 * y) - sn * s;
+  y = cs - e1 * y1;
+  cor = cor + ((cs - y) - e1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+
+  if (cor > 0)
+    cor = 1.0005 * cor + 3.1e-30 * ABS (orig);
+  else
+    cor = 1.0005 * cor - 3.1e-30 * ABS (orig);
+
+  if (res == res + cor)
+    return (n & 2) ? -res : res;
+  else
+    {
+      __docos (ABS (x), dx, w);
+
+      if (w[1] > 0)
+	cor = 1.000000005 * w[1] + 1.1e-30 * ABS (orig);
+      else
+	cor = 1.000000005 * w[1] - 1.1e-30 * ABS (orig);
+
+      if (w[0] == w[0] + cor)
+	return (n & 2) ? -w[0] : w[0];
+      else
+	return __mpsin1 (orig);
+    }
 }
+
 /***************************************************************************/
 /*  Routine compute sin(x+dx) or cos(x+dx) (Double-Length number) where x   */
 /* is small enough to use Taylor series around zero and   (x+dx)            */
@@ -893,26 +1104,36 @@ sloww2(double x, double dx, double orig, int n) {
 
 static double
 SECTION
-bsloww(double x,double dx, double orig,int n) {
-  static const double th2_36 = 206158430208.0;   /*    1.5*2**37   */
-  double y,x1,x2,xx,r,t,res,cor,w[2];
-  x1=(x+th2_36)-th2_36;
-  y = aa.x*x1*x1*x1;
-  r=x+y;
-  x2=(x-x1)+dx;
-  xx=x*x;
-  t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + bb.x)*xx + 3.0*aa.x*x1*x2)*x +aa.x*x2*x2*x2+dx;
-  t=((x-r)+y)+t;
-  res=r+t;
-  cor = (r-res)+t;
-  cor = (cor>0)? 1.0005*cor+1.1e-24 : 1.0005*cor-1.1e-24;
-  if (res == res + cor) return res;
-  else {
-    (x>0)? __dubsin(x,dx,w) : __dubsin(-x,-dx,w);
-    cor = (w[1]>0)? 1.000000001*w[1] + 1.1e-24 : 1.000000001*w[1] - 1.1e-24;
-    if (w[0] == w[0]+cor) return (x>0)?w[0]:-w[0];
-    else return (n&1)?__mpcos1(orig):__mpsin1(orig);
-  }
+bsloww (double x, double dx, double orig, int n)
+{
+  static const double th2_36 = 206158430208.0;	/*    1.5*2**37   */
+  double y, x1, x2, xx, r, t, res, cor, w[2];
+
+  x1 = (x + th2_36) - th2_36;
+  y = aa.x * x1 * x1 * x1;
+  r = x + y;
+  x2 = (x - x1) + dx;
+  xx = x * x;
+  t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx + bb.x) * xx
+       + 3.0 * aa.x * x1 * x2) * x + aa.x * x2 * x2 * x2 + dx;
+  t = ((x - r) + y) + t;
+  res = r + t;
+  cor = (r - res) + t;
+  cor = (cor > 0) ? 1.0005 * cor + 1.1e-24 : 1.0005 * cor - 1.1e-24;
+  if (res == res + cor)
+    return res;
+  else
+    {
+      (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
+      if (w[1] > 0)
+	cor = 1.000000001 * w[1] + 1.1e-24;
+      else
+	cor = 1.000000001 * w[1] - 1.1e-24;
+      if (w[0] == w[0] + cor)
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return (n & 1) ? __mpcos1 (orig) : __mpsin1 (orig);
+    }
 }
 
 /***************************************************************************/
@@ -924,40 +1145,51 @@ bsloww(double x,double dx, double orig,int n) {
 
 static double
 SECTION
-bsloww1(double x, double dx, double orig,int n) {
-mynumber u;
- double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,c1,c2,xx,cor,res;
- static const double t22 = 6291456.0;
- int4 k;
- y=ABS(x);
- u.x=big.x+y;
- y=y-(u.x-big.x);
- dx=(x>0)?dx:-dx;
- xx=y*y;
- s = y*xx*(sn3 +xx*sn5);
- c = xx*(cs2 +xx*(cs4 + xx*cs6));
- k=u.i[LOW_HALF]<<2;
- sn=__sincostab.x[k];
- ssn=__sincostab.x[k+1];
- cs=__sincostab.x[k+2];
- ccs=__sincostab.x[k+3];
- y1 = (y+t22)-t22;
- y2 = (y - y1)+dx;
- c1 = (cs+t22)-t22;
- c2=(cs-c1)+ccs;
- cor=(ssn+s*ccs+cs*s+c2*y+c1*y2-sn*y*dx)-sn*c;
- y=sn+c1*y1;
- cor = cor+((sn-y)+c1*y1);
- res=y+cor;
- cor=(y-res)+cor;
- cor = (cor>0)? 1.0005*cor+1.1e-24 : 1.0005*cor-1.1e-24;
- if (res == res + cor) return (x>0)?res:-res;
- else {
-   __dubsin(ABS(x),dx,w);
-   cor = (w[1]>0)? 1.000000005*w[1]+1.1e-24: 1.000000005*w[1]-1.1e-24;
-   if (w[0] == w[0]+cor) return (x>0)?w[0]:-w[0];
-   else  return (n&1)?__mpcos1(orig):__mpsin1(orig);
- }
+bsloww1 (double x, double dx, double orig, int n)
+{
+  mynumber u;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
+  static const double t22 = 6291456.0;
+  int4 k;
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  dx = (x > 0) ? dx : -dx;
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + dx;
+  c1 = (cs + t22) - t22;
+  c2 = (cs - c1) + ccs;
+  cor = (ssn + s * ccs + cs * s + c2 * y + c1 * y2 - sn * y * dx) - sn * c;
+  y = sn + c1 * y1;
+  cor = cor + ((sn - y) + c1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+  cor = (cor > 0) ? 1.0005 * cor + 1.1e-24 : 1.0005 * cor - 1.1e-24;
+  if (res == res + cor)
+    return (x > 0) ? res : -res;
+  else
+    {
+      __dubsin (ABS (x), dx, w);
+
+      if (w[1] > 0)
+	cor = 1.000000005 * w[1] + 1.1e-24;
+      else
+	cor = 1.000000005 * w[1] - 1.1e-24;
+
+      if (w[0] == w[0] + cor)
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return (n & 1) ? __mpcos1 (orig) : __mpsin1 (orig);
+    }
 }
 
 /***************************************************************************/
@@ -969,41 +1201,52 @@ mynumber u;
 
 static double
 SECTION
-bsloww2(double x, double dx, double orig, int n) {
-mynumber u;
- double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,e1,e2,xx,cor,res;
- static const double t22 = 6291456.0;
- int4 k;
- y=ABS(x);
- u.x=big.x+y;
- y=y-(u.x-big.x);
- dx=(x>0)?dx:-dx;
- xx=y*y;
- s = y*xx*(sn3 +xx*sn5);
- c = y*dx+xx*(cs2 +xx*(cs4 + xx*cs6));
- k=u.i[LOW_HALF]<<2;
- sn=__sincostab.x[k];
- ssn=__sincostab.x[k+1];
- cs=__sincostab.x[k+2];
- ccs=__sincostab.x[k+3];
-
- y1 = (y+t22)-t22;
- y2 = (y - y1)+dx;
- e1 = (sn+t22)-t22;
- e2=(sn-e1)+ssn;
- cor=(ccs-cs*c-e1*y2-e2*y)-sn*s;
- y=cs-e1*y1;
- cor = cor+((cs-y)-e1*y1);
- res=y+cor;
- cor=(y-res)+cor;
- cor = (cor>0)? 1.0005*cor+1.1e-24 : 1.0005*cor-1.1e-24;
- if (res == res + cor) return (n&2)?-res:res;
- else {
-   __docos(ABS(x),dx,w);
-   cor = (w[1]>0)? 1.000000005*w[1]+1.1e-24 : 1.000000005*w[1]-1.1e-24;
-   if (w[0] == w[0]+cor) return (n&2)?-w[0]:w[0];
-   else  return (n&1)?__mpsin1(orig):__mpcos1(orig);
- }
+bsloww2 (double x, double dx, double orig, int n)
+{
+  mynumber u;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
+  static const double t22 = 6291456.0;
+  int4 k;
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  dx = (x > 0) ? dx : -dx;
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = y * dx + xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + dx;
+  e1 = (sn + t22) - t22;
+  e2 = (sn - e1) + ssn;
+  cor = (ccs - cs * c - e1 * y2 - e2 * y) - sn * s;
+  y = cs - e1 * y1;
+  cor = cor + ((cs - y) - e1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+  cor = (cor > 0) ? 1.0005 * cor + 1.1e-24 : 1.0005 * cor - 1.1e-24;
+  if (res == res + cor)
+    return (n & 2) ? -res : res;
+  else
+    {
+      __docos (ABS (x), dx, w);
+
+      if (w[1] > 0)
+	cor = 1.000000005 * w[1] + 1.1e-24;
+      else
+	cor = 1.000000005 * w[1] - 1.1e-24;
+
+      if (w[0] == w[0] + cor)
+	return (n & 2) ? -w[0] : w[0];
+      else
+	return (n & 1) ? __mpsin1 (orig) : __mpcos1 (orig);
+    }
 }
 
 /************************************************************************/
@@ -1013,39 +1256,44 @@ mynumber u;
 
 static double
 SECTION
-cslow2(double x) {
+cslow2 (double x)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,e1,e2,xx,cor,res;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  u.x = big.x+y;
-  y = y-(u.x-big.x);
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];
-  ssn=__sincostab.x[k+1];
-  cs=__sincostab.x[k+2];
-  ccs=__sincostab.x[k+3];
-  y1 = (y+t22)-t22;
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+  y1 = (y + t22) - t22;
   y2 = y - y1;
-  e1 = (sn+t22)-t22;
-  e2=(sn-e1)+ssn;
-  cor=(ccs-cs*c-e1*y2-e2*y)-sn*s;
-  y=cs-e1*y1;
-  cor = cor+((cs-y)-e1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  if (res == res+1.0005*cor)
+  e1 = (sn + t22) - t22;
+  e2 = (sn - e1) + ssn;
+  cor = (ccs - cs * c - e1 * y2 - e2 * y) - sn * s;
+  y = cs - e1 * y1;
+  cor = cor + ((cs - y) - e1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+  if (res == res + 1.0005 * cor)
     return res;
-  else {
-    y=ABS(x);
-    __docos(y,0,w);
-    if (w[0] == w[0]+1.000000005*w[1]) return w[0];
-    else return __mpcos(x,0);
-  }
+  else
+    {
+      y = ABS (x);
+      __docos (y, 0, w);
+      if (w[0] == w[0] + 1.000000005 * w[1])
+	return w[0];
+      else
+	return __mpcos (x, 0);
+    }
 }
 
 /***************************************************************************/
@@ -1058,46 +1306,78 @@ cslow2(double x) {
 
 static double
 SECTION
-csloww(double x,double dx, double orig) {
-  static const double th2_36 = 206158430208.0;   /*    1.5*2**37   */
-  double y,x1,x2,xx,r,t,res,cor,w[2],a,da,xn;
-  union {int4 i[2]; double x;} v;
+csloww (double x, double dx, double orig)
+{
+  static const double th2_36 = 206158430208.0;	/*    1.5*2**37   */
+  double y, x1, x2, xx, r, t, res, cor, w[2], a, da, xn;
+  union
+  {
+    int4 i[2];
+    double x;
+  } v;
   int4 n;
-  x1=(x+th2_36)-th2_36;
-  y = aa.x*x1*x1*x1;
-  r=x+y;
-  x2=(x-x1)+dx;
-  xx=x*x;
-    /* Taylor series */
-  t = (((((s5.x*xx + s4.x)*xx + s3.x)*xx + s2.x)*xx + bb.x)*xx + 3.0*aa.x*x1*x2)*x +aa.x*x2*x2*x2+dx;
-  t=((x-r)+y)+t;
-  res=r+t;
-  cor = (r-res)+t;
-  cor = (cor>0)? 1.0005*cor+ABS(orig)*3.1e-30 : 1.0005*cor-ABS(orig)*3.1e-30;
-  if (res == res + cor) return res;
-  else {
-    (x>0)? __dubsin(x,dx,w) : __dubsin(-x,-dx,w);
-    cor = (w[1]>0)? 1.000000001*w[1] + ABS(orig)*1.1e-30 : 1.000000001*w[1] - ABS(orig)*1.1e-30;
-    if (w[0] == w[0]+cor) return (x>0)?w[0]:-w[0];
-    else {
-      t = (orig*hpinv.x + toint.x);
-      xn = t - toint.x;
-      v.x = t;
-      y = (orig - xn*mp1.x) - xn*mp2.x;
-      n =v.i[LOW_HALF]&3;
-      da = xn*pp3.x;
-      t=y-da;
-      da = (y-t)-da;
-      y = xn*pp4.x;
-      a = t - y;
-      da = ((t-a)-y)+da;
-      if (n==1) {a=-a; da=-da;}
-      (a>0)? __dubsin(a,da,w) : __dubsin(-a,-da,w);
-      cor = (w[1]>0)? 1.000000001*w[1] + ABS(orig)*1.1e-40 : 1.000000001*w[1] - ABS(orig)*1.1e-40;
-      if (w[0] == w[0]+cor) return (a>0)?w[0]:-w[0];
-      else return __mpcos1(orig);
+
+  x1 = (x + th2_36) - th2_36;
+  y = aa.x * x1 * x1 * x1;
+  r = x + y;
+  x2 = (x - x1) + dx;
+  xx = x * x;
+  /* Taylor series */
+  t = (((((s5.x * xx + s4.x) * xx + s3.x) * xx + s2.x) * xx + bb.x) * xx
+       + 3.0 * aa.x * x1 * x2) * x + aa.x * x2 * x2 * x2 + dx;
+  t = ((x - r) + y) + t;
+  res = r + t;
+  cor = (r - res) + t;
+
+  if (cor > 0)
+    cor = 1.0005 * cor + ABS (orig) * 3.1e-30;
+  else
+    cor = 1.0005 * cor - ABS (orig) * 3.1e-30;
+
+  if (res == res + cor)
+    return res;
+  else
+    {
+      (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
+
+      if (w[1] > 0)
+	cor = 1.000000001 * w[1] + ABS (orig) * 1.1e-30;
+      else
+	cor = 1.000000001 * w[1] - ABS (orig) * 1.1e-30;
+
+      if (w[0] == w[0] + cor)
+	return (x > 0) ? w[0] : -w[0];
+      else
+	{
+	  t = (orig * hpinv.x + toint.x);
+	  xn = t - toint.x;
+	  v.x = t;
+	  y = (orig - xn * mp1.x) - xn * mp2.x;
+	  n = v.i[LOW_HALF] & 3;
+	  da = xn * pp3.x;
+	  t = y - da;
+	  da = (y - t) - da;
+	  y = xn * pp4.x;
+	  a = t - y;
+	  da = ((t - a) - y) + da;
+	  if (n == 1)
+	    {
+	      a = -a;
+	      da = -da;
+	    }
+	  (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w);
+
+	  if (w[1] > 0)
+	    cor = 1.000000001 * w[1] + ABS (orig) * 1.1e-40;
+	  else
+	    cor = 1.000000001 * w[1] - ABS (orig) * 1.1e-40;
+
+	  if (w[0] == w[0] + cor)
+	    return (a > 0) ? w[0] : -w[0];
+	  else
+	    return __mpcos1 (orig);
+	}
     }
-  }
 }
 
 /***************************************************************************/
@@ -1109,40 +1389,54 @@ csloww(double x,double dx, double orig) {
 
 static double
 SECTION
-csloww1(double x, double dx, double orig) {
+csloww1 (double x, double dx, double orig)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,c1,c2,xx,cor,res;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, c1, c2, xx, cor, res;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  u.x=big.x+y;
-  y=y-(u.x-big.x);
-  dx=(x>0)?dx:-dx;
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];
-  ssn=__sincostab.x[k+1];
-  cs=__sincostab.x[k+2];
-  ccs=__sincostab.x[k+3];
-  y1 = (y+t22)-t22;
-  y2 = (y - y1)+dx;
-  c1 = (cs+t22)-t22;
-  c2=(cs-c1)+ccs;
-  cor=(ssn+s*ccs+cs*s+c2*y+c1*y2-sn*y*dx)-sn*c;
-  y=sn+c1*y1;
-  cor = cor+((sn-y)+c1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  cor = (cor>0)? 1.0005*cor+3.1e-30*ABS(orig) : 1.0005*cor-3.1e-30*ABS(orig);
-  if (res == res + cor) return (x>0)?res:-res;
-  else {
-    __dubsin(ABS(x),dx,w);
-    cor = (w[1]>0)? 1.000000005*w[1]+1.1e-30*ABS(orig) : 1.000000005*w[1]-1.1e-30*ABS(orig);
-    if (w[0] == w[0]+cor) return (x>0)?w[0]:-w[0];
-    else  return __mpcos1(orig);
-  }
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  dx = (x > 0) ? dx : -dx;
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + dx;
+  c1 = (cs + t22) - t22;
+  c2 = (cs - c1) + ccs;
+  cor = (ssn + s * ccs + cs * s + c2 * y + c1 * y2 - sn * y * dx) - sn * c;
+  y = sn + c1 * y1;
+  cor = cor + ((sn - y) + c1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+
+  if (cor > 0)
+    cor = 1.0005 * cor + 3.1e-30 * ABS (orig);
+  else
+    cor = 1.0005 * cor - 3.1e-30 * ABS (orig);
+
+  if (res == res + cor)
+    return (x > 0) ? res : -res;
+  else
+    {
+      __dubsin (ABS (x), dx, w);
+      if (w[1] > 0)
+	cor = 1.000000005 * w[1] + 1.1e-30 * ABS (orig);
+      else
+	cor = 1.000000005 * w[1] - 1.1e-30 * ABS (orig);
+      if (w[0] == w[0] + cor)
+	return (x > 0) ? w[0] : -w[0];
+      else
+	return __mpcos1 (orig);
+    }
 }
 
 
@@ -1155,41 +1449,55 @@ csloww1(double x, double dx, double orig) {
 
 static double
 SECTION
-csloww2(double x, double dx, double orig, int n) {
+csloww2 (double x, double dx, double orig, int n)
+{
   mynumber u;
-  double sn,ssn,cs,ccs,s,c,w[2],y,y1,y2,e1,e2,xx,cor,res;
+  double sn, ssn, cs, ccs, s, c, w[2], y, y1, y2, e1, e2, xx, cor, res;
   static const double t22 = 6291456.0;
   int4 k;
-  y=ABS(x);
-  u.x=big.x+y;
-  y=y-(u.x-big.x);
-  dx=(x>0)?dx:-dx;
-  xx=y*y;
-  s = y*xx*(sn3 +xx*sn5);
-  c = y*dx+xx*(cs2 +xx*(cs4 + xx*cs6));
-  k=u.i[LOW_HALF]<<2;
-  sn=__sincostab.x[k];
-  ssn=__sincostab.x[k+1];
-  cs=__sincostab.x[k+2];
-  ccs=__sincostab.x[k+3];
-
-  y1 = (y+t22)-t22;
-  y2 = (y - y1)+dx;
-  e1 = (sn+t22)-t22;
-  e2=(sn-e1)+ssn;
-  cor=(ccs-cs*c-e1*y2-e2*y)-sn*s;
-  y=cs-e1*y1;
-  cor = cor+((cs-y)-e1*y1);
-  res=y+cor;
-  cor=(y-res)+cor;
-  cor = (cor>0)? 1.0005*cor+3.1e-30*ABS(orig) : 1.0005*cor-3.1e-30*ABS(orig);
-  if (res == res + cor) return (n)?-res:res;
-  else {
-    __docos(ABS(x),dx,w);
-    cor = (w[1]>0)? 1.000000005*w[1]+1.1e-30*ABS(orig) : 1.000000005*w[1]-1.1e-30*ABS(orig);
-    if (w[0] == w[0]+cor) return (n)?-w[0]:w[0];
-    else  return __mpcos1(orig);
-  }
+
+  y = ABS (x);
+  u.x = big.x + y;
+  y = y - (u.x - big.x);
+  dx = (x > 0) ? dx : -dx;
+  xx = y * y;
+  s = y * xx * (sn3 + xx * sn5);
+  c = y * dx + xx * (cs2 + xx * (cs4 + xx * cs6));
+  k = u.i[LOW_HALF] << 2;
+  sn = __sincostab.x[k];
+  ssn = __sincostab.x[k + 1];
+  cs = __sincostab.x[k + 2];
+  ccs = __sincostab.x[k + 3];
+
+  y1 = (y + t22) - t22;
+  y2 = (y - y1) + dx;
+  e1 = (sn + t22) - t22;
+  e2 = (sn - e1) + ssn;
+  cor = (ccs - cs * c - e1 * y2 - e2 * y) - sn * s;
+  y = cs - e1 * y1;
+  cor = cor + ((cs - y) - e1 * y1);
+  res = y + cor;
+  cor = (y - res) + cor;
+
+  if (cor > 0)
+    cor = 1.0005 * cor + 3.1e-30 * ABS (orig);
+  else
+    cor = 1.0005 * cor - 3.1e-30 * ABS (orig);
+
+  if (res == res + cor)
+    return (n) ? -res : res;
+  else
+    {
+      __docos (ABS (x), dx, w);
+      if (w[1] > 0)
+	cor = 1.000000005 * w[1] + 1.1e-30 * ABS (orig);
+      else
+	cor = 1.000000005 * w[1] - 1.1e-30 * ABS (orig);
+      if (w[0] == w[0] + cor)
+	return (n) ? -w[0] : w[0];
+      else
+	return __mpcos1 (orig);
+    }
 }
 
 #ifndef __cos

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=f0ee064b7dcdbde6b28002a63be4b86c86e235b9

commit f0ee064b7dcdbde6b28002a63be4b86c86e235b9
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Tue Apr 30 14:17:57 2013 +0530

    Allow multiple input domains to be run in the same benchmark program
    
    Some math functions have distinct performance characteristics in
    specific domains of inputs, where some inputs return via a fast path
    while other inputs require multiple precision calculations, that too
    at different precision levels.  The way to implement different domains
    was to have a separate source file and benchmark definition, resulting
    in separate programs.
    
    This clutters up the benchmark, so this change allows these domains to
    be consolidated into the same input file.  To do this, the input file
    format is now enhanced to allow comments with a preceding # and
    directives with two # at the begining of a line.  A directive that
    looks like:
    
    tells the benchmark generation script that what follows is a different
    domain of inputs.  The value of the 'name' directive (in this case,
    foo) is used in the output.  The two input domains are then executed
    sequentially and their results collated separately.  with the above
    directive, there would be two lines in the result that look like:
    
    func(): ....
    func(foo): ...

diff --git a/ChangeLog b/ChangeLog
index 07ec4d0..afeadd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2013-04-30  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
+	* benchtests/Makefile (bench): Remove slow benchmarks.
+	* benchtests/atan-inputs: Add slow benchmark inputs.
+	* benchtests/bench-modf.c (NUM_VARIANTS): Define.
+	(BENCH_FUNC): Accept variant offset.
+	(VARIANT): Define.
+	* benchtests/bench-skeleton.c (main): Run benchmark for each
+	variant.
+	* benchtests/cos-inputs: Add slow benchmark inputs.
+	* benchtests/exp-inputs: Likewise.
+	* benchtests/pow-inputs: Likewise.
+	* benchtests/sin-inputs: Likewise.
+	* benchtests/slowatan-inputs: Remove.
+	* benchtests/slowatan.c: Remove.
+	* benchtests/slowcos-inputs: Remove.
+	* benchtests/slowcos.c: Remove.
+	* benchtests/slowexp-inputs: Remove.
+	* benchtests/slowexp.c: Remove.
+	* benchtests/slowpow-inputs: Remove.
+	* benchtests/slowpow.c: Remove.
+	* benchtests/slowsin-inputs: Remove.
+	* benchtests/slowsin.c: Remove.
+	* benchtests/slowtan-inputs: Remove.
+	* benchtests/slowtan.c: Remove.
+	* benchtests/tan-inputs: Add slow benchmark inputs.
+	* scripts/bench.pl: Parse comments and directives.
+
 	* benchtests/Makefile: Remove *-ITER.  Define BENCH_DURATION
 	in CPPFLAGS.
 	($(objpfx)bench-%.c): Remove *-ITER.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 9d25d69..19e1be6 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -39,15 +39,12 @@
 #   See pow-inputs for an example.
 
 subdir := benchtests
-bench := exp pow rint sin cos tan atan modf \
-	 slowexp slowpow slowsin slowcos slowtan slowatan
+bench := exp pow rint sin cos tan atan modf
 
-# exp function fast path: sysdeps/ieee754/dbl-64/e_exp.c
 exp-ARGLIST = double
 exp-RET = double
 LDFLAGS-bench-exp = -lm
 
-# pow function fast path: sysdeps/ieee754/dbl-64/e_pow.c
 pow-ARGLIST = double:double
 pow-RET = double
 LDFLAGS-bench-pow = -lm
@@ -56,62 +53,22 @@ rint-ARGLIST = double
 rint-RET = double
 LDFLAGS-bench-rint = -lm
 
-# exp function slowest path: sysdeps/ieee754/dbl-64/mpexp.c
-slowexp-ARGLIST = double
-slowexp-RET = double
-slowexp-INCLUDE = slowexp.c
-LDFLAGS-bench-slowexp = -lm
-
-# sin function fast path: sysdeps/ieee754/dbl-64/s_sin.c
 sin-ARGLIST = double
 sin-RET = double
 LDFLAGS-bench-sin = -lm
 
-# cos function fast path: sysdeps/ieee754/dbl-64/s_sin.c
 cos-ARGLIST = double
 cos-RET = double
 LDFLAGS-bench-cos = -lm
 
-# tan function fast path: sysdeps/ieee754/dbl-64/s_tan.c
 tan-ARGLIST = double
 tan-RET = double
 LDFLAGS-bench-tan = -lm
 
-# atan function fast path: sysdeps/ieee754/dbl-64/s_atan.c
 atan-ARGLIST = double
 atan-RET = double
 LDFLAGS-bench-atan = -lm
 
-# pow function slowest path: sysdeps/ieee754/dbl-64/slowpow.c
-slowpow-ARGLIST = double:double
-slowpow-RET = double
-slowpow-INCLUDE = slowpow.c
-LDFLAGS-bench-slowpow = -lm
-
-# sin function slowest path: sysdeps/ieee754/dbl-64/sincos32.c
-slowsin-ARGLIST = double
-slowsin-RET = double
-slowsin-INCLUDE = slowsin.c
-LDFLAGS-bench-slowsin = -lm
-
-# cos function slowest path: sysdeps/ieee754/dbl-64/sincos32.c
-slowcos-ARGLIST = double
-slowcos-RET = double
-slowcos-INCLUDE = slowcos.c
-LDFLAGS-bench-slowcos = -lm
-
-# tan function slowest path: sysdeps/ieee754/dbl-64/mptan.c
-slowtan-ARGLIST = double
-slowtan-RET = double
-slowtan-INCLUDE = slowtan.c
-LDFLAGS-bench-slowtan = -lm
-
-# atan function slowest path: sysdeps/ieee754/dbl-64/mpatan.c
-slowatan-ARGLIST = double
-slowatan-RET = double
-slowatan-INCLUDE = slowatan.c
-LDFLAGS-bench-slowatan = -lm
-
 
 
 # Rules to build and execute the benchmarks.  Do not put any benchmark
diff --git a/benchtests/atan-inputs b/benchtests/atan-inputs
index c685db3..4a2cf3a 100644
--- a/benchtests/atan-inputs
+++ b/benchtests/atan-inputs
@@ -1,3 +1,9 @@
 0x1.000000c5cba86p0
 0x1.000001883003ap0
 0x1.00000dfb2b674p0
+# atan slowest path at 768 bits
+# Implemented in sysdeps/ieee754/dbl-64/mpatan.c
+## name: 768bits
+0x1.000000c5cba87p0
+0x1.000001883003bp0
+0x1.00000dfb2b675p0
diff --git a/benchtests/bench-modf.c b/benchtests/bench-modf.c
index 90a5255..7fae7dc 100644
--- a/benchtests/bench-modf.c
+++ b/benchtests/bench-modf.c
@@ -17,7 +17,7 @@
 
 extern double modf (double, double *);
 
-#define CALL_BENCH_FUNC(j, i) modf ( in[j].arg0, &i);
+#define CALL_BENCH_FUNC(j, i) modf (in[j].arg0, &i);
 
 struct args
 {
@@ -28,11 +28,17 @@ struct args
   { -42.42 }
 };
 
-#define NUM_SAMPLES (sizeof (in) / sizeof (struct args))
+#define NUM_VARIANTS 1
+#define NUM_SAMPLES(v) (sizeof (in) / sizeof (struct args))
 
 static volatile double ret = 0.0;
-#define BENCH_FUNC(j) ({double iptr; ret =  CALL_BENCH_FUNC (j, iptr);})
+#define BENCH_FUNC(v, j) \
+({									      \
+  double iptr;								      \
+  ret =  CALL_BENCH_FUNC (j, iptr);					      \
+})
 
 #define FUNCNAME "modf"
+#define VARIANT(v) FUNCNAME "()"
 
 #include "bench-skeleton.c"
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c
index bbd151b..7359184 100644
--- a/benchtests/bench-skeleton.c
+++ b/benchtests/bench-skeleton.c
@@ -25,12 +25,11 @@
 #define TIMESPEC_AFTER(a, b) \
   (((a).tv_sec == (b).tv_sec) ?						      \
      ((a).tv_nsec > (b).tv_nsec) :					      \
-        ((a).tv_sec > (b).tv_sec))
+	((a).tv_sec > (b).tv_sec))
 int
 main (int argc, char **argv)
 {
   unsigned long i, k;
-  uint64_t total = 0, max = 0, min = 0x7fffffffffffffff;
   struct timespec start, end, runtime;
 
   memset (&runtime, 0, sizeof (runtime));
@@ -45,53 +44,57 @@ main (int argc, char **argv)
      but it's better than having nothing at all.  */
   unsigned long iters = 1000 * start.tv_nsec;
 
-  /* Run for approxmately DURATION seconds.  */
-  clock_gettime (CLOCK_MONOTONIC_RAW, &runtime);
-  runtime.tv_sec += DURATION;
-
-  double d_total_i = 0;
-  while (1)
+  for (int v = 0; v < NUM_VARIANTS; v++)
     {
-      for (i = 0; i < NUM_SAMPLES; i++)
-	{
-	  clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start);
-	  for (k = 0; k < iters; k++)
-	    BENCH_FUNC(i);
-	  clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end);
+      /* Run for approximately DURATION seconds.  */
+      clock_gettime (CLOCK_MONOTONIC_RAW, &runtime);
+      runtime.tv_sec += DURATION;
 
-	  uint64_t cur = (end.tv_nsec - start.tv_nsec
-			 + ((end.tv_sec - start.tv_sec)
-			    * (uint64_t) 1000000000));
+      double d_total_i = 0;
+      uint64_t total = 0, max = 0, min = 0x7fffffffffffffff;
+      while (1)
+	{
+	  for (i = 0; i < NUM_SAMPLES (v); i++)
+	    {
+	      clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start);
+	      for (k = 0; k < iters; k++)
+		BENCH_FUNC (v, i);
+	      clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end);
 
-	  if (cur > max)
-	    max = cur;
+	      uint64_t cur = (end.tv_nsec - start.tv_nsec
+			      + ((end.tv_sec - start.tv_sec)
+				 * (uint64_t) 1000000000));
 
-	  if (cur < min)
-	    min = cur;
+	      if (cur > max)
+		max = cur;
 
-	  total += cur;
+	      if (cur < min)
+		min = cur;
 
-	  d_total_i += iters;
-	}
+	      total += cur;
 
-      struct timespec curtime;
+	      d_total_i += iters;
+	    }
+	  struct timespec curtime;
 
-      memset (&curtime, 0, sizeof (curtime));
-      clock_gettime (CLOCK_MONOTONIC_RAW, &curtime);
-      if (TIMESPEC_AFTER (curtime, runtime))
-	goto done;
-    }
+	  memset (&curtime, 0, sizeof (curtime));
+	  clock_gettime (CLOCK_MONOTONIC_RAW, &curtime);
+	  if (TIMESPEC_AFTER (curtime, runtime))
+	    goto done;
+	}
 
-  double d_total_s;
-  double d_iters;
+      double d_total_s;
+      double d_iters;
 
- done:
-  d_total_s = total * 1e-9;
-  d_iters = iters;
+    done:
+      d_total_s = total * 1e-9;
+      d_iters = iters;
 
-  printf (FUNCNAME ": ITERS:%g: TOTAL:%gs, MAX:%gns, MIN:%gns, %g iter/s\n",
-	  d_total_i, d_total_s, max / d_iters, min / d_iters,
-	  d_total_i / d_total_s);
+      printf ("%s: ITERS:%g: TOTAL:%gs, MAX:%gns, MIN:%gns, %g iter/s\n",
+	      VARIANT (v),
+	      d_total_i, d_total_s, max / d_iters, min / d_iters,
+	      d_total_i / d_total_s);
+    }
 
   return 0;
 }
diff --git a/benchtests/cos-inputs b/benchtests/cos-inputs
index 98f4122..82a4060 100644
--- a/benchtests/cos-inputs
+++ b/benchtests/cos-inputs
@@ -3,3 +3,11 @@
 0x1.00000162a932ap0
 0x1.000002d452a11p0
 0x1.000005bc7d86cp0
+# cos slow path at 768 bits
+# Implemented in sysdeps/ieee754/dbl-64/sincos32.c
+## name: 768bits
+0x1.000000cf4a2a2p0
+0x1.0000010b239a9p0
+0x1.00000162a932bp0
+0x1.000002d452a10p0
+0x1.000005bc7d86dp0
diff --git a/benchtests/exp-inputs b/benchtests/exp-inputs
index d81cc07..e9d33a3 100644
--- a/benchtests/exp-inputs
+++ b/benchtests/exp-inputs
@@ -1 +1,5 @@
 42
+# Slowest path with computation in 768 bit precision.
+# Implemented in: sysdeps/ieee754/dbl-64/mpexp.c
+## name: 768bits
+708.00096423260981737257679924368858
diff --git a/benchtests/pow-inputs b/benchtests/pow-inputs
index 2f7cc03..dad6505 100644
--- a/benchtests/pow-inputs
+++ b/benchtests/pow-inputs
@@ -1 +1,5 @@
 42.0, 42.0
+# pow slowest path at 768 bits
+# Implemented in sysdeps/ieee754/dbl-64/slowpow.c
+## name: 768bits
+1.0000000000000020, 1.5
diff --git a/benchtests/sin-inputs b/benchtests/sin-inputs
index 620cea8..08192d8 100644
--- a/benchtests/sin-inputs
+++ b/benchtests/sin-inputs
@@ -5,3 +5,13 @@
 4.0
 4.7
 5.9
+# sin slowest path at 768 bits
+# Implemented in sysdeps/ieee754/dbl-64/sincos32.c
+## name: 768bits
+0.93340582292648832662962377071381
+2.3328432680770916363144351635128
+3.7439477503636453548097051680088
+3.9225160069792437411706487182528
+4.0711651639931289992091478779912
+4.7858438478542097982426639646292
+5.9840767662578002727968851104379
diff --git a/benchtests/slowatan-inputs b/benchtests/slowatan-inputs
deleted file mode 100644
index e557a3c..0000000
--- a/benchtests/slowatan-inputs
+++ /dev/null
@@ -1,3 +0,0 @@
-0x1.000000c5cba87p0
-0x1.000001883003bp0
-0x1.00000dfb2b675p0
diff --git a/benchtests/slowatan.c b/benchtests/slowatan.c
deleted file mode 100644
index 9a11d30..0000000
--- a/benchtests/slowatan.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Define slowatan.
-   Copyright (C) 2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C 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 2.1 of the License, or (at your option) any later version.
-
-   The GNU C 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 C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define slowatan atan
diff --git a/benchtests/slowcos-inputs b/benchtests/slowcos-inputs
deleted file mode 100644
index b7eb235..0000000
--- a/benchtests/slowcos-inputs
+++ /dev/null
@@ -1,5 +0,0 @@
-0x1.000000cf4a2a2p0
-0x1.0000010b239a9p0
-0x1.00000162a932bp0
-0x1.000002d452a10p0
-0x1.000005bc7d86dp0
diff --git a/benchtests/slowcos.c b/benchtests/slowcos.c
deleted file mode 100644
index 9f56234..0000000
--- a/benchtests/slowcos.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Define slowcos.
-   Copyright (C) 2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C 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 2.1 of the License, or (at your option) any later version.
-
-   The GNU C 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 C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define slowcos cos
diff --git a/benchtests/slowexp-inputs b/benchtests/slowexp-inputs
deleted file mode 100644
index a2086ba..0000000
--- a/benchtests/slowexp-inputs
+++ /dev/null
@@ -1 +0,0 @@
-708.00096423260981737257679924368858
diff --git a/benchtests/slowexp.c b/benchtests/slowexp.c
deleted file mode 100644
index 92ac5e9..0000000
--- a/benchtests/slowexp.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Define slowexp.
-   Copyright (C) 2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C 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 2.1 of the License, or (at your option) any later version.
-
-   The GNU C 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 C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define slowexp exp
diff --git a/benchtests/slowpow-inputs b/benchtests/slowpow-inputs
deleted file mode 100644
index dbb1270..0000000
--- a/benchtests/slowpow-inputs
+++ /dev/null
@@ -1 +0,0 @@
-1.0000000000000020, 1.5
diff --git a/benchtests/slowpow.c b/benchtests/slowpow.c
deleted file mode 100644
index 08f436d..0000000
--- a/benchtests/slowpow.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Define slowpow.
-   Copyright (C) 2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C 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 2.1 of the License, or (at your option) any later version.
-
-   The GNU C 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 C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define slowpow pow
diff --git a/benchtests/slowsin-inputs b/benchtests/slowsin-inputs
deleted file mode 100644
index 39daf80..0000000
--- a/benchtests/slowsin-inputs
+++ /dev/null
@@ -1,7 +0,0 @@
-0.93340582292648832662962377071381
-2.3328432680770916363144351635128
-3.7439477503636453548097051680088
-3.9225160069792437411706487182528
-4.0711651639931289992091478779912
-4.7858438478542097982426639646292
-5.9840767662578002727968851104379
diff --git a/benchtests/slowsin.c b/benchtests/slowsin.c
deleted file mode 100644
index b6809bd..0000000
--- a/benchtests/slowsin.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Define slowsin.
-   Copyright (C) 2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C 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 2.1 of the License, or (at your option) any later version.
-
-   The GNU C 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 C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define slowsin sin
diff --git a/benchtests/slowtan-inputs b/benchtests/slowtan-inputs
deleted file mode 100644
index 74a7eab..0000000
--- a/benchtests/slowtan-inputs
+++ /dev/null
@@ -1 +0,0 @@
-0x1.dffffffffff1fp-22
diff --git a/benchtests/slowtan.c b/benchtests/slowtan.c
deleted file mode 100644
index 583f16f..0000000
--- a/benchtests/slowtan.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Define slowtan.
-   Copyright (C) 2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C 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 2.1 of the License, or (at your option) any later version.
-
-   The GNU C 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 C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#define slowtan tan
diff --git a/benchtests/tan-inputs b/benchtests/tan-inputs
index 4369d75..629414f 100644
--- a/benchtests/tan-inputs
+++ b/benchtests/tan-inputs
@@ -1 +1,5 @@
 0x1.dffffffffff1ep-22
+# tan slowest path at 768 bits
+# Implemented in sysdeps/ieee754/dbl-64/mptan.c
+## name: 768bits
+0x1.dffffffffff1fp-22
diff --git a/scripts/bench.pl b/scripts/bench.pl
index 5856cfa..dcc5ead 100755
--- a/scripts/bench.pl
+++ b/scripts/bench.pl
@@ -42,15 +42,28 @@ if (@ARGV == 3) {
 
 my $decl = "extern $ret $func (";
 
+# Function has no arguments.
 if (@args == 0 || $args[0] eq "void") {
   print "$decl void);\n";
-  print "#define CALL_BENCH_FUNC(j) $func();\n";
-  print "#define NUM_SAMPLES (1)\n";
+  print "#define CALL_BENCH_FUNC(i,j) $func();\n";
+  print "#define NUM_VARIANTS (1)\n";
+  print "#define NUM_SAMPLES(v) (1)\n";
+  print "#define VARIANT(v) FUNCNAME \"()\"\n"
 }
+# The function has arguments, so parse them and populate the inputs.
 else {
   my $num = 0;
-  my $bench_func = "#define CALL_BENCH_FUNC(j) $func (";
-  my $struct = "struct args {";
+  my $bench_func = "#define CALL_BENCH_FUNC(v, i) $func (";
+
+  my $struct =
+    "struct _variants
+    {
+      const char *name;
+      int count;
+      struct args *in;
+    };\n";
+
+  my $arg_struct = "struct args {";
 
   foreach $arg (@args) {
     if ($num > 0) {
@@ -58,24 +71,87 @@ else {
       $decl = "$decl,";
     }
 
-    $struct = "$struct $arg arg$num;";
-    $bench_func = "$bench_func in[j].arg$num";
+    $arg_struct = "$arg_struct $arg arg$num;";
+    $bench_func = "$bench_func variants[v].in[i].arg$num";
     $decl = "$decl $arg";
     $num = $num + 1;
   }
 
-  print "$decl);\n";
-  print "$bench_func);\n";
-  print "$struct } in[] = {";
+  $arg_struct = $arg_struct . "};\n";
+  $decl = $decl . ");\n";
+  $bench_func = $bench_func . ");\n";
+
+  # We create a hash of inputs for each variant of the test.
+  my $variant = "";
+  my @curvals;
+  my %vals;
 
   open INPUTS, "<$func-inputs" or die $!;
 
-  while (<INPUTS>) {
+  LINE:while (<INPUTS>) {
     chomp;
-    print "{$_},\n";
+
+    # New variant.
+    if (/^## (\w+): (\w+)/) {
+      #We only identify Name for now.
+      if ($1 ne "name") {
+        next LINE;
+      }
+
+      # Save values in the last variant.
+      my @copy = @curvals;
+      $vals{$variant} = \@copy;
+
+      # Prepare for the next.
+      $variant=$2;
+      undef @curvals;
+      next LINE;
+    }
+
+    # Skip over comments.
+    if (/^#/) {
+      next LINE;
+    }
+    push (@curvals, $_);
   }
-  print "};\n";
-  print "#define NUM_SAMPLES (sizeof (in) / sizeof (struct args))\n"
+
+  $vals{$variant} = \@curvals;
+
+  # Print the definitions and macros.
+  print $decl;
+  print $bench_func;
+  print $arg_struct;
+  print $struct;
+
+  my $c = 0;
+  my $key;
+
+  # Print the input arrays.
+  foreach $key (keys %vals) {
+    my @arr = @{$vals{$key}};
+
+    print "struct args in" . $c . "[" . @arr . "] = {\n";
+    foreach (@arr) {
+      print "{$_},\n";
+    }
+    print "};\n\n";
+    $c += 1;
+  }
+
+  # The variants.  Each variant then points to the appropriate input array we
+  # defined above.
+  print "struct _variants variants[" . (keys %vals) . "] = {\n";
+  $c = 0;
+  foreach $key (keys %vals) {
+    print "{\"$func($key)\", " . @{$vals{$key}} . ", in$c},\n";
+    $c += 1;
+  }
+  print "};\n\n";
+
+  # Finally, print the last set of macros.
+  print "#define NUM_VARIANTS $c\n";
+  print "#define NUM_SAMPLES(i) (variants[i].count)\n";
+  print "#define VARIANT(i) (variants[i].name)\n";
 }
 
 # In some cases not storing a return value seems to result in the function call
@@ -85,7 +161,8 @@ if ($ret ne "void") {
   $getret = "ret = ";
 }
 
-print "#define BENCH_FUNC(j) ({$getret CALL_BENCH_FUNC (j);})\n";
+# And we're done.
+print "#define BENCH_FUNC(i, j) ({$getret CALL_BENCH_FUNC (i, j);})\n";
 
 print "#define FUNCNAME \"$func\"\n";
 print "#include \"bench-skeleton.c\"\n";

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d569c6eeb48219993063f956e516704281602f7d

commit d569c6eeb48219993063f956e516704281602f7d
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
Date:   Tue Apr 30 14:10:20 2013 +0530

    Maintain runtime of each benchmark at ~10 seconds
    
    The idea to run benchmarks for a constant number of iterations is
    problematic.  While the benchmarks may run for 10 seconds on x86_64,
    they could run for about 30 seconds on powerpc and worse, over 3
    minutes on arm.  Besides that, adding a new benchmark is cumbersome
    since one needs to find out the number of iterations needed for a
    sufficient runtime.
    
    A better idea would be to run each benchmark for a specific amount of
    time.  This patch does just that.  The run time defaults to 10 seconds
    and it is configurable at command line:
    
      make BENCH_DURATION=5 bench

diff --git a/ChangeLog b/ChangeLog
index a56bf73..07ec4d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-04-30  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+	* benchtests/Makefile: Remove *-ITER.  Define BENCH_DURATION
+	in CPPFLAGS.
+	($(objpfx)bench-%.c): Remove *-ITER.
+	* benchtests/bench-modf.c: Remove definition of ITER.
+	* benchtests/bench-skeleton.c (TIMESPEC_AFTER): New macro.
+	(main): Loop for DURATION seconds instead of fixed number of
+	iterations.
+	* scripts/bench.pl: Don't expect iterations in parameters.
+
 2013-04-29  Roland McGrath  <roland@hack.frob.com>
 
 	* io/fchdir.c (__fchdir): Renamed from fchdir.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 387fde4..9d25d69 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -23,12 +23,6 @@
 
 # - Append the function name to the bench variable
 
-# - Define foo-ITER with the number of iterations you want to run.  Keep it
-#   high enough that the overhead of clock_gettime is only a small fraction of
-#   the total run time of the test.  A good idea would be to keep the run time
-#   of each test at around 10 seconds for x86_64.  That is just a guideline,
-#   since some scenarios may require higher run times.
-
 # - Define foo-ARGLIST as a colon separated list of types of the input
 #   arguments.  Use `void` if function does not take any inputs.  Put in quotes
 #   if the input argument is a pointer, e.g.:
@@ -49,83 +43,70 @@ bench := exp pow rint sin cos tan atan modf \
 	 slowexp slowpow slowsin slowcos slowtan slowatan
 
 # exp function fast path: sysdeps/ieee754/dbl-64/e_exp.c
-exp-ITER = 5e8
 exp-ARGLIST = double
 exp-RET = double
 LDFLAGS-bench-exp = -lm
 
 # pow function fast path: sysdeps/ieee754/dbl-64/e_pow.c
-pow-ITER = 2e8
 pow-ARGLIST = double:double
 pow-RET = double
 LDFLAGS-bench-pow = -lm
 
-rint-ITER = 250000000
 rint-ARGLIST = double
 rint-RET = double
 LDFLAGS-bench-rint = -lm
 
 # exp function slowest path: sysdeps/ieee754/dbl-64/mpexp.c
-slowexp-ITER = 3e5
 slowexp-ARGLIST = double
 slowexp-RET = double
 slowexp-INCLUDE = slowexp.c
 LDFLAGS-bench-slowexp = -lm
 
 # sin function fast path: sysdeps/ieee754/dbl-64/s_sin.c
-sin-ITER = 3e9
 sin-ARGLIST = double
 sin-RET = double
 LDFLAGS-bench-sin = -lm
 
 # cos function fast path: sysdeps/ieee754/dbl-64/s_sin.c
-cos-ITER = 3e9
 cos-ARGLIST = double
 cos-RET = double
 LDFLAGS-bench-cos = -lm
 
 # tan function fast path: sysdeps/ieee754/dbl-64/s_tan.c
-tan-ITER = 3e9
 tan-ARGLIST = double
 tan-RET = double
 LDFLAGS-bench-tan = -lm
 
 # atan function fast path: sysdeps/ieee754/dbl-64/s_atan.c
-atan-ITER = 6e9
 atan-ARGLIST = double
 atan-RET = double
 LDFLAGS-bench-atan = -lm
 
 # pow function slowest path: sysdeps/ieee754/dbl-64/slowpow.c
-slowpow-ITER = 1e5
 slowpow-ARGLIST = double:double
 slowpow-RET = double
 slowpow-INCLUDE = slowpow.c
 LDFLAGS-bench-slowpow = -lm
 
 # sin function slowest path: sysdeps/ieee754/dbl-64/sincos32.c
-slowsin-ITER = 3e7
 slowsin-ARGLIST = double
 slowsin-RET = double
 slowsin-INCLUDE = slowsin.c
 LDFLAGS-bench-slowsin = -lm
 
 # cos function slowest path: sysdeps/ieee754/dbl-64/sincos32.c
-slowcos-ITER = 3e7
 slowcos-ARGLIST = double
 slowcos-RET = double
 slowcos-INCLUDE = slowcos.c
 LDFLAGS-bench-slowcos = -lm
 
 # tan function slowest path: sysdeps/ieee754/dbl-64/mptan.c
-slowtan-ITER = 3e7
 slowtan-ARGLIST = double
 slowtan-RET = double
 slowtan-INCLUDE = slowtan.c
 LDFLAGS-bench-slowtan = -lm
 
 # atan function slowest path: sysdeps/ieee754/dbl-64/mpatan.c
-slowatan-ITER = 3e8
 slowatan-ARGLIST = double
 slowatan-RET = double
 slowatan-INCLUDE = slowatan.c
@@ -141,6 +122,13 @@ include ../Rules
 
 binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
 
+# The default duration: 10 seconds.
+ifndef BENCH_DURATION
+BENCH_DURATION := 10
+endif
+
+CPPFLAGS-nonlib = -DDURATION=$(BENCH_DURATION)
+
 # This makes sure CPPFLAGS-nonlib and CFLAGS-nonlib are passed
 # for all these modules.
 cpp-srcs-left := $(binaries-bench:=.c)
@@ -176,5 +164,5 @@ $(objpfx)bench-%.c: %-inputs $(bench-deps)
 	  cat $($*-INCLUDE); \
 	fi; \
 	$(..)scripts/bench.pl $(patsubst %-inputs,%,$<) \
-	  $($*-ITER) $($*-ARGLIST) $($*-RET); } > $@-tmp
+	  $($*-ARGLIST) $($*-RET); } > $@-tmp
 	mv -f $@-tmp $@
diff --git a/benchtests/bench-modf.c b/benchtests/bench-modf.c
index 975a29f..90a5255 100644
--- a/benchtests/bench-modf.c
+++ b/benchtests/bench-modf.c
@@ -33,7 +33,6 @@ struct args
 static volatile double ret = 0.0;
 #define BENCH_FUNC(j) ({double iptr; ret =  CALL_BENCH_FUNC (j, iptr);})
 
-#define ITER 250000000
 #define FUNCNAME "modf"
 
 #include "bench-skeleton.c"
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c
index 13f986d..bbd151b 100644
--- a/benchtests/bench-skeleton.c
+++ b/benchtests/bench-skeleton.c
@@ -22,13 +22,18 @@
 #include <time.h>
 #include <inttypes.h>
 
+#define TIMESPEC_AFTER(a, b) \
+  (((a).tv_sec == (b).tv_sec) ?						      \
+     ((a).tv_nsec > (b).tv_nsec) :					      \
+        ((a).tv_sec > (b).tv_sec))
 int
 main (int argc, char **argv)
 {
-  unsigned long i, j, k;
+  unsigned long i, k;
   uint64_t total = 0, max = 0, min = 0x7fffffffffffffff;
-  struct timespec start, end;
+  struct timespec start, end, runtime;
 
+  memset (&runtime, 0, sizeof (runtime));
   memset (&start, 0, sizeof (start));
   memset (&end, 0, sizeof (end));
 
@@ -39,11 +44,15 @@ main (int argc, char **argv)
      Measurements close to the minimum clock resolution won't make much sense,
      but it's better than having nothing at all.  */
   unsigned long iters = 1000 * start.tv_nsec;
-  unsigned long total_iters = ITER / iters;
 
-  for (i = 0; i < NUM_SAMPLES; i++)
+  /* Run for approxmately DURATION seconds.  */
+  clock_gettime (CLOCK_MONOTONIC_RAW, &runtime);
+  runtime.tv_sec += DURATION;
+
+  double d_total_i = 0;
+  while (1)
     {
-      for (j = 0; j < total_iters; j ++)
+      for (i = 0; i < NUM_SAMPLES; i++)
 	{
 	  clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start);
 	  for (k = 0; k < iters; k++)
@@ -61,12 +70,25 @@ main (int argc, char **argv)
 	    min = cur;
 
 	  total += cur;
+
+	  d_total_i += iters;
 	}
+
+      struct timespec curtime;
+
+      memset (&curtime, 0, sizeof (curtime));
+      clock_gettime (CLOCK_MONOTONIC_RAW, &curtime);
+      if (TIMESPEC_AFTER (curtime, runtime))
+	goto done;
     }
 
-  double d_total_s = total * 1e-9;
-  double d_iters = iters;
-  double d_total_i = (double)ITER * NUM_SAMPLES;
+  double d_total_s;
+  double d_iters;
+
+ done:
+  d_total_s = total * 1e-9;
+  d_iters = iters;
+
   printf (FUNCNAME ": ITERS:%g: TOTAL:%gs, MAX:%gns, MIN:%gns, %g iter/s\n",
 	  d_total_i, d_total_s, max / d_iters, min / d_iters,
 	  d_total_i / d_total_s);
diff --git a/scripts/bench.pl b/scripts/bench.pl
index bb7f648..5856cfa 100755
--- a/scripts/bench.pl
+++ b/scripts/bench.pl
@@ -22,23 +22,22 @@ use warnings;
 # Generate a benchmark source file for a given input.
 
 if (@ARGV < 2) {
-  die "Usage: bench.pl <function> <iterations> [parameter types] [return type]"
+  die "Usage: bench.pl <function> [parameter types] [return type]"
 }
 
 my $arg;
 my $func = $ARGV[0];
-my $iters = $ARGV[1];
 my @args;
 my $ret = "void";
 my $getret = "";
 my $retval = "";
 
-if (@ARGV >= 3) {
-  @args = split(':', $ARGV[2]);
+if (@ARGV >= 2) {
+  @args = split(':', $ARGV[1]);
 }
 
-if (@ARGV == 4) {
-  $ret = $ARGV[3];
+if (@ARGV == 3) {
+  $ret = $ARGV[2];
 }
 
 my $decl = "extern $ret $func (";
@@ -88,6 +87,5 @@ if ($ret ne "void") {
 
 print "#define BENCH_FUNC(j) ({$getret CALL_BENCH_FUNC (j);})\n";
 
-print "#define ITER $iters\n";
 print "#define FUNCNAME \"$func\"\n";
 print "#include \"bench-skeleton.c\"\n";

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                      |   39 +
 benchtests/Makefile            |   73 +--
 benchtests/atan-inputs         |    6 +
 benchtests/bench-modf.c        |   13 +-
 benchtests/bench-skeleton.c    |   75 +-
 benchtests/cos-inputs          |    8 +
 benchtests/exp-inputs          |    4 +
 benchtests/pow-inputs          |    4 +
 benchtests/sin-inputs          |   10 +
 benchtests/slowatan-inputs     |    3 -
 benchtests/slowatan.c          |   19 -
 benchtests/slowcos-inputs      |    5 -
 benchtests/slowcos.c           |   19 -
 benchtests/slowexp-inputs      |    1 -
 benchtests/slowexp.c           |   19 -
 benchtests/slowpow-inputs      |    1 -
 benchtests/slowpow.c           |   19 -
 benchtests/slowsin-inputs      |    7 -
 benchtests/slowsin.c           |   19 -
 benchtests/slowtan-inputs      |    1 -
 benchtests/slowtan.c           |   19 -
 benchtests/tan-inputs          |    4 +
 scripts/bench.pl               |  117 ++-
 sysdeps/ieee754/dbl-64/s_sin.c | 2116 +++++++++++++++++++++++-----------------
 24 files changed, 1451 insertions(+), 1150 deletions(-)
 delete mode 100644 benchtests/slowatan-inputs
 delete mode 100644 benchtests/slowatan.c
 delete mode 100644 benchtests/slowcos-inputs
 delete mode 100644 benchtests/slowcos.c
 delete mode 100644 benchtests/slowexp-inputs
 delete mode 100644 benchtests/slowexp.c
 delete mode 100644 benchtests/slowpow-inputs
 delete mode 100644 benchtests/slowpow.c
 delete mode 100644 benchtests/slowsin-inputs
 delete mode 100644 benchtests/slowsin.c
 delete mode 100644 benchtests/slowtan-inputs
 delete mode 100644 benchtests/slowtan.c


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]