This is the mail archive of the libc-alpha@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]

Re: [RFC] DO_NOT_USE_THIS - do not use this.


On Tue, Sep 03, 2013 at 08:23:24PM +0530, Siddhesh Poyarekar wrote:
> On Tue, Sep 03, 2013 at 04:44:42PM +0200, OndÅej BÃlka wrote:
> > Hi, when looking a cppcheck code we found blocks surrounded by
> > ifdef DO_NOT_USE_THIS.
> > 
> > They are now out of sync with code they are supposed to explain.
> > Should we remove them or change them to comment?
> > 
> 
> We should just remove them.  Please add a ChangeLog and repost.
> 
Here.

	* sysdeps/ieee754/dbl-64/e_j0.c: Remove DO_NOT_USE_THIS conditionals.
	* sysdeps/ieee754/dbl-64/e_j1.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_erf.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_expm1.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_log1p.c: Likewise.

---
 sysdeps/ieee754/dbl-64/e_j0.c    | 20 -----------------
 sysdeps/ieee754/dbl-64/e_j1.c    | 21 ------------------
 sysdeps/ieee754/dbl-64/s_erf.c   | 48 ----------------------------------------
 sysdeps/ieee754/dbl-64/s_expm1.c |  4 ----
 sysdeps/ieee754/dbl-64/s_log1p.c |  4 ----
 5 files changed, 97 deletions(-)

diff --git a/sysdeps/ieee754/dbl-64/e_j0.c b/sysdeps/ieee754/dbl-64/e_j0.c
index d641a09..ca54275 100644
--- a/sysdeps/ieee754/dbl-64/e_j0.c
+++ b/sysdeps/ieee754/dbl-64/e_j0.c
@@ -116,17 +116,12 @@ __ieee754_j0(double x)
 	  else	      return one - 0.25*x*x;
 	}
 	z = x*x;
-#ifdef DO_NOT_USE_THIS
-	r =  z*(R02+z*(R03+z*(R04+z*R05)));
-	s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
-#else
 	r1 = z*R[2]; z2=z*z;
 	r2 = R[3]+z*R[4]; z4=z2*z2;
 	r  = r1 + z2*r2 + z4*R[5];
 	s1 = one+z*S[1];
 	s2 = S[2]+z*S[3];
 	s = s1 + z2*s2 + z4*S[4];
-#endif
 	if(ix < 0x3FF00000) {	/* |x| < 1.00 */
 	    return one + z*(-0.25+(r/s));
 	} else {
@@ -196,10 +191,6 @@ __ieee754_y0(double x)
 	    return(U[0] + tpi*__ieee754_log(x));
 	}
 	z = x*x;
-#ifdef DO_NOT_USE_THIS
-	u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
-	v = one+z*(v01+z*(v02+z*(v03+z*v04)));
-#else
 	u1 = U[0]+z*U[1]; z2=z*z;
 	u2 = U[2]+z*U[3]; z4=z2*z2;
 	u3 = U[4]+z*U[5]; z6=z4*z2;
@@ -207,7 +198,6 @@ __ieee754_y0(double x)
 	v1 = one+z*V[0];
 	v2 = V[1]+z*V[2];
 	v = v1 + z2*v2 + z4*V[3];
-#endif
 	return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
 }
 strong_alias (__ieee754_y0, __y0_finite)
@@ -299,10 +289,6 @@ pzero(double x)
 	else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
 	else if(ix>=0x40000000){p = pR2; q= pS2;}
 	z = one/(x*x);
-#ifdef DO_NOT_USE_THIS
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
-#else
 	r1 = p[0]+z*p[1]; z2=z*z;
 	r2 = p[2]+z*p[3]; z4=z2*z2;
 	r3 = p[4]+z*p[5];
@@ -311,7 +297,6 @@ pzero(double x)
 	s2 = q[1]+z*q[2];
 	s3 = q[3]+z*q[4];
 	s = s1 + z2*s2 + z4*s3;
-#endif
 	return one+ r/s;
 }
 
@@ -407,10 +392,6 @@ qzero(double x)
 	else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
 	else if(ix>=0x40000000){p = qR2; q= qS2;}
 	z = one/(x*x);
-#ifdef DO_NOT_USE_THIS
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-#else
 	r1 = p[0]+z*p[1]; z2=z*z;
 	r2 = p[2]+z*p[3]; z4=z2*z2;
 	r3 = p[4]+z*p[5]; z6=z4*z2;
