From 5d705f3c30775a04377f481e867c4661ed9e856f Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Fri, 27 Aug 2004 11:40:49 +0000 Subject: [PATCH] c.lib 1.174 (27.8.2004) - The parameters of atan2() were swapped. Fixed. - Merged fdlibm 5.3 changes with __kernel_tan(), __exp() and __pow() functions. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14718 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/amiga.lib_rev.h | 10 ++++----- library/amiga.lib_rev.rev | 2 +- library/c.lib_rev.h | 10 ++++----- library/c.lib_rev.rev | 2 +- library/changes | 8 ++++++++ library/debug.lib_rev.h | 10 ++++----- library/debug.lib_rev.rev | 2 +- library/m.lib_rev.h | 10 ++++----- library/m.lib_rev.rev | 2 +- library/m881.lib_rev.h | 10 ++++----- library/m881.lib_rev.rev | 2 +- library/math_atan2.c | 12 +++++------ library/math_exp.c | 4 ++-- library/math_kernel_tan.c | 18 ++++++++++++++-- library/math_pow.c | 43 ++++++++++++++++++--------------------- library/net.lib_rev.h | 10 ++++----- library/net.lib_rev.rev | 2 +- library/releasenotes | 11 +++++----- library/stack.lib_rev.h | 10 ++++----- library/stack.lib_rev.rev | 2 +- library/unix.lib_rev.h | 10 ++++----- library/unix.lib_rev.rev | 2 +- 22 files changed, 105 insertions(+), 87 deletions(-) diff --git a/library/amiga.lib_rev.h b/library/amiga.lib_rev.h index d95999d..45f3917 100644 --- a/library/amiga.lib_rev.h +++ b/library/amiga.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "amiga.lib 1.173" -#define VSTRING "amiga.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: amiga.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "amiga.lib 1.174" +#define VSTRING "amiga.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: amiga.lib 1.174 (27.8.2004)" diff --git a/library/amiga.lib_rev.rev b/library/amiga.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/amiga.lib_rev.rev +++ b/library/amiga.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/c.lib_rev.h b/library/c.lib_rev.h index 89679b0..df5691b 100644 --- a/library/c.lib_rev.h +++ b/library/c.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "c.lib 1.173" -#define VSTRING "c.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: c.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "c.lib 1.174" +#define VSTRING "c.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: c.lib 1.174 (27.8.2004)" diff --git a/library/c.lib_rev.rev b/library/c.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/c.lib_rev.rev +++ b/library/c.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/changes b/library/changes index 8157507..e8cc7d2 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,11 @@ +c.lib 1.174 (27.8.2004) + +- The parameters of atan2() were swapped. Fixed. + +- Merged fdlibm 5.3 changes with __kernel_tan(), __exp() and __pow() + functions. + + c.lib 1.173 (25.8.2004) - The header file was missing the C++ 'extern "C" { .. }' diff --git a/library/debug.lib_rev.h b/library/debug.lib_rev.h index 57ab992..4ef748a 100644 --- a/library/debug.lib_rev.h +++ b/library/debug.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "debug.lib 1.173" -#define VSTRING "debug.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: debug.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "debug.lib 1.174" +#define VSTRING "debug.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: debug.lib 1.174 (27.8.2004)" diff --git a/library/debug.lib_rev.rev b/library/debug.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/debug.lib_rev.rev +++ b/library/debug.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/m.lib_rev.h b/library/m.lib_rev.h index 3fdd4f7..4cb8f92 100644 --- a/library/m.lib_rev.h +++ b/library/m.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "m.lib 1.173" -#define VSTRING "m.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: m.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "m.lib 1.174" +#define VSTRING "m.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: m.lib 1.174 (27.8.2004)" diff --git a/library/m.lib_rev.rev b/library/m.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/m.lib_rev.rev +++ b/library/m.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/m881.lib_rev.h b/library/m881.lib_rev.h index 48a1c0d..c0458b5 100644 --- a/library/m881.lib_rev.h +++ b/library/m881.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "m881.lib 1.173" -#define VSTRING "m881.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: m881.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "m881.lib 1.174" +#define VSTRING "m881.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: m881.lib 1.174 (27.8.2004)" diff --git a/library/m881.lib_rev.rev b/library/m881.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/m881.lib_rev.rev +++ b/library/m881.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/math_atan2.c b/library/math_atan2.c index 5a0fce2..59b349a 100644 --- a/library/math_atan2.c +++ b/library/math_atan2.c @@ -1,5 +1,5 @@ /* - * $Id: math_atan2.c,v 1.2 2004-08-21 18:57:40 obarthel Exp $ + * $Id: math_atan2.c,v 1.3 2004-08-27 11:40:49 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ extern double __atan(double x); /****************************************************************************/ INLINE static const double -__atan2(double x,double y) +__atan2(double y,double x) { const double pi = 3.14159265358979323846; const double pi_over_2 = pi / 2.0; @@ -135,7 +135,7 @@ __atan(double x) } INLINE static const double -__atan2(double x,double y) +__atan2(double y,double x) { double pi,pi_over_2; double result; @@ -210,7 +210,7 @@ pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ INLINE static const double -__atan2(double x,double y) +__atan2(double y,double x) { double z; int k,m,hx,hy,ix,iy; @@ -319,11 +319,11 @@ __atan2(double x,double y) /****************************************************************************/ double -atan2(double x,double y) +atan2(double y,double x) { double result; - result = __atan2(x,y); + result = __atan2(y,x); return(result); } diff --git a/library/math_exp.c b/library/math_exp.c index a6bdf67..1572117 100644 --- a/library/math_exp.c +++ b/library/math_exp.c @@ -1,5 +1,5 @@ /* - * $Id: math_exp.c,v 1.1.1.1 2004-07-26 16:30:41 obarthel Exp $ + * $Id: math_exp.c,v 1.2 2004-08-27 11:40:49 obarthel Exp $ * * :ts=4 * @@ -194,7 +194,7 @@ __exp(double x) } else { - k = invln2*x+halF[xsb]; + k = (int)(invln2*x+halF[xsb]); t = k; hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */ lo = t*ln2LO[0]; diff --git a/library/math_kernel_tan.c b/library/math_kernel_tan.c index aadaf4c..04e6923 100644 --- a/library/math_kernel_tan.c +++ b/library/math_kernel_tan.c @@ -1,5 +1,5 @@ /* - * $Id: math_kernel_tan.c,v 1.1.1.1 2004-07-26 16:30:48 obarthel Exp $ + * $Id: math_kernel_tan.c,v 1.2 2004-08-27 11:40:49 obarthel Exp $ * * :ts=4 * @@ -82,7 +82,21 @@ double __kernel_tan(double x, double y, int iy) unsigned int low; GET_LOW_WORD(low,x); if(((ix|low)|(iy+1))==0) return one/fabs(x); - else return (iy==1)? x: -one/x; + else { + if (iy == 1) + return x; + else { /* compute -1 / (x+y) carefully */ + double a, t; + + z = w = x + y; + SET_LOW_WORD(z,0); + v = y - (z - x); + t = a = -one / w; + SET_LOW_WORD(t,0); + s = one + t * z; + return t + a * (s + t * v); + } + } } } if(ix>=0x3FE59428) { /* |x|>=0.6744 */ diff --git a/library/math_pow.c b/library/math_pow.c index 4958b2a..5459d8a 100644 --- a/library/math_pow.c +++ b/library/math_pow.c @@ -1,5 +1,5 @@ /* - * $Id: math_pow.c,v 1.1.1.1 2004-07-26 16:30:52 obarthel Exp $ + * $Id: math_pow.c,v 1.2 2004-08-27 11:40:49 obarthel Exp $ * * :ts=4 * @@ -286,11 +286,12 @@ __pow(double x,double y) } /* (x<0)**(non-int) is NaN */ - /* REDHAT LOCAL: This used to be - if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x); - but ANSI C says a right shift of a signed negative quantity is - implementation defined. */ - if(((((unsigned int)hx>>31)-1)|yisint)==0) return (x-x)/(x-x); + n = ((unsigned int)hx>>31)+1; + if((n|yisint)==0) return (x-x)/(x-x); + + s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ + if((n|(yisint-1))==0) + s = -one;/* (-ve)**(odd int) */ /* |y| is huge */ if(iy>0x41e00000) { /* if |y| > 2**31 */ @@ -299,11 +300,11 @@ __pow(double x,double y) if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; } /* over/underflow if x is not close to one */ - if(ix<0x3fefffff) return (hy<0)? huge*huge:tiny*tiny; - if(ix>0x3ff00000) return (hy>0)? huge*huge:tiny*tiny; + if(ix<0x3fefffff) return (hy<0)? s*huge*huge:s*tiny*tiny; + if(ix>0x3ff00000) return (hy>0)? s*huge*huge:s*tiny*tiny; /* now |1-x| is tiny <= 2**-20, suffice to compute log(x) by x-x^2/2+x^3/3-x^4/4 */ - t = ax-1; /* t has 20 trailing zeros */ + t = ax-one; /* t has 20 trailing zeros */ w = (t*t)*(0.5-t*(0.3333333333333333333333-t*0.25)); u = ivln2_h*t; /* ivln2_h has 21 sig. bits */ v = t*ivln2_l-w*ivln2; @@ -311,7 +312,7 @@ __pow(double x,double y) SET_LOW_WORD(t1,0); t2 = v-(t1-u); } else { - double s2,s_h,s_l,t_h,t_l; + double ss,s2,s_h,s_l,t_h,t_l; n = 0; /* take care subnormal number */ if(ix<0x00100000) @@ -325,11 +326,11 @@ __pow(double x,double y) else {k=0;n+=1;ix -= 0x00100000;} SET_HIGH_WORD(ax,ix); - /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ + /* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */ u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */ v = one/(ax+bp[k]); - s = u*v; - s_h = s; + ss = u*v; + s_h = ss; SET_LOW_WORD(s_h,0); /* t_h=ax+bp[k] High */ t_h = zero; @@ -337,33 +338,29 @@ __pow(double x,double y) t_l = ax - (t_h-bp[k]); s_l = v*((u-s_h*t_h)-s_h*t_l); /* compute log(ax) */ - s2 = s*s; + s2 = ss*ss; r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6))))); - r += s_l*(s_h+s); + r += s_l*(s_h+ss); s2 = s_h*s_h; t_h = 3.0+s2+r; SET_LOW_WORD(t_h,0); t_l = r-((t_h-3.0)-s2); - /* u+v = s*(1+...) */ + /* u+v = ss*(1+...) */ u = s_h*t_h; - v = s_l*t_h+t_l*s; - /* 2/(3log2)*(s+...) */ + v = s_l*t_h+t_l*ss; + /* 2/(3log2)*(ss+...) */ p_h = u+v; SET_LOW_WORD(p_h,0); p_l = v-(p_h-u); z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */ z_l = cp_l*p_h+p_l*cp+dp_l[k]; - /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */ + /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */ t = (double)n; t1 = (((z_h+z_l)+dp_h[k])+t); SET_LOW_WORD(t1,0); t2 = z_l-(((t1-t)-dp_h[k])-z_h); } - s = one; /* s (sign of result -ve**odd) = -1 else = 1 */ - if(((((unsigned int)hx>>31)-1)|(yisint-1))==0) - s = -one;/* (-ve)**(odd int) */ - /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ y1 = y; SET_LOW_WORD(y1,0); diff --git a/library/net.lib_rev.h b/library/net.lib_rev.h index 838f711..9f37779 100644 --- a/library/net.lib_rev.h +++ b/library/net.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "net.lib 1.173" -#define VSTRING "net.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: net.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "net.lib 1.174" +#define VSTRING "net.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: net.lib 1.174 (27.8.2004)" diff --git a/library/net.lib_rev.rev b/library/net.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/net.lib_rev.rev +++ b/library/net.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/releasenotes b/library/releasenotes index 9e9e643..d852cfc 100644 --- a/library/releasenotes +++ b/library/releasenotes @@ -1,7 +1,6 @@ -c.lib 1.173 (25.8.2004) +c.lib 1.174 (27.8.2004) -- You can now retrieve the low level file handle or socket descriptor - that is associated with a file descriptor, as used by this runtime - library. The new function is called "__get_default_file()", and the - function prototype and documentation can be found in the - header file. +- atan2() did not work correctly. Please rebuild any code that + uses it. + +- tan(), exp() and pow() now should return more accurate results. diff --git a/library/stack.lib_rev.h b/library/stack.lib_rev.h index e45abe6..01dbb79 100644 --- a/library/stack.lib_rev.h +++ b/library/stack.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "stack.lib 1.173" -#define VSTRING "stack.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: stack.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "stack.lib 1.174" +#define VSTRING "stack.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: stack.lib 1.174 (27.8.2004)" diff --git a/library/stack.lib_rev.rev b/library/stack.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/stack.lib_rev.rev +++ b/library/stack.lib_rev.rev @@ -1 +1 @@ -173 +174 diff --git a/library/unix.lib_rev.h b/library/unix.lib_rev.h index 33c9149..4f9edb8 100644 --- a/library/unix.lib_rev.h +++ b/library/unix.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 173 -#define DATE "25.8.2004" -#define VERS "unix.lib 1.173" -#define VSTRING "unix.lib 1.173 (25.8.2004)\r\n" -#define VERSTAG "\0$VER: unix.lib 1.173 (25.8.2004)" +#define REVISION 174 +#define DATE "27.8.2004" +#define VERS "unix.lib 1.174" +#define VSTRING "unix.lib 1.174 (27.8.2004)\r\n" +#define VERSTAG "\0$VER: unix.lib 1.174 (27.8.2004)" diff --git a/library/unix.lib_rev.rev b/library/unix.lib_rev.rev index c4597e5..c5356ba 100644 --- a/library/unix.lib_rev.rev +++ b/library/unix.lib_rev.rev @@ -1 +1 @@ -173 +174