diff --git a/.vscode/settings.json b/.vscode/settings.json index f41b8dff..3322a6d7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -58,7 +58,9 @@ "__mem.h": "c", "fdlibm.h": "c", "float.h": "c", - "corecrt_math_defines.h": "c" + "corecrt_math_defines.h": "c", + "math_ppc.h": "c", + "errno.h": "c" }, "search.useIgnoreFiles": false, "search.exclude": { diff --git a/configure.py b/configure.py index ce80b976..62f50acb 100644 --- a/configure.py +++ b/configure.py @@ -712,19 +712,19 @@ config.libs = [ Object(NonMatching, "MSL_C.PPCEABI.bare.H/k_sin.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/k_tan.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_atan.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_copysign.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_cos.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_copysign.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_cos.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_floor.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_frexp.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_ldexp.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_modf.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_sin.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_tan.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_acos.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_asin.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_modf.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_sin.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_tan.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/w_acos.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/w_asin.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/w_atan2.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_fmod.c"), - Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_pow.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/w_fmod.c"), + Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/w_pow.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/math_ppc.c"), ], }, diff --git a/include/PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math_ppc.h b/include/PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math_ppc.h new file mode 100644 index 00000000..325c4527 --- /dev/null +++ b/include/PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math_ppc.h @@ -0,0 +1,5 @@ +double acos(double x); +double tan(double); +double sin(double); +double cos(double); +double atan2(double); diff --git a/src/MSL_C.PPCEABI.bare.H/math_ppc.c b/src/MSL_C.PPCEABI.bare.H/math_ppc.c index 100dbfa0..54626547 100644 --- a/src/MSL_C.PPCEABI.bare.H/math_ppc.c +++ b/src/MSL_C.PPCEABI.bare.H/math_ppc.c @@ -1,8 +1,4 @@ -extern double tan(double); -extern double sin(double); -extern double cos(double); -extern double atan2(double); -extern double acos(double); +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math_ppc.h" float acosf(float arg0) { return (float) acos(arg0); diff --git a/src/MSL_C.PPCEABI.bare.H/s_copysign.c b/src/MSL_C.PPCEABI.bare.H/s_copysign.c new file mode 100644 index 00000000..d3313078 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/s_copysign.c @@ -0,0 +1,30 @@ +/* @(#)s_copysign.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * copysign(double x, double y) + * copysign(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double copysign(double x, double y) +#else + double copysign(x,y) + double x,y; +#endif +{ + __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000); + return x; +} diff --git a/src/MSL_C.PPCEABI.bare.H/s_cos.c b/src/MSL_C.PPCEABI.bare.H/s_cos.c new file mode 100644 index 00000000..0ceb1875 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/s_cos.c @@ -0,0 +1,78 @@ + +/* @(#)s_cos.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* cos(x) + * Return cosine function of x. + * + * kernel function: + * __kernel_sin ... sine function on [-pi/4,pi/4] + * __kernel_cos ... cosine function on [-pi/4,pi/4] + * __ieee754_rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double cos(double x) +#else + double cos(x) + double x; +#endif +{ + double y[2],z=0.0; + int n, ix; + + /* High word of x. */ + ix = __HI(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3fe921fb) return __kernel_cos(x,z); + + /* cos(Inf or NaN) is NaN */ + else if (ix>=0x7ff00000) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2(x,y); + switch(n&3) { + case 0: return __kernel_cos(y[0],y[1]); + case 1: return -__kernel_sin(y[0],y[1],1); + case 2: return -__kernel_cos(y[0],y[1]); + default: + return __kernel_sin(y[0],y[1],1); + } + } +} diff --git a/src/MSL_C.PPCEABI.bare.H/s_ldexp.c b/src/MSL_C.PPCEABI.bare.H/s_ldexp.c new file mode 100644 index 00000000..c43f64fb --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/s_ldexp.c @@ -0,0 +1,27 @@ +/* @(#)s_ldexp.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h" + +#ifdef __STDC__ + double ldexp(double value, int exp) +#else + double ldexp(value, exp) + double value; int exp; +#endif +{ + if(!finite(value)||value==0.0) return value; + value = scalbn(value,exp); + if(!finite(value)||value==0.0) errno = ERANGE; + return value; +} diff --git a/src/MSL_C.PPCEABI.bare.H/s_modf.c b/src/MSL_C.PPCEABI.bare.H/s_modf.c new file mode 100644 index 00000000..8c957d21 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/s_modf.c @@ -0,0 +1,80 @@ + +/* @(#)s_modf.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * modf(double x, double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ +static const double one = 1.0; +#else +static double one = 1.0; +#endif + +#ifdef __STDC__ + double modf(double x, double *iptr) +#else + double modf(x, iptr) + double x,*iptr; +#endif +{ + int i0,i1,j0; + unsigned i; + i0 = __HI(x); /* high x */ + i1 = __LO(x); /* low x */ + j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ + if(j0<20) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + __HIp(iptr) = i0&0x80000000; + __LOp(iptr) = 0; /* *iptr = +-0 */ + return x; + } else { + i = (0x000fffff)>>j0; + if(((i0&i)|i1)==0) { /* x is integral */ + *iptr = x; + __HI(x) &= 0x80000000; + __LO(x) = 0; /* return +-0 */ + return x; + } else { + __HIp(iptr) = i0&(~i); + __LOp(iptr) = 0; + return x - *iptr; + } + } + } else if (j0>51) { /* no fraction part */ + *iptr = x*one; + __HI(x) &= 0x80000000; + __LO(x) = 0; /* return +-0 */ + return x; + } else { /* fraction part in low x */ + i = ((unsigned)(0xffffffff))>>(j0-20); + if((i1&i)==0) { /* x is integral */ + *iptr = x; + __HI(x) &= 0x80000000; + __LO(x) = 0; /* return +-0 */ + return x; + } else { + __HIp(iptr) = i0; + __LOp(iptr) = i1&(~i); + return x - *iptr; + } + } +} diff --git a/src/MSL_C.PPCEABI.bare.H/s_sin.c b/src/MSL_C.PPCEABI.bare.H/s_sin.c new file mode 100644 index 00000000..5f09b616 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/s_sin.c @@ -0,0 +1,78 @@ + +/* @(#)s_sin.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* sin(x) + * Return sine function of x. + * + * kernel function: + * __kernel_sin ... sine function on [-pi/4,pi/4] + * __kernel_cos ... cose function on [-pi/4,pi/4] + * __ieee754_rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double sin(double x) +#else + double sin(x) + double x; +#endif +{ + double y[2],z=0.0; + int n, ix; + + /* High word of x. */ + ix = __HI(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); + + /* sin(Inf or NaN) is NaN */ + else if (ix>=0x7ff00000) return x-x; + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2(x,y); + switch(n&3) { + case 0: return __kernel_sin(y[0],y[1],1); + case 1: return __kernel_cos(y[0],y[1]); + case 2: return -__kernel_sin(y[0],y[1],1); + default: + return -__kernel_cos(y[0],y[1]); + } + } +} diff --git a/src/MSL_C.PPCEABI.bare.H/s_tan.c b/src/MSL_C.PPCEABI.bare.H/s_tan.c new file mode 100644 index 00000000..8a0b9292 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/s_tan.c @@ -0,0 +1,72 @@ + +/* @(#)s_tan.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* tan(x) + * Return tangent function of x. + * + * kernel function: + * __kernel_tan ... tangent function on [-pi/4,pi/4] + * __ieee754_rem_pio2 ... argument reduction routine + * + * Method. + * Let S,C and T denote the sin, cos and tan respectively on + * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 + * in [-pi/4 , +pi/4], and let n = k mod 4. + * We have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C T + * 1 C -S -1/T + * 2 -S -C T + * 3 -C S -1/T + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * TRIG(x) returns trig(x) nearly rounded + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double tan(double x) +#else + double tan(x) + double x; +#endif +{ + double y[2],z=0.0; + int n, ix; + + /* High word of x. */ + ix = __HI(x); + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1); + + /* tan(Inf or NaN) is NaN */ + else if (ix>=0x7ff00000) return x-x; /* NaN */ + + /* argument reduction needed */ + else { + n = __ieee754_rem_pio2(x,y); + return __kernel_tan(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even + -1 -- n odd */ + } +} diff --git a/src/MSL_C.PPCEABI.bare.H/w_acos.c b/src/MSL_C.PPCEABI.bare.H/w_acos.c new file mode 100644 index 00000000..dfc4c031 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/w_acos.c @@ -0,0 +1,38 @@ + +/* @(#)w_acos.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrap_acos(x) + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double acos(double x) /* wrapper acos */ +#else + double acos(x) /* wrapper acos */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_acos(x); +#else + double z; + z = __ieee754_acos(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(fabs(x)>1.0) { + return __kernel_standard(x,x,1); /* acos(|x|>1) */ + } else + return z; +#endif +} diff --git a/src/MSL_C.PPCEABI.bare.H/w_asin.c b/src/MSL_C.PPCEABI.bare.H/w_asin.c new file mode 100644 index 00000000..d21c6ce6 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/w_asin.c @@ -0,0 +1,38 @@ +/* @(#)w_asin.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + * + */ + +/* + * wrapper asin(x) + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double asin(double x) /* wrapper asin */ +#else + double asin(x) /* wrapper asin */ + double x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_asin(x); +#else + double z; + z = __ieee754_asin(x); + if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; + if(fabs(x)>1.0) { + return __kernel_standard(x,x,2); /* asin(|x|>1) */ + } else + return z; +#endif +} diff --git a/src/MSL_C.PPCEABI.bare.H/w_fmod.c b/src/MSL_C.PPCEABI.bare.H/w_fmod.c new file mode 100644 index 00000000..57c5cc16 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/w_fmod.c @@ -0,0 +1,37 @@ +/* @(#)w_fmod.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper fmod(x,y) + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + +#ifdef __STDC__ + double fmod(double x, double y) /* wrapper fmod */ +#else + double fmod(x,y) /* wrapper fmod */ + double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_fmod(x,y); +#else + double z; + z = __ieee754_fmod(x,y); + if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; + if(y==0.0) { + return __kernel_standard(x,y,27); /* fmod(x,0) */ + } else + return z; +#endif +} diff --git a/src/MSL_C.PPCEABI.bare.H/w_pow.c b/src/MSL_C.PPCEABI.bare.H/w_pow.c new file mode 100644 index 00000000..99c8e3b9 --- /dev/null +++ b/src/MSL_C.PPCEABI.bare.H/w_pow.c @@ -0,0 +1,60 @@ + + +/* @(#)w_pow.c 1.3 95/01/18 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunSoft, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper pow(x,y) return x**y + */ + +#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" + + +#ifdef __STDC__ + double pow(double x, double y) /* wrapper pow */ +#else + double pow(x,y) /* wrapper pow */ + double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_pow(x,y); +#else + double z; + z=__ieee754_pow(x,y); + if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; + if(isnan(x)) { + if(y==0.0) + return __kernel_standard(x,y,42); /* pow(NaN,0.0) */ + else + return z; + } + if(x==0.0){ + if(y==0.0) + return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ + if(finite(y)&&y<0.0) + return __kernel_standard(x,y,23); /* pow(0.0,negative) */ + return z; + } + if(!finite(z)) { + if(finite(x)&&finite(y)) { + if(isnan(z)) + return __kernel_standard(x,y,24); /* pow neg**non-int */ + else + return __kernel_standard(x,y,21); /* pow overflow */ + } + } + if(z==0.0&&finite(x)&&finite(y)) + return __kernel_standard(x,y,22); /* pow underflow */ + return z; +#endif +}