@@ -419,6 +400,5 @@ qzero(double x)
 	s2 = q[1]+z*q[2];
 	s3 = q[3]+z*q[4];
 	s = s1 + z2*s2 + z4*s3 +z6*q[5];
-#endif
 	return (-.125 + r/s)/x;
 }
diff --git a/sysdeps/ieee754/dbl-64/e_j1.c b/sysdeps/ieee754/dbl-64/e_j1.c
index cca5f20..12d5c40 100644
--- a/sysdeps/ieee754/dbl-64/e_j1.c
+++ b/sysdeps/ieee754/dbl-64/e_j1.c
@@ -116,11 +116,6 @@ __ieee754_j1(double x)
 	    if(huge+x>one) return 0.5*x;/* inexact if x!=0 necessary */
 	}
 	z = x*x;
-#ifdef DO_NOT_USE_THIS
-	r =  z*(r00+z*(r01+z*(r02+z*r03)));
-	s =  one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
-	r *= x;
-#else
 	r1 = z*R[0]; z2=z*z;
 	r2 = R[1]+z*R[2]; z4=z2*z2;
 	r = r1 + z2*r2 + z4*R[3];
@@ -129,7 +124,6 @@ __ieee754_j1(double x)
 	s2 = S[2]+z*S[3];
 	s3 = S[4]+z*S[5];
 	s = s1 + z2*s2 + z4*s3;
-#endif
 	return(x*0.5+r/s);
 }
 strong_alias (__ieee754_j1, __j1_finite)
@@ -193,10 +187,6 @@ __ieee754_y1(double x)
 	    return(-tpi/x);
 	}
 	z = x*x;
-#ifdef DO_NOT_USE_THIS
-	u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
-	v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
-#else
 	u1 = U0[0]+z*U0[1];z2=z*z;
 	u2 = U0[2]+z*U0[3];z4=z2*z2;
 	u  = u1 + z2*u2 + z4*U0[4];
@@ -204,7 +194,6 @@ __ieee754_y1(double x)
 	v2 = V0[1]+z*V0[2];
 	v3 = V0[3]+z*V0[4];
 	v = v1 + z2*v2 + z4*v3;
-#endif
 	return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x));
 }
 strong_alias (__ieee754_y1, __y1_finite)
@@ -297,10 +286,6 @@ pone(double x)
 	else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
 	else if(ix>=0x40000000){p = pr2; q= ps2;}
 	z = one/(x*x);
-#ifdef DO_NOT_USE_THIS
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
-#else
 	r1 = p[0]+z*p[1]; z2=z*z;
 	r2 = p[2]+z*p[3]; z4=z2*z2;
 	r3 = p[4]+z*p[5];
@@ -309,7 +294,6 @@ pone(double x)
 	s2 = q[1]+z*q[2];
 	s3 = q[3]+z*q[4];
 	s = s1 + z2*s2 + z4*s3;
-#endif
 	return one+ r/s;
 }
 
@@ -406,10 +390,6 @@ qone(double x)
 	else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
 	else if(ix>=0x40000000){p = qr2; q= qs2;}
 	z = one/(x*x);
-#ifdef DO_NOT_USE_THIS
-	r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
-	s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-#else
 	r1 = p[0]+z*p[1]; z2=z*z;
 	r2 = p[2]+z*p[3]; z4=z2*z2;
 	r3 = p[4]+z*p[5]; z6=z4*z2;
@@ -418,6 +398,5 @@ qone(double x)
 	s2 = q[1]+z*q[2];
 	s3 = q[3]+z*q[4];
 	s = s1 + z2*s2 + z4*s3 + z6*q[5];
-#endif
 	return (.375 + r/s)/x;
 }
diff --git a/sysdeps/ieee754/dbl-64/s_erf.c b/sysdeps/ieee754/dbl-64/s_erf.c
index e25e28d..0cf408c 100644
--- a/sysdeps/ieee754/dbl-64/s_erf.c
+++ b/sysdeps/ieee754/dbl-64/s_erf.c
@@ -209,10 +209,6 @@ double __erf(double x)
 		return x + efx*x;
 	    }
 	    z = x*x;
-#ifdef DO_NOT_USE_THIS
-	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
-	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
-#else
 	    r1 = pp[0]+z*pp[1]; z2=z*z;
 	    r2 = pp[2]+z*pp[3]; z4=z2*z2;
 	    s1 = one+z*qq[1];
@@ -220,17 +216,12 @@ double __erf(double x)
 	    s3 = qq[4]+z*qq[5];
             r = r1 + z2*r2 + z4*pp[4];
 	    s  = s1 + z2*s2 + z4*s3;
