From abfbe76cb5adff2e7c9ddd4dc10c3dcc641d8949 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Sun, 14 Feb 2016 03:55:33 +0100 Subject: libm: remove dead code _IEEE_LIBM is always defined, so the other code is never used. I don't know when it was actively used. --- libm/Makefile.in | 5 +- libm/e_acos.c | 15 - libm/e_acosh.c | 15 - libm/e_asin.c | 15 - libm/e_atan2.c | 15 - libm/e_atanh.c | 20 -- libm/e_cosh.c | 15 - libm/e_exp.c | 22 -- libm/e_fmod.c | 15 - libm/e_hypot.c | 15 - libm/e_j0.c | 37 --- libm/e_j1.c | 36 --- libm/e_jn.c | 36 --- libm/e_lgamma_r.c | 41 --- libm/e_log.c | 15 - libm/e_log10.c | 18 -- libm/e_pow.c | 34 --- libm/e_remainder.c | 16 -- libm/e_scalb.c | 22 -- libm/e_sinh.c | 15 - libm/e_sqrt.c | 15 - libm/k_standard.c | 772 ---------------------------------------------------- libm/math_private.h | 3 - libm/s_matherr.c | 24 -- 24 files changed, 2 insertions(+), 1234 deletions(-) delete mode 100644 libm/k_standard.c delete mode 100644 libm/s_matherr.c (limited to 'libm') diff --git a/libm/Makefile.in b/libm/Makefile.in index f0e552880..835e7bf3f 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -23,7 +23,6 @@ subdirs += libm libm/$(TARGET_ARCH) CFLAGS-libm := -DNOT_IN_libc -DIS_IN_libm $(SSP_ALL_CFLAGS) -CFLAGS-libm += -D_IEEE_LIBM LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libm.so := -Wl,--dsbt-index=5 LDFLAGS-libm.so := $(LDFLAGS) @@ -59,11 +58,11 @@ libm_CSRC := \ e_exp.c e_exp10.c e_fmod.c e_hypot.c \ e_lgamma_r.c e_log.c e_log2.c e_log10.c \ e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \ - e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \ + e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_tan.c \ s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \ s_erf.c s_expm1.c s_fabs.c s_finite.c s_floor.c s_frexp.c \ s_ilogb.c s_ldexp.c s_lib_version.c s_lrint.c s_lround.c s_llround.c \ - s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c \ + s_log1p.c s_logb.c s_modf.c s_nextafter.c \ s_nextafterf.c s_round.c \ s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c s_tan.c \ s_tanh.c s_trunc.c \ diff --git a/libm/e_acos.c b/libm/e_acos.c index 8d2c880ac..acf10130e 100644 --- a/libm/e_acos.c +++ b/libm/e_acos.c @@ -96,20 +96,5 @@ double __ieee754_acos(double x) } } -/* - * wrap_acos(x) - */ -#ifndef _IEEE_LIBM -double acos(double x) -{ - double 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) */ - return z; -} -#else strong_alias(__ieee754_acos, acos) -#endif libm_hidden_def(acos) diff --git a/libm/e_acosh.c b/libm/e_acosh.c index 8f509e3b6..17e29c824 100644 --- a/libm/e_acosh.c +++ b/libm/e_acosh.c @@ -54,20 +54,5 @@ double __ieee754_acosh(double x) } } -/* - * wrapper acosh(x) - */ -#ifndef _IEEE_LIBM -double acosh(double x) -{ - double z = __ieee754_acosh(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (x < 1.0) - return __kernel_standard(x, x, 29); /* acosh(x<1) */ - return z; -} -#else strong_alias(__ieee754_acosh, acosh) -#endif libm_hidden_def(acosh) diff --git a/libm/e_asin.c b/libm/e_asin.c index 2801b323a..1441acb3d 100644 --- a/libm/e_asin.c +++ b/libm/e_asin.c @@ -105,20 +105,5 @@ double __ieee754_asin(double x) if(hx>0) return t; else return -t; } -/* - * wrapper asin(x) - */ -#ifndef _IEEE_LIBM -double asin(double x) -{ - double 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) */ - return z; -} -#else strong_alias(__ieee754_asin, asin) -#endif libm_hidden_def(asin) diff --git a/libm/e_atan2.c b/libm/e_atan2.c index ef7ffa9f1..ef379aa7a 100644 --- a/libm/e_atan2.c +++ b/libm/e_atan2.c @@ -115,20 +115,5 @@ double __ieee754_atan2(double y, double x) } } -/* - * wrapper atan2(y,x) - */ -#ifndef _IEEE_LIBM -double atan2(double y, double x) -{ - double z = __ieee754_atan2(y, x); - if (_LIB_VERSION == _IEEE_ || isnan(x) || isnan(y)) - return z; - if (x == 0.0 && y == 0.0) - return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ - return z; -} -#else strong_alias(__ieee754_atan2, atan2) -#endif libm_hidden_def(atan2) diff --git a/libm/e_atanh.c b/libm/e_atanh.c index ce8d5c750..fb36a1af1 100644 --- a/libm/e_atanh.c +++ b/libm/e_atanh.c @@ -55,25 +55,5 @@ double __ieee754_atanh(double x) if(hx>=0) return t; else return -t; } -/* - * wrapper atanh(x) - */ -#ifndef _IEEE_LIBM -double atanh(double x) -{ - double z, y; - z = __ieee754_atanh(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - y = fabs(x); - if (y >= 1.0) { - if (y > 1.0) - return __kernel_standard(x, x, 30); /* atanh(|x|>1) */ - return __kernel_standard(x, x, 31); /* atanh(|x|==1) */ - } - return z; -} -#else strong_alias(__ieee754_atanh, atanh) -#endif libm_hidden_def(atanh) diff --git a/libm/e_cosh.c b/libm/e_cosh.c index 6923b9300..a8e34aa45 100644 --- a/libm/e_cosh.c +++ b/libm/e_cosh.c @@ -78,20 +78,5 @@ double __ieee754_cosh(double x) return huge*huge; } -/* - * wrapper cosh(x) - */ -#ifndef _IEEE_LIBM -double cosh(double x) -{ - double z = __ieee754_cosh(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (fabs(x) > 7.10475860073943863426e+02) - return __kernel_standard(x, x, 5); /* cosh overflow */ - return z; -} -#else strong_alias(__ieee754_cosh, cosh) -#endif libm_hidden_def(cosh) diff --git a/libm/e_exp.c b/libm/e_exp.c index e82a6db08..ce958d111 100644 --- a/libm/e_exp.c +++ b/libm/e_exp.c @@ -156,27 +156,5 @@ double __ieee754_exp(double x) /* default IEEE double exp */ } } -/* - * wrapper exp(x) - */ -#ifndef _IEEE_LIBM -double exp(double x) -{ - static const double o_threshold = 7.09782712893383973096e+02; /* 0x40862E42, 0xFEFA39EF */ - static const double u_threshold = -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ - - double z = __ieee754_exp(x); - if (_LIB_VERSION == _IEEE_) - return z; - if (isfinite(x)) { - if (x > o_threshold) - return __kernel_standard(x, x, 6); /* exp overflow */ - if (x < u_threshold) - return __kernel_standard(x, x, 7); /* exp underflow */ - } - return z; -} -#else strong_alias(__ieee754_exp, exp) -#endif libm_hidden_def(exp) diff --git a/libm/e_fmod.c b/libm/e_fmod.c index 54062a59f..7857854f8 100644 --- a/libm/e_fmod.c +++ b/libm/e_fmod.c @@ -125,20 +125,5 @@ double __ieee754_fmod(double x, double y) return x; /* exact output */ } -/* - * wrapper fmod(x,y) - */ -#ifndef _IEEE_LIBM -double fmod(double x, double y) -{ - double 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) */ - return z; -} -#else strong_alias(__ieee754_fmod, fmod) -#endif libm_hidden_def(fmod) diff --git a/libm/e_hypot.c b/libm/e_hypot.c index e34338695..cd63b73ae 100644 --- a/libm/e_hypot.c +++ b/libm/e_hypot.c @@ -117,20 +117,5 @@ double __ieee754_hypot(double x, double y) } else return w; } -/* - * wrapper hypot(x,y) - */ -#ifndef _IEEE_LIBM -double hypot(double x, double y) -{ - double z = __ieee754_hypot(x, y); - if (_LIB_VERSION == _IEEE_) - return z; - if ((!isfinite(z)) && isfinite(x) && isfinite(y)) - return __kernel_standard(x, y, 4); /* hypot overflow */ - return z; -} -#else strong_alias(__ieee754_hypot, hypot) -#endif libm_hidden_def(hypot) diff --git a/libm/e_j0.c b/libm/e_j0.c index ac2e0eae9..f740d1902 100644 --- a/libm/e_j0.c +++ b/libm/e_j0.c @@ -123,22 +123,7 @@ double __ieee754_j0(double x) } } -/* - * wrapper j0(double x) - */ -#ifndef _IEEE_LIBM -double j0(double x) -{ - double z = __ieee754_j0(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (fabs(x) > X_TLOSS) - return __kernel_standard(x, x, 34); /* j0(|x|>X_TLOSS) */ - return z; -} -#else strong_alias(__ieee754_j0, j0) -#endif static const double u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */ @@ -205,29 +190,7 @@ double __ieee754_y0(double x) return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x))); } -/* - * wrapper y0(double x) - */ -#ifndef _IEEE_LIBM -double y0(double x) -{ - double z = __ieee754_y0(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (x <= 0.0) { - if (x == 0.0) /* d= -one/(x-x); */ - return __kernel_standard(x, x, 8); - /* d = zero/(x-x); */ - return __kernel_standard(x, x, 9); - } - if (x > X_TLOSS) - return __kernel_standard(x, x, 35); /* y0(x>X_TLOSS) */ - return z; -} -#else strong_alias(__ieee754_y0, y0) -#endif - /* The asymptotic expansions of pzero is * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. diff --git a/libm/e_j1.c b/libm/e_j1.c index 807edd8ba..78754b4c1 100644 --- a/libm/e_j1.c +++ b/libm/e_j1.c @@ -118,22 +118,7 @@ double __ieee754_j1(double x) return(x*0.5+r/s); } -/* - * wrapper of j1 - */ -#ifndef _IEEE_LIBM -double j1(double x) -{ - double z = __ieee754_j1(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (fabs(x) > X_TLOSS) - return __kernel_standard(x, x, 36); /* j1(|x|>X_TLOSS) */ - return z; -} -#else strong_alias(__ieee754_j1, j1) -#endif static const double U0[5] = { -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */ @@ -198,28 +183,7 @@ double __ieee754_y1(double x) return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); } -/* - * wrapper of y1 - */ -#ifndef _IEEE_LIBM -double y1(double x) -{ - double z = __ieee754_y1(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (x <= 0.0) { - if (x == 0.0) /* d = -one/(x-x); */ - return __kernel_standard(x, x, 10); - /* d = zero/(x-x); */ - return __kernel_standard(x, x, 11); - } - if (x > X_TLOSS) - return __kernel_standard(x, x, 37); /* y1(x>X_TLOSS) */ - return z; -} -#else strong_alias(__ieee754_y1, y1) -#endif /* For x >= 8, the asymptotic expansions of pone is * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. diff --git a/libm/e_jn.c b/libm/e_jn.c index 5f7d95adf..2133905e4 100644 --- a/libm/e_jn.c +++ b/libm/e_jn.c @@ -200,22 +200,7 @@ double __ieee754_jn(int n, double x) if(sgn==1) return -b; else return b; } -/* - * wrapper jn(int n, double x) - */ -#ifndef _IEEE_LIBM -double jn(int n, double x) -{ - double z = __ieee754_jn(n, x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (fabs(x) > X_TLOSS) - return __kernel_standard((double)n, x, 38); /* jn(|x|>X_TLOSS,n) */ - return z; -} -#else strong_alias(__ieee754_jn, jn) -#endif double __ieee754_yn(int n, double x) { @@ -274,25 +259,4 @@ double __ieee754_yn(int n, double x) if(sign>0) return b; else return -b; } -/* - * wrapper yn(int n, double x) - */ -#ifndef _IEEE_LIBM -double yn(int n, double x) /* wrapper yn */ -{ - double z = __ieee754_yn(n, x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (x <= 0.0) { - if(x == 0.0) /* d= -one/(x-x); */ - return __kernel_standard((double)n, x, 12); - /* d = zero/(x-x); */ - return __kernel_standard((double)n, x, 13); - } - if (x > X_TLOSS) - return __kernel_standard((double)n, x, 39); /* yn(x>X_TLOSS,n) */ - return z; -} -#else strong_alias(__ieee754_yn, yn) -#endif diff --git a/libm/e_lgamma_r.c b/libm/e_lgamma_r.c index c91166a19..82005ea17 100644 --- a/libm/e_lgamma_r.c +++ b/libm/e_lgamma_r.c @@ -295,25 +295,7 @@ double __ieee754_lgamma_r(double x, int *signgamp) return r; } -/* - * wrapper double lgamma_r(double x, int *signgamp) - */ -#ifndef _IEEE_LIBM -double lgamma_r(double x, int *signgamp) -{ - double y = __ieee754_lgamma_r(x, signgamp); - if (_LIB_VERSION == _IEEE_) - return y; - if (!isfinite(y) && isfinite(x)) { - if (floor(x) == x && x <= 0.0) - return __kernel_standard(x, x, 15); /* lgamma pole */ - return __kernel_standard(x, x, 14); /* lgamma overflow */ - } - return y; -} -#else strong_alias(__ieee754_lgamma_r, lgamma_r) -#endif libm_hidden_def(lgamma_r) /* __ieee754_lgamma(x) @@ -324,25 +306,7 @@ double __ieee754_lgamma(double x) return __ieee754_lgamma_r(x, &signgam); } -/* - * wrapper double lgamma(double x) - */ -#ifndef _IEEE_LIBM -double lgamma(double x) -{ - double y = __ieee754_lgamma_r(x, &signgam); - if (_LIB_VERSION == _IEEE_) - return y; - if (!isfinite(y) && isfinite(x)) { - if (floor(x) == x && x <= 0.0) - return __kernel_standard(x, x, 15); /* lgamma pole */ - return __kernel_standard(x, x, 14); /* lgamma overflow */ - } - return y; -} -#else strong_alias(__ieee754_lgamma, lgamma); -#endif libm_hidden_def(lgamma) @@ -352,13 +316,8 @@ libm_hidden_def(lgamma) * not a ln(|Gamma(x)|) but just Gamma(x), but standards * introduced tgamma name for that. */ -#ifndef _IEEE_LIBM -strong_alias(lgamma_r, gamma_r) -strong_alias(lgamma, gamma) -#else strong_alias(__ieee754_lgamma_r, gamma_r) strong_alias(__ieee754_lgamma, gamma) -#endif libm_hidden_def(gamma) diff --git a/libm/e_log.c b/libm/e_log.c index 2ee03ccc4..1ca453d04 100644 --- a/libm/e_log.c +++ b/libm/e_log.c @@ -128,20 +128,5 @@ double __ieee754_log(double x) } } -/* - * wrapper log(x) - */ -#ifndef _IEEE_LIBM -double log(double x) -{ - double z = __ieee754_log(x); - if (_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) - return z; - if (x == 0.0) - return __kernel_standard(x, x, 16); /* log(0) */ - return __kernel_standard(x, x, 17); /* log(x<0) */ -} -#else strong_alias(__ieee754_log, log) -#endif libm_hidden_def(log) diff --git a/libm/e_log10.c b/libm/e_log10.c index 877572536..3c62081e6 100644 --- a/libm/e_log10.c +++ b/libm/e_log10.c @@ -79,23 +79,5 @@ double __ieee754_log10(double x) return z+y*log10_2hi; } -/* - * wrapper log10(X) - */ -#ifndef _IEEE_LIBM -double log10(double x) -{ - double z = __ieee754_log10(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (x <= 0.0) { - if(x == 0.0) - return __kernel_standard(x, x, 18); /* log10(0) */ - return __kernel_standard(x, x, 19); /* log10(x<0) */ - } - return z; -} -#else strong_alias(__ieee754_log10, log10) -#endif libm_hidden_def(log10) diff --git a/libm/e_pow.c b/libm/e_pow.c index 4e22091be..1958fe619 100644 --- a/libm/e_pow.c +++ b/libm/e_pow.c @@ -300,39 +300,5 @@ double __ieee754_pow(double x, double y) return s*z; } -/* - * wrapper pow(x,y) return x**y - */ -#ifndef _IEEE_LIBM -double pow(double x, double y) -{ - double 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) */ - return z; - } - if (x == 0.0) { - if (y == 0.0) - return __kernel_standard(x, y, 20); /* pow(0.0,0.0) */ - if (isfinite(y) && y < 0.0) - return __kernel_standard(x,y,23); /* pow(0.0,negative) */ - return z; - } - if (!isfinite(z)) { - if (isfinite(x) && isfinite(y)) { - if (isnan(z)) - return __kernel_standard(x, y, 24); /* pow neg**non-int */ - return __kernel_standard(x, y, 21); /* pow overflow */ - } - } - if (z == 0.0 && isfinite(x) && isfinite(y)) - return __kernel_standard(x, y, 22); /* pow underflow */ - return z; -} -#else strong_alias(__ieee754_pow, pow) -#endif libm_hidden_def(pow) diff --git a/libm/e_remainder.c b/libm/e_remainder.c index 4ac24f295..8a00ff24f 100644 --- a/libm/e_remainder.c +++ b/libm/e_remainder.c @@ -64,22 +64,6 @@ double __ieee754_remainder(double x, double p) return x; } -/* - * wrapper remainder(x,p) - */ -#ifndef _IEEE_LIBM -double remainder(double x, double y) -{ - double z = __ieee754_remainder(x, y); - if (_LIB_VERSION == _IEEE_ || isnan(y)) - return z; - if (y == 0.0) - return __kernel_standard(x, y, 28); /* remainder(x,0) */ - return z; -} -strong_alias(remainder, drem) -#else strong_alias(__ieee754_remainder, remainder) strong_alias(__ieee754_remainder, drem) -#endif libm_hidden_def(remainder) diff --git a/libm/e_scalb.c b/libm/e_scalb.c index 9e1a3f742..cc85b48d3 100644 --- a/libm/e_scalb.c +++ b/libm/e_scalb.c @@ -33,28 +33,6 @@ double __ieee754_scalb(double x, double fn) } #if defined __UCLIBC_SUSV3_LEGACY__ -/* - * wrapper scalb(double x, double fn) is provided for - * passing various standard test suites. - * One should use scalbn() instead. - */ -#ifndef _IEEE_LIBM -double scalb(double x, double fn) -{ - double z = __ieee754_scalb(x, fn); - if (_LIB_VERSION == _IEEE_) - return z; - if (!(isfinite(z) || isnan(z)) && isfinite(x)) - return __kernel_standard(x, (double)fn, 32); /* scalb overflow */ - if (z == 0.0 && z != x) - return __kernel_standard(x, (double)fn, 33); /* scalb underflow */ - if (!isfinite(fn)) - errno = ERANGE; - return z; -} -#else strong_alias(__ieee754_scalb, scalb) -#endif libm_hidden_def(scalb) - #endif /* UCLIBC_SUSV3_LEGACY */ diff --git a/libm/e_sinh.c b/libm/e_sinh.c index a3dca9ded..52b33d5d1 100644 --- a/libm/e_sinh.c +++ b/libm/e_sinh.c @@ -71,20 +71,5 @@ double __ieee754_sinh(double x) return x*shuge; } -/* - * wrapper sinh(x) - */ -#ifndef _IEEE_LIBM -double sinh(double x) -{ - double z = __ieee754_sinh(x); - if (_LIB_VERSION == _IEEE_) - return z; - if (!isfinite(z) && isfinite(x)) - return __kernel_standard(x, x, 25); /* sinh overflow */ - return z; -} -#else strong_alias(__ieee754_sinh, sinh) -#endif libm_hidden_def(sinh) diff --git a/libm/e_sqrt.c b/libm/e_sqrt.c index 98d83c5a8..a5b2049bc 100644 --- a/libm/e_sqrt.c +++ b/libm/e_sqrt.c @@ -180,22 +180,7 @@ double __ieee754_sqrt(double x) return z; } -/* - * wrapper sqrt(x) - */ -#ifndef _IEEE_LIBM -double sqrt(double x) -{ - double z = __ieee754_sqrt(x); - if (_LIB_VERSION == _IEEE_ || isnan(x)) - return z; - if (x < 0.0) - return __kernel_standard(x, x, 26); /* sqrt(negative) */ - return z; -} -#else strong_alias(__ieee754_sqrt, sqrt) -#endif libm_hidden_def(sqrt) diff --git a/libm/k_standard.c b/libm/k_standard.c deleted file mode 100644 index 29e662d9c..000000000 --- a/libm/k_standard.c +++ /dev/null @@ -1,772 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include -#include "math_private.h" -#include - -#ifndef _IEEE_LIBM - -#ifndef _USE_WRITE -#include /* fputs(), stderr */ -#define WRITE2(u,v) fputs(u, stderr) -#else /* !defined(_USE_WRITE) */ -#include /* write */ -#define WRITE2(u,v) write(2, u, v) -#undef fflush -#endif /* !defined(_USE_WRITE) */ - -static const double zero = 0.0; /* used as const */ - -/* - * Standard conformance (non-IEEE) on exception cases. - * Mapping: - * 1 -- acos(|x|>1) - * 2 -- asin(|x|>1) - * 3 -- atan2(+-0,+-0) - * 4 -- hypot overflow - * 5 -- cosh overflow - * 6 -- exp overflow - * 7 -- exp underflow - * 8 -- y0(0) - * 9 -- y0(-ve) - * 10-- y1(0) - * 11-- y1(-ve) - * 12-- yn(0) - * 13-- yn(-ve) - * 14-- lgamma(finite) overflow - * 15-- lgamma(-integer) - * 16-- log(0) - * 17-- log(x<0) - * 18-- log10(0) - * 19-- log10(x<0) - * 20-- pow(0.0,0.0) - * 21-- pow(x,y) overflow - * 22-- pow(x,y) underflow - * 23-- pow(0,negative) - * 24-- pow(neg,non-integral) - * 25-- sinh(finite) overflow - * 26-- sqrt(negative) - * 27-- fmod(x,0) - * 28-- remainder(x,0) - * 29-- acosh(x<1) - * 30-- atanh(|x|>1) - * 31-- atanh(|x|=1) - * 32-- scalb overflow - * 33-- scalb underflow - * 34-- j0(|x|>X_TLOSS) - * 35-- y0(x>X_TLOSS) - * 36-- j1(|x|>X_TLOSS) - * 37-- y1(x>X_TLOSS) - * 38-- jn(|x|>X_TLOSS, n) - * 39-- yn(x>X_TLOSS, n) - * 40-- gamma(finite) overflow - * 41-- gamma(-integer) - * 42-- pow(NaN,0.0) - */ - -double __kernel_standard(double x, double y, int type) -{ - struct exception exc; -#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ -#define HUGE_VAL inf - double inf = 0.0; - - SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ -#endif - -#ifdef _USE_WRITE - (void) fflush(stdout); -#endif - exc.arg1 = x; - exc.arg2 = y; - switch(type) { - case 1: - case 101: - /* acos(|x|>1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "acos" : "acosf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if(_LIB_VERSION == _SVID_) { - (void) WRITE2("acos: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 2: - case 102: - /* asin(|x|>1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "asin" : "asinf"; - exc.retval = zero; - if(_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if(_LIB_VERSION == _SVID_) { - (void) WRITE2("asin: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 3: - case 103: - /* atan2(+-0,+-0) */ - exc.arg1 = y; - exc.arg2 = x; - exc.type = DOMAIN; - exc.name = type < 100 ? "atan2" : "atan2f"; - exc.retval = zero; - if(_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if(_LIB_VERSION == _SVID_) { - (void) WRITE2("atan2: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 4: - case 104: - /* hypot(finite,finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "hypot" : "hypotf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 5: - case 105: - /* cosh(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "cosh" : "coshf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 6: - case 106: - /* exp(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "exp" : "expf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 7: - case 107: - /* exp(finite) underflow */ - exc.type = UNDERFLOW; - exc.name = type < 100 ? "exp" : "expf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 8: - case 108: - /* y0(0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "y0" : "y0f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y0: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 9: - case 109: - /* y0(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = type < 100 ? "y0" : "y0f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y0: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 10: - case 110: - /* y1(0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "y1" : "y1f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y1: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 11: - case 111: - /* y1(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = type < 100 ? "y1" : "y1f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y1: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 12: - case 112: - /* yn(n,0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "yn" : "ynf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("yn: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 13: - case 113: - /* yn(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = type < 100 ? "yn" : "ynf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("yn: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 14: - case 114: - /* lgamma(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "lgamma" : "lgammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 15: - case 115: - /* lgamma(-integer) or lgamma(0) */ - exc.type = SING; - exc.name = type < 100 ? "lgamma" : "lgammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("lgamma: SING error\n", 19); - } - errno = EDOM; - } - break; - case 16: - case 116: - /* log(0) */ - exc.type = SING; - exc.name = type < 100 ? "log" : "logf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log: SING error\n", 16); - } - errno = EDOM; - } - break; - case 17: - case 117: - /* log(x<0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "log" : "logf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log: DOMAIN error\n", 18); - } - errno = EDOM; - } - break; - case 18: - case 118: - /* log10(0) */ - exc.type = SING; - exc.name = type < 100 ? "log10" : "log10f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log10: SING error\n", 18); - } - errno = EDOM; - } - break; - case 19: - case 119: - /* log10(x<0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "log10" : "log10f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log10: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 20: - case 120: - /* pow(0.0,0.0) */ - /* error only if _LIB_VERSION == _SVID_ */ - exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - exc.retval = zero; - if (_LIB_VERSION != _SVID_) exc.retval = 1.0; - else if (!matherr(&exc)) { - (void) WRITE2("pow(0,0): DOMAIN error\n", 23); - errno = EDOM; - } - break; - case 21: - case 121: - /* pow(x,y) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "pow" : "powf"; - if (_LIB_VERSION == _SVID_) { - exc.retval = HUGE; - y *= 0.5; - if(xzero) ? HUGE : -HUGE); - else - exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 26: - case 126: - /* sqrt(x<0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "sqrt" : "sqrtf"; - if (_LIB_VERSION == _SVID_) - exc.retval = zero; - else - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("sqrt: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 27: - case 127: - /* fmod(x,0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "fmod" : "fmodf"; - if (_LIB_VERSION == _SVID_) - exc.retval = x; - else - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("fmod: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 28: - case 128: - /* remainder(x,0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "remainder" : "remainderf"; - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("remainder: DOMAIN error\n", 24); - } - errno = EDOM; - } - break; - case 29: - case 129: - /* acosh(x<1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "acosh" : "acoshf"; - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("acosh: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 30: - case 130: - /* atanh(|x|>1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "atanh" : "atanhf"; - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("atanh: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 31: - case 131: - /* atanh(|x|=1) */ - exc.type = SING; - exc.name = type < 100 ? "atanh" : "atanhf"; - exc.retval = x/zero; /* sign(x)*inf */ - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("atanh: SING error\n", 18); - } - errno = EDOM; - } - break; -# ifdef __UCLIBC_SUSV3_LEGACY__ - case 32: - case 132: - /* scalb overflow; SVID also returns +-HUGE_VAL */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "scalb" : "scalbf"; - exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 33: - case 133: - /* scalb underflow */ - exc.type = UNDERFLOW; - exc.name = type < 100 ? "scalb" : "scalbf"; - exc.retval = copysign(zero,x); - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; -# endif - case 34: - case 134: - /* j0(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "j0" : "j0f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 35: - case 135: - /* y0(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "y0" : "y0f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 36: - case 136: - /* j1(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "j1" : "j1f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 37: - case 137: - /* y1(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "y1" : "y1f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 38: - case 138: - /* jn(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "jn" : "jnf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 39: - case 139: - /* yn(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "yn" : "ynf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 40: - case 140: - /* gamma(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "gamma" : "gammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 41: - case 141: - /* gamma(-integer) or gamma(0) */ - exc.type = SING; - exc.name = type < 100 ? "gamma" : "gammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("gamma: SING error\n", 18); - } - errno = EDOM; - } - break; - case 42: - case 142: - /* pow(NaN,0.0) */ - /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ - exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - exc.retval = x; - if (_LIB_VERSION == _IEEE_ || - _LIB_VERSION == _POSIX_) exc.retval = 1.0; - else if (!matherr(&exc)) { - errno = EDOM; - } - break; - } - return exc.retval; -} -#endif /* _IEEE_LIBM */ diff --git a/libm/math_private.h b/libm/math_private.h index b62dcfe1a..620ce9a44 100644 --- a/libm/math_private.h +++ b/libm/math_private.h @@ -180,9 +180,6 @@ extern int __ieee754_rem_pio2 (double,double*) attribute_hidden; extern double __ieee754_scalb (double,double) attribute_hidden; /* fdlibm kernel function */ -#ifndef _IEEE_LIBM -extern double __kernel_standard (double,double,int) attribute_hidden; -#endif extern double __kernel_sin (double,double,int) attribute_hidden; extern double __kernel_cos (double,double) attribute_hidden; extern double __kernel_tan (double,double,int) attribute_hidden; diff --git a/libm/s_matherr.c b/libm/s_matherr.c deleted file mode 100644 index 9a50459c8..000000000 --- a/libm/s_matherr.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include "math.h" -#include "math_private.h" - -#ifndef _IEEE_LIBM - -int matherr(struct exception *x) -{ - int n=0; - if(x->arg1!=x->arg1) return 0; - return n; -} -libm_hidden_def(matherr) -#endif -- cgit v1.2.3