diff options
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/e_log2l.c (renamed from sysdeps/generic/s_log2l.c) | 5 | ||||
-rw-r--r-- | sysdeps/generic/w_cosh.c | 2 | ||||
-rw-r--r-- | sysdeps/generic/w_coshf.c | 2 | ||||
-rw-r--r-- | sysdeps/generic/w_coshl.c | 2 | ||||
-rw-r--r-- | sysdeps/generic/w_exp10.c | 16 | ||||
-rw-r--r-- | sysdeps/generic/w_exp10f.c | 19 | ||||
-rw-r--r-- | sysdeps/generic/w_exp10l.c | 16 | ||||
-rw-r--r-- | sysdeps/generic/w_exp2.c | 4 | ||||
-rw-r--r-- | sysdeps/generic/w_exp2f.c | 4 | ||||
-rw-r--r-- | sysdeps/generic/w_exp2l.c | 5 | ||||
-rw-r--r-- | sysdeps/generic/w_log2.c | 32 | ||||
-rw-r--r-- | sysdeps/generic/w_log2f.c | 30 | ||||
-rw-r--r-- | sysdeps/generic/w_log2l.c | 28 |
13 files changed, 112 insertions, 53 deletions
diff --git a/sysdeps/generic/s_log2l.c b/sysdeps/generic/e_log2l.c index 835cd4f..681904b 100644 --- a/sysdeps/generic/s_log2l.c +++ b/sysdeps/generic/e_log2l.c @@ -3,13 +3,12 @@ #include <errno.h> long double -__log2l (long double x) +__ieee754_log2l (long double x) { - fputs ("__log2l not implemented\n", stderr); + fputs ("__ieee754_log2l not implemented\n", stderr); __set_errno (ENOSYS); return 0.0; } -weak_alias (__log2l, log2l) stub_warning (log2l) #include <stub-tag.h> diff --git a/sysdeps/generic/w_cosh.c b/sysdeps/generic/w_cosh.c index 8db25c8..709f485 100644 --- a/sysdeps/generic/w_cosh.c +++ b/sysdeps/generic/w_cosh.c @@ -34,7 +34,7 @@ static char rcsid[] = "$NetBSD: w_cosh.c,v 1.6 1995/05/10 20:48:47 jtc Exp $"; double z; z = __ieee754_cosh(x); if(_LIB_VERSION == _IEEE_ || __isnan(x)) return z; - if(fabs(x)>7.10475860073943863426e+02) { + if(!__finite(z) && __finite(x)) { return __kernel_standard(x,x,5); /* cosh overflow */ } else return z; diff --git a/sysdeps/generic/w_coshf.c b/sysdeps/generic/w_coshf.c index 53ca841..c38fd1d 100644 --- a/sysdeps/generic/w_coshf.c +++ b/sysdeps/generic/w_coshf.c @@ -37,7 +37,7 @@ static char rcsid[] = "$NetBSD: w_coshf.c,v 1.3 1995/05/10 20:48:49 jtc Exp $"; float z; z = __ieee754_coshf(x); if(_LIB_VERSION == _IEEE_ || __isnanf(x)) return z; - if(fabsf(x)>(float)8.9415985107e+01) { + if(!__finite(z) && __finite(x)) { /* cosh overflow */ return (float)__kernel_standard((double)x,(double)x,105); } else diff --git a/sysdeps/generic/w_coshl.c b/sysdeps/generic/w_coshl.c index 343d572..cc1929a 100644 --- a/sysdeps/generic/w_coshl.c +++ b/sysdeps/generic/w_coshl.c @@ -38,7 +38,7 @@ static char rcsid[] = "$NetBSD: $"; long double z; z = __ieee754_coshl(x); if(_LIB_VERSION == _IEEE_ || __isnanl(x)) return z; - if(fabsl(x)>7.10475860073943863426e+02) { + if(!__finite(z) && __finite(x)) { return __kernel_standard(x,x,205); /* cosh overflow */ } else return z; diff --git a/sysdeps/generic/w_exp10.c b/sysdeps/generic/w_exp10.c index bf0d361..597506f 100644 --- a/sysdeps/generic/w_exp10.c +++ b/sysdeps/generic/w_exp10.c @@ -21,14 +21,6 @@ #include "math_private.h" #ifdef __STDC__ -static const double -#else -static double -#endif -o_threshold= 3.0825471555991674389672e+02, -u_threshold= -3.2360724533877978485251e+02; - -#ifdef __STDC__ double __exp10(double x) /* wrapper exp10 */ #else double __exp10(x) /* wrapper exp10 */ @@ -41,11 +33,9 @@ u_threshold= -3.2360724533877978485251e+02; double z; z = __ieee754_exp10(x); if(_LIB_VERSION == _IEEE_) return z; - if(__finite(x)) { - if(x>o_threshold) - return __kernel_standard(x,x,46); /* exp10 overflow */ - else if(x<u_threshold) - return __kernel_standard(x,x,47); /* exp10 underflow */ + if(!__finite(z) && __finite(x)) { + /* exp10 overflow (46) if x > 0, underflow (47) if x < 0. */ + return __kernel_standard(x,x,46+!!__signbit(x)); } return z; #endif diff --git a/sysdeps/generic/w_exp10f.c b/sysdeps/generic/w_exp10f.c index f78be79..1c510a3 100644 --- a/sysdeps/generic/w_exp10f.c +++ b/sysdeps/generic/w_exp10f.c @@ -21,14 +21,6 @@ #include "math_private.h" #ifdef __STDC__ -static const float -#else -static float -#endif -o_threshold= 3.853183944498959298709e+01, -u_threshold= -4.515449934959717928174e+01; - -#ifdef __STDC__ float __exp10f(float x) /* wrapper exp10f */ #else float __exp10f(x) /* wrapper exp10f */ @@ -41,13 +33,10 @@ u_threshold= -4.515449934959717928174e+01; float z; z = __ieee754_exp10f(x); if(_LIB_VERSION == _IEEE_) return z; - if(__finitef(x)) { - if(x>o_threshold) - /* exp overflow */ - return (float)__kernel_standard((double)x,(double)x,146); - else if(x<u_threshold) - /* exp underflow */ - return (float)__kernel_standard((double)x,(double)x,147); + if(!__finitef(z) && __finitef(x)) { + /* exp10f overflow (146) if x > 0, underflow (147) if x < 0. */ + return (float)__kernel_standard((double) x, (double) x, + 146+!!__signbitf(x)); } return z; #endif diff --git a/sysdeps/generic/w_exp10l.c b/sysdeps/generic/w_exp10l.c index 7117873..aebddcb 100644 --- a/sysdeps/generic/w_exp10l.c +++ b/sysdeps/generic/w_exp10l.c @@ -22,14 +22,6 @@ #include "math_private.h" #ifdef __STDC__ -static const long double -#else -static long double -#endif -o_threshold= 4.93207544895866790234755e+03, -u_threshold= -4.95104033868549871764588e+03; - -#ifdef __STDC__ long double __exp10l(long double x) /* wrapper exp10 */ #else long double __exp10l(x) /* wrapper exp10 */ @@ -42,11 +34,9 @@ u_threshold= -4.95104033868549871764588e+03; long double z; z = __ieee754_exp10l(x); if(_LIB_VERSION == _IEEE_) return z; - if(__finitel(x)) { - if(x>o_threshold) - return __kernel_standard(x,x,246); /* exp10 overflow */ - else if(x<u_threshold) - return __kernel_standard(x,x,247); /* exp10 underflow */ + if(!__finitel(z) && __finitel(x)) { + /* exp10 overflow (246) if x > 0, underflow (247) if x < 0. */ + return __kernel_standard(x,x,246+__signbitl(x)); } return z; #endif diff --git a/sysdeps/generic/w_exp2.c b/sysdeps/generic/w_exp2.c index 126aa09..4e667d7 100644 --- a/sysdeps/generic/w_exp2.c +++ b/sysdeps/generic/w_exp2.c @@ -7,7 +7,7 @@ #include "math_private.h" static const double o_threshold= (double) DBL_MAX_EXP; -static const double u_threshold= (double) DBL_MIN_EXP; +static const double u_threshold= (double) (DBL_MIN_EXP - DBL_MANT_DIG - 1); double __exp2 (double x) /* wrapper exp2 */ @@ -22,7 +22,7 @@ __exp2 (double x) /* wrapper exp2 */ if (x > o_threshold) /* exp2 overflow */ return __kernel_standard (x, x, 44); - else if (x < u_threshold) + else if (x <= u_threshold) /* exp2 underflow */ return __kernel_standard (x, x, 45); } diff --git a/sysdeps/generic/w_exp2f.c b/sysdeps/generic/w_exp2f.c index d2c340d..13cfc9a 100644 --- a/sysdeps/generic/w_exp2f.c +++ b/sysdeps/generic/w_exp2f.c @@ -7,7 +7,7 @@ #include "math_private.h" static const float o_threshold= (float) FLT_MAX_EXP; -static const float u_threshold= (float) FLT_MIN_EXP; +static const float u_threshold= (float) (FLT_MIN_EXP - FLT_MANT_DIG - 1); float __exp2f (float x) /* wrapper exp2f */ @@ -22,7 +22,7 @@ __exp2f (float x) /* wrapper exp2f */ if (x > o_threshold) /* exp2 overflow */ return (float) __kernel_standard ((double) x, (double) x, 144); - else if (x < u_threshold) + else if (x <= u_threshold) /* exp2 underflow */ return (float) __kernel_standard ((double) x, (double) x, 145); } diff --git a/sysdeps/generic/w_exp2l.c b/sysdeps/generic/w_exp2l.c index 965e9bf..f492301 100644 --- a/sysdeps/generic/w_exp2l.c +++ b/sysdeps/generic/w_exp2l.c @@ -7,7 +7,8 @@ #include "math_private.h" static const long double o_threshold = (long double) LDBL_MAX_EXP; -static const long double u_threshold = (long double) LDBL_MIN_EXP; +static const long double u_threshold + = (long double) (LDBL_MIN_EXP - LDBL_MANT_DIG - 1); long double __exp2l (long double x) /* wrapper exp2l */ @@ -21,7 +22,7 @@ __exp2l (long double x) /* wrapper exp2l */ { if (x > o_threshold) return __kernel_standard (x, x, 244); /* exp2l overflow */ - else if (x < u_threshold) + else if (x <= u_threshold) return __kernel_standard (x, x, 245); /* exp2l underflow */ } return z; diff --git a/sysdeps/generic/w_log2.c b/sysdeps/generic/w_log2.c new file mode 100644 index 0000000..7966ff3 --- /dev/null +++ b/sysdeps/generic/w_log2.c @@ -0,0 +1,32 @@ +/* + * wrapper log2(X) + */ + +#include "math.h" +#include "math_private.h" + +double +__log2 (double x) /* wrapper log2 */ +{ +#ifdef _IEEE_LIBM + return __ieee754_log2 (x); +#else + double z; + z = __ieee754_log2 (x); + if (_LIB_VERSION == _IEEE_ || __isnan (x)) return z; + if (x <= 0.0) + { + if (x == 0.0) + return __kernel_standard (x, x, 48); /* log2 (0) */ + else + return __kernel_standard (x, x, 49); /* log2 (x < 0) */ + } + else + return z; +#endif +} +weak_alias (__log2, log2) +#ifdef NO_LONG_DOUBLE +strong_alias (__log2, __log2l) +weak_alias (__log2, log2l) +#endif diff --git a/sysdeps/generic/w_log2f.c b/sysdeps/generic/w_log2f.c new file mode 100644 index 0000000..1e2eb85 --- /dev/null +++ b/sysdeps/generic/w_log2f.c @@ -0,0 +1,30 @@ +/* + * wrapper log2(X) + */ + +#include "math.h" +#include "math_private.h" + +float +__log2f (float x) /* wrapper log2f */ +{ +#ifdef _IEEE_LIBM + return __ieee754_log2f (x); +#else + float z; + z = __ieee754_log2f (x); + if (_LIB_VERSION == _IEEE_ || __isnanf (x)) return z; + if (x <= 0.0f) + { + if (x == 0.0f) + /* log2f (0) */ + return __kernel_standard ((double) x, (double) x, 148); + else + /* log2f (x < 0) */ + return __kernel_standard ((double) x, (double) x, 149); + } + else + return z; +#endif +} +weak_alias (__log2f, log2f) diff --git a/sysdeps/generic/w_log2l.c b/sysdeps/generic/w_log2l.c new file mode 100644 index 0000000..f41757c --- /dev/null +++ b/sysdeps/generic/w_log2l.c @@ -0,0 +1,28 @@ +/* + * wrapper log2l(X) + */ + +#include "math.h" +#include "math_private.h" + +long double +__log2l (long double x) /* wrapper log2l */ +{ +#ifdef _IEEE_LIBM + return __ieee754_log2l (x); +#else + long double z; + z = __ieee754_log2l (x); + if (_LIB_VERSION == _IEEE_ || __isnanl (x)) return z; + if (x <= 0.0) + { + if (x == 0.0) + return __kernel_standard (x, x, 248); /* log2l (0) */ + else + return __kernel_standard (x, x, 249); /* log2l (x < 0) */ + } + else + return z; +#endif +} +weak_alias (__log2l, log2l) |