-#endif
 	    y = r/s;
 	    return x + x*y;
 	}
 	if(ix < 0x3ff40000) {		/* 0.84375 <= |x| < 1.25 */
 	    double s2,s4,s6,P1,P2,P3,P4,Q1,Q2,Q3,Q4;
 	    s = fabs(x)-one;
-#ifdef DO_NOT_USE_THIS
-	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
-	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
-#else
 	    P1 = pa[0]+s*pa[1]; s2=s*s;
 	    Q1 = one+s*qa[1];   s4=s2*s2;
 	    P2 = pa[2]+s*pa[3]; s6=s4*s2;
@@ -241,7 +232,6 @@ double __erf(double x)
 	    Q4 = qa[6];
 	    P = P1 + s2*P2 + s4*P3 + s6*P4;
 	    Q = Q1 + s2*Q2 + s4*Q3 + s6*Q4;
-#endif
 	    if(hx>=0) return erx + P/Q; else return -erx - P/Q;
 	}
 	if (ix >= 0x40180000) {		/* inf>|x|>=6 */
@@ -250,12 +240,6 @@ double __erf(double x)
 	x = fabs(x);
  	s = one/(x*x);
 	if(ix< 0x4006DB6E) {	/* |x| < 1/0.35 */
-#ifdef DO_NOT_USE_THIS
-	    R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
-				ra5+s*(ra6+s*ra7))))));
-	    S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
-				sa5+s*(sa6+s*(sa7+s*sa8)))))));
-#else
 	    double R1,R2,R3,R4,S1,S2,S3,S4,s2,s4,s6,s8;
 	    R1 = ra[0]+s*ra[1];s2 = s*s;
 	    S1 = one+s*sa[1];  s4 = s2*s2;
@@ -267,14 +251,7 @@ double __erf(double x)
 	    S4 = sa[6]+s*sa[7];
 	    R = R1 + s2*R2 + s4*R3 + s6*R4;
 	    S = S1 + s2*S2 + s4*S3 + s6*S4 + s8*sa[8];
-#endif
 	} else {	/* |x| >= 1/0.35 */
-#ifdef DO_NOT_USE_THIS
-	    R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
-				rb5+s*rb6)))));
-	    S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
-				sb5+s*(sb6+s*sb7))))));
-#else
 	    double R1,R2,R3,S1,S2,S3,S4,s2,s4,s6;
 	    R1 = rb[0]+s*rb[1];s2 = s*s;
 	    S1 = one+s*sb[1];  s4 = s2*s2;
@@ -285,7 +262,6 @@ double __erf(double x)
 	    S4 = sb[6]+s*sb[7];
 	    R = R1 + s2*R2 + s4*R3 + s6*rb[6];
 	    S = S1 + s2*S2 + s4*S3 + s6*S4;
-#endif
 	}
 	z  = x;
 	SET_LOW_WORD(z,0);
@@ -314,10 +290,6 @@ double __erfc(double x)
 	    if(ix < 0x3c700000)  	/* |x|<2**-56 */
 		return one-x;
 	    z = x*x;
-#ifdef DO_NOT_USE_THIS
-	    r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
-	    s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
-#else
 	    r1 = pp[0]+z*pp[1]; z2=z*z;
 	    r2 = pp[2]+z*pp[3]; z4=z2*z2;
 	    s1 = one+z*qq[1];
@@ -325,7 +297,6 @@ double __erfc(double x)
 	    s3 = qq[4]+z*qq[5];
             r = r1 + z2*r2 + z4*pp[4];
 	    s  = s1 + z2*s2 + z4*s3;
-#endif
 	    y = r/s;
 	    if(hx < 0x3fd00000) {  	/* x<1/4 */
 		return one-(x+x*y);
@@ -338,10 +309,6 @@ double __erfc(double x)
 	if(ix < 0x3ff40000) {		/* 0.84375 <= |x| < 1.25 */
 	    double s2,s4,s6,P1,P2,P3,P4,Q1,Q2,Q3,Q4;
 	    s = fabs(x)-one;
-#ifdef DO_NOT_USE_THIS
-	    P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
-	    Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
-#else
 	    P1 = pa[0]+s*pa[1]; s2=s*s;
 	    Q1 = one+s*qa[1];   s4=s2*s2;
 	    P2 = pa[2]+s*pa[3]; s6=s4*s2;
@@ -352,7 +319,6 @@ double __erfc(double x)
 	    Q4 = qa[6];
 	    P = P1 + s2*P2 + s4*P3 + s6*P4;
 	    Q = Q1 + s2*Q2 + s4*Q3 + s6*Q4;
-#endif
 	    if(hx>=0) {
 	        z  = one-erx; return z - P/Q;
 	    } else {
@@ -363,12 +329,6 @@ double __erfc(double x)
 	    x = fabs(x);
  	    s = one/(x*x);
 	    if(ix< 0x4006DB6D) {	/* |x| < 1/.35 ~ 2.857143*/
-#ifdef DO_NOT_USE_THIS
-	        R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
-				ra5+s*(ra6+s*ra7))))));
-	        S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
-				sa5+s*(sa6+s*(sa7+s*sa8)))))));
-#else
 		double R1,R2,R3,R4,S1,S2,S3,S4,s2,s4,s6,s8;
 	    R1 = ra[0]+s*ra[1];s2 = s*s;
 	    S1 = one+s*sa[1];  s4 = s2*s2;
@@ -380,16 +340,9 @@ double __erfc(double x)
 	    S4 = sa[6]+s*sa[7];
 	    R = R1 + s2*R2 + s4*R3 + s6*R4;
 	    S = S1 + s2*S2 + s4*S3 + s6*S4 + s8*sa[8];
-#endif
 	    } else {			/* |x| >= 1/.35 ~ 2.857143 */
 		double R1,R2,R3,S1,S2,S3,S4,s2,s4,s6;
 		if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */
-#ifdef DO_NOT_USE_THIS
-	        R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
-				rb5+s*rb6)))));
-	        S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
-				sb5+s*(sb6+s*sb7))))));
-#else
 		R1 = rb[0]+s*rb[1];s2 = s*s;
 		S1 = one+s*sb[1];  s4 = s2*s2;
 		R2 = rb[2]+s*rb[3];s6 = s4*s2;
@@ -399,7 +352,6 @@ double __erfc(double x)
 		S4 = sb[6]+s*sb[7];
 		R = R1 + s2*R2 + s4*R3 + s6*rb[6];
 		S = S1 + s2*S2 + s4*S3 + s6*S4;
-#endif
 	    }
 	    z  = x;
 	    SET_LOW_WORD(z,0);
diff --git a/sysdeps/ieee754/dbl-64/s_expm1.c b/sysdeps/ieee754/dbl-64/s_expm1.c
index 1a4bcd9..87da7eb 100644
--- a/sysdeps/ieee754/dbl-64/s_expm1.c
+++ b/sysdeps/ieee754/dbl-64/s_expm1.c
@@ -184,14 +184,10 @@ __expm1(double x)
     /* x is now in primary range */
 	hfx = 0.5*x;
 	hxs = x*hfx;
-#ifdef DO_NOT_USE_THIS
-	r1 = one+hxs*(Q1+hxs*(Q2+hxs*(Q3+hxs*(Q4+hxs*Q5))));
-#else
 	R1 = one+hxs*Q[1]; h2 = hxs*hxs;
 	R2 = Q[2]+hxs*Q[3]; h4 = h2*h2;
 	R3 = Q[4]+hxs*Q[5];
 	r1 = R1 + h2*R2 + h4*R3;
-#endif
 	t  = 3.0-r1*hfx;
 	e  = hxs*((r1-t)/(6.0 - x*t));
 	if(k==0) return x - (x*e-hxs);		/* c is 0 */
diff --git a/sysdeps/ieee754/dbl-64/s_log1p.c b/sysdeps/ieee754/dbl-64/s_log1p.c
index e3e6860..0c6f763 100644
--- a/sysdeps/ieee754/dbl-64/s_log1p.c
+++ b/sysdeps/ieee754/dbl-64/s_log1p.c
@@ -156,15 +156,11 @@ __log1p(double x)
 	}
 	s = f/(2.0+f);
 	z = s*s;
-#ifdef DO_NOT_USE_THIS
-	R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
-#else
 	R1 = z*Lp[1]; z2=z*z;
 	R2 = Lp[2]+z*Lp[3]; z4=z2*z2;
 	R3 = Lp[4]+z*Lp[5]; z6=z4*z2;
 	R4 = Lp[6]+z*Lp[7];
 	R = R1 + z2*R2 + z4*R3 + z6*R4;
-#endif
 	if(k==0) return f-(hfsq-s*(hfsq+R)); else
 		 return k*ln2_hi-((hfsq-(s*(hfsq+R)+(k*ln2_lo+c)))-f);
 }
-- 
1.8.3.2


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