summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/complex.h8
-rw-r--r--include/math.h18
-rw-r--r--include/tgmath.h2
-rw-r--r--libc/sysdeps/linux/common/bits/cmathcalls.h23
-rw-r--r--libc/sysdeps/linux/common/bits/mathcalls.h79
-rw-r--r--libc/sysdeps/linux/common/bits/mathdef.h6
-rw-r--r--libm/Makefile.in60
-rw-r--r--libm/carg.c4
-rw-r--r--libm/e_acosh.c2
-rw-r--r--libm/e_asin.c1
-rw-r--r--libm/e_atan2.c2
-rw-r--r--libm/e_atanh.c1
-rw-r--r--libm/e_cosh.c2
-rw-r--r--libm/e_gamma.c3
-rw-r--r--libm/e_gamma_r.c2
-rw-r--r--libm/e_j0.c4
-rw-r--r--libm/e_j1.c4
-rw-r--r--libm/e_jn.c4
-rw-r--r--libm/e_lgamma.c3
-rw-r--r--libm/e_lgamma_r.c5
-rw-r--r--libm/e_log2.c130
-rw-r--r--libm/e_pow.c2
-rw-r--r--libm/e_rem_pio2.c1
-rw-r--r--libm/e_remainder.c1
-rw-r--r--libm/e_scalb.c4
-rw-r--r--libm/e_sinh.c2
-rw-r--r--libm/float_wrappers.c57
-rw-r--r--libm/fp_private.h90
-rw-r--r--libm/fpmacros.c303
-rw-r--r--libm/k_rem_pio2.c2
-rw-r--r--libm/k_standard.c3
-rw-r--r--libm/k_tan.c1
-rw-r--r--libm/ldouble_wrappers.c523
-rw-r--r--libm/math_private.h1
-rw-r--r--libm/nan.c50
-rw-r--r--libm/powerpc/classic/s_ceil.c113
-rw-r--r--libm/powerpc/classic/s_copysign.c59
-rw-r--r--libm/powerpc/classic/s_floor.c113
-rw-r--r--libm/powerpc/classic/s_frexp.c65
-rw-r--r--libm/powerpc/classic/s_ldexp.c49
-rw-r--r--libm/powerpc/classic/s_logb.c107
-rw-r--r--libm/powerpc/classic/s_modf.c344
-rw-r--r--libm/powerpc/classic/s_nearbyint.c38
-rw-r--r--libm/powerpc/classic/s_rint.c159
-rw-r--r--libm/powerpc/classic/s_round.c115
-rw-r--r--libm/powerpc/classic/s_trunc.c89
-rw-r--r--libm/powerpc/classic/w_scalb.c94
-rw-r--r--libm/s_asinh.c3
-rw-r--r--libm/s_atan.c2
-rw-r--r--libm/s_cbrt.c1
-rw-r--r--libm/s_ceil.c1
-rw-r--r--libm/s_copysign.c1
-rw-r--r--libm/s_cos.c1
-rw-r--r--libm/s_erf.c3
-rw-r--r--libm/s_expm1.c1
-rw-r--r--libm/s_fabs.c1
-rw-r--r--libm/s_fdim.c24
-rw-r--r--libm/s_finite.c17
-rw-r--r--libm/s_finitef.c32
-rw-r--r--libm/s_floor.c1
-rw-r--r--libm/s_fma.c30
-rw-r--r--libm/s_fmax.c25
-rw-r--r--libm/s_fmin.c25
-rw-r--r--libm/s_fpclassify.c43
-rw-r--r--libm/s_fpclassifyf.c42
-rw-r--r--libm/s_frexp.c1
-rw-r--r--libm/s_ilogb.c1
-rw-r--r--libm/s_isinf.c26
-rw-r--r--libm/s_isinff.c26
-rw-r--r--libm/s_isnan.c37
-rw-r--r--libm/s_isnanf.c34
-rw-r--r--libm/s_ldexp.c3
-rw-r--r--libm/s_llrint.c2
-rw-r--r--libm/s_llround.c1
-rw-r--r--libm/s_log1p.c1
-rw-r--r--libm/s_logb.c2
-rw-r--r--libm/s_lrint.c1
-rw-r--r--libm/s_lround.c1
-rw-r--r--libm/s_matherr.c1
-rw-r--r--libm/s_modf.c1
-rw-r--r--libm/s_nearbyint.c24
-rw-r--r--libm/s_nextafter.c1
-rw-r--r--libm/s_remquo.c37
-rw-r--r--libm/s_rint.c1
-rw-r--r--libm/s_round.c1
-rw-r--r--libm/s_scalbln.c62
-rw-r--r--libm/s_scalbn.c2
-rw-r--r--libm/s_signbit.c33
-rw-r--r--libm/s_signbitf.c34
-rw-r--r--libm/s_significand.c2
-rw-r--r--libm/s_sin.c1
-rw-r--r--libm/s_tan.c1
-rw-r--r--libm/s_tanh.c3
-rw-r--r--libm/s_trunc.c1
-rw-r--r--libm/w_acos.c1
-rw-r--r--libm/w_acosh.c1
-rw-r--r--libm/w_asin.c1
-rw-r--r--libm/w_atan2.c1
-rw-r--r--libm/w_atanh.c1
-rw-r--r--libm/w_cabs.c2
-rw-r--r--libm/w_cosh.c1
-rw-r--r--libm/w_drem.c2
-rw-r--r--libm/w_exp.c1
-rw-r--r--libm/w_exp2.c26
-rw-r--r--libm/w_fmod.c1
-rw-r--r--libm/w_gamma.c2
-rw-r--r--libm/w_gamma_r.c2
-rw-r--r--libm/w_hypot.c1
-rw-r--r--libm/w_j0.c2
-rw-r--r--libm/w_j1.c2
-rw-r--r--libm/w_jn.c2
-rw-r--r--libm/w_lgamma.c2
-rw-r--r--libm/w_lgamma_r.c2
-rw-r--r--libm/w_log.c1
-rw-r--r--libm/w_log10.c1
-rw-r--r--libm/w_log2.c14
-rw-r--r--libm/w_pow.c1
-rw-r--r--libm/w_remainder.c1
-rw-r--r--libm/w_scalb.c1
-rw-r--r--libm/w_sinh.c1
-rw-r--r--libm/w_sqrt.c1
-rw-r--r--libm/w_tgamma.c47
122 files changed, 1485 insertions, 1978 deletions
diff --git a/include/complex.h b/include/complex.h
index f005a9391..94fb6ea44 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -62,7 +62,7 @@ __BEGIN_DECLS
#define __MATHDECL_1(type, function, args) \
extern type __MATH_PRECNAME(function) args __THROW
-#define _Mdouble_ double
+#define _Mdouble_ double
#define __MATH_PRECNAME(name) name
#include <bits/cmathcalls.h>
#undef _Mdouble_
@@ -72,7 +72,7 @@ __BEGIN_DECLS
#ifndef _Mfloat_
# define _Mfloat_ float
#endif
-#define _Mdouble_ _Mfloat_
+#define _Mdouble_ _Mfloat_
#ifdef __STDC__
# define __MATH_PRECNAME(name) name##f
#else
@@ -84,11 +84,11 @@ __BEGIN_DECLS
/* And the long double versions. It is non-critical to define them
here unconditionally since `long double' is required in ISO C99. */
-#if __STDC__ - 0 || __GNUC__ - 0 && !defined __NO_LONG_DOUBLE_MATH
+#if __STDC__ - 0 || __GNUC__ - 0 && defined __UCLIBC_HAS_LONG_DOUBLE_MATH__
# ifndef _Mlong_double_
# define _Mlong_double_ long double
# endif
-# define _Mdouble_ _Mlong_double_
+# define _Mdouble_ _Mlong_double_
# ifdef __STDC__
# define __MATH_PRECNAME(name) name##l
# else
diff --git a/include/math.h b/include/math.h
index 34c042dc5..ae5d6ec70 100644
--- a/include/math.h
+++ b/include/math.h
@@ -64,7 +64,7 @@ __BEGIN_DECLS
#define __MATHDECL_1(type, function,suffix, args) \
extern type __MATH_PRECNAME(function,suffix) args __THROW
-#define _Mdouble_ double
+#define _Mdouble_ double
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
# define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
@@ -83,7 +83,7 @@ __BEGIN_DECLS
# ifndef _Mfloat_
# define _Mfloat_ float
# endif
-# define _Mdouble_ _Mfloat_
+# define _Mdouble_ _Mfloat_
# ifdef __STDC__
# define __MATH_PRECNAME(name,r) name##f##r
# else
@@ -98,7 +98,7 @@ __BEGIN_DECLS
# undef __MATH_PRECNAME
# if (__STDC__ - 0 || __GNUC__ - 0) \
- && (!defined __NO_LONG_DOUBLE_MATH || defined __LDBL_COMPAT)
+ && (defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ || defined __LDBL_COMPAT)
# ifdef __LDBL_COMPAT
# ifdef __USE_ISOC99
@@ -130,7 +130,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
# ifndef _Mlong_double_
# define _Mlong_double_ long double
# endif
-# define _Mdouble_ _Mlong_double_
+# define _Mdouble_ _Mlong_double_
# ifdef __STDC__
# define __MATH_PRECNAME(name,r) name##l##r
# else
@@ -210,7 +210,7 @@ enum
};
/* Return number of classification appropriate for X. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# ifndef __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define fpclassify(x) \
(sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
# else
@@ -222,7 +222,7 @@ enum
# endif
/* Return nonzero value if sign of X is negative. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# ifndef __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define signbit(x) \
(sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
# else
@@ -234,7 +234,7 @@ enum
# endif
/* Return nonzero value if X is not +-Inf or NaN. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# ifndef __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define isfinite(x) \
(sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
# else
@@ -250,7 +250,7 @@ enum
/* Return nonzero value if X is a NaN. We could use `fpclassify' but
we already have this functions `__isnan' and it is faster. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# ifndef __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define isnan(x) \
(sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
# else
@@ -262,7 +262,7 @@ enum
# endif
/* Return nonzero value is X is positive or negative infinity. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# ifndef __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define isinf(x) \
(sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
# else
diff --git a/include/tgmath.h b/include/tgmath.h
index 5fb683fef..685a34588 100644
--- a/include/tgmath.h
+++ b/include/tgmath.h
@@ -36,7 +36,7 @@
#if __GNUC_PREREQ (2, 7)
-# ifdef __NO_LONG_DOUBLE_MATH
+# ifndef __UCLIBC_HAS_LONG_DOUBLE_MATH__
# define __tgml(fct) fct
# else
# define __tgml(fct) fct ## l
diff --git a/libc/sysdeps/linux/common/bits/cmathcalls.h b/libc/sysdeps/linux/common/bits/cmathcalls.h
index 35237b35d..762c1e3c1 100644
--- a/libc/sysdeps/linux/common/bits/cmathcalls.h
+++ b/libc/sysdeps/linux/common/bits/cmathcalls.h
@@ -52,81 +52,104 @@
/* Arc cosine of Z. */
__MATHCALL (cacos, (_Mdouble_complex_ __z));
+libm_hidden_proto(cacos)
/* Arc sine of Z. */
__MATHCALL (casin, (_Mdouble_complex_ __z));
+libm_hidden_proto(casin)
/* Arc tangent of Z. */
__MATHCALL (catan, (_Mdouble_complex_ __z));
+libm_hidden_proto(catan)
/* Cosine of Z. */
__MATHCALL (ccos, (_Mdouble_complex_ __z));
+libm_hidden_proto(ccos)
/* Sine of Z. */
__MATHCALL (csin, (_Mdouble_complex_ __z));
+libm_hidden_proto(csin)
/* Tangent of Z. */
__MATHCALL (ctan, (_Mdouble_complex_ __z));
+libm_hidden_proto(ctan)
/* Hyperbolic functions. */
/* Hyperbolic arc cosine of Z. */
__MATHCALL (cacosh, (_Mdouble_complex_ __z));
+libm_hidden_proto(cacosh)
/* Hyperbolic arc sine of Z. */
__MATHCALL (casinh, (_Mdouble_complex_ __z));
+libm_hidden_proto(casinh)
/* Hyperbolic arc tangent of Z. */
__MATHCALL (catanh, (_Mdouble_complex_ __z));
+libm_hidden_proto(catanh)
/* Hyperbolic cosine of Z. */
__MATHCALL (ccosh, (_Mdouble_complex_ __z));
+libm_hidden_proto(ccosh)
/* Hyperbolic sine of Z. */
__MATHCALL (csinh, (_Mdouble_complex_ __z));
+libm_hidden_proto(ccosh)
/* Hyperbolic tangent of Z. */
__MATHCALL (ctanh, (_Mdouble_complex_ __z));
+libm_hidden_proto(ctanh)
/* Exponential and logarithmic functions. */
/* Exponential function of Z. */
__MATHCALL (cexp, (_Mdouble_complex_ __z));
+libm_hidden_proto(cexp)
/* Natural logarithm of Z. */
__MATHCALL (clog, (_Mdouble_complex_ __z));
+libm_hidden_proto(clog)
#ifdef __USE_GNU
/* The base 10 logarithm is not defined by the standard but to implement
the standard C++ library it is handy. */
__MATHCALL (clog10, (_Mdouble_complex_ __z));
+libm_hidden_proto(clog10)
#endif
/* Power functions. */
/* Return X to the Y power. */
__MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y));
+libm_hidden_proto(cpow)
/* Return the square root of Z. */
__MATHCALL (csqrt, (_Mdouble_complex_ __z));
+libm_hidden_proto(csqrt)
/* Absolute value, conjugates, and projection. */
/* Absolute value of Z. */
__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z));
+libm_hidden_proto(cabs)
/* Argument value of Z. */
__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z));
+libm_hidden_proto(carg)
/* Complex conjugate of Z. */
__MATHCALL (conj, (_Mdouble_complex_ __z));
+libm_hidden_proto(conj)
/* Projection of Z onto the Riemann sphere. */
__MATHCALL (cproj, (_Mdouble_complex_ __z));
+libm_hidden_proto(cproj)
/* Decomposing complex values. */
/* Imaginary part of Z. */
__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z));
+libm_hidden_proto(cimag)
/* Real part of Z. */
__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z));
+libm_hidden_proto(creal)
/* Now some optimized versions. GCC has handy notations for these
diff --git a/libc/sysdeps/linux/common/bits/mathcalls.h b/libc/sysdeps/linux/common/bits/mathcalls.h
index c02007284..e30b04aed 100644
--- a/libc/sysdeps/linux/common/bits/mathcalls.h
+++ b/libc/sysdeps/linux/common/bits/mathcalls.h
@@ -53,44 +53,58 @@
_Mdouble_BEGIN_NAMESPACE
/* Arc cosine of X. */
__MATHCALL (acos,, (_Mdouble_ __x));
+libm_hidden_proto(acos)
/* Arc sine of X. */
__MATHCALL (asin,, (_Mdouble_ __x));
+libm_hidden_proto(asin)
/* Arc tangent of X. */
__MATHCALL (atan,, (_Mdouble_ __x));
+libm_hidden_proto(atan)
/* Arc tangent of Y/X. */
__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
+libm_hidden_proto(atan2)
/* Cosine of X. */
__MATHCALL (cos,, (_Mdouble_ __x));
+libm_hidden_proto(cos)
/* Sine of X. */
__MATHCALL (sin,, (_Mdouble_ __x));
+libm_hidden_proto(sin)
/* Tangent of X. */
__MATHCALL (tan,, (_Mdouble_ __x));
+libm_hidden_proto(tan)
/* Hyperbolic functions. */
/* Hyperbolic cosine of X. */
__MATHCALL (cosh,, (_Mdouble_ __x));
+libm_hidden_proto(cosh)
/* Hyperbolic sine of X. */
__MATHCALL (sinh,, (_Mdouble_ __x));
+libm_hidden_proto(sinh)
/* Hyperbolic tangent of X. */
__MATHCALL (tanh,, (_Mdouble_ __x));
+libm_hidden_proto(tanh)
_Mdouble_END_NAMESPACE
#if 0 /*def __USE_GNU*/
/* Cosine and sine of X. */
__MATHDECL (void,sincos,,
(_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
+libm_hidden_proto(sincos)
#endif
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Hyperbolic arc cosine of X. */
__MATHCALL (acosh,, (_Mdouble_ __x));
+libm_hidden_proto(acosh)
/* Hyperbolic arc sine of X. */
__MATHCALL (asinh,, (_Mdouble_ __x));
+libm_hidden_proto(asinh)
/* Hyperbolic arc tangent of X. */
__MATHCALL (atanh,, (_Mdouble_ __x));
+libm_hidden_proto(atanh)
__END_NAMESPACE_C99
#endif
@@ -99,40 +113,51 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Exponential function of X. */
__MATHCALL (exp,, (_Mdouble_ __x));
+libm_hidden_proto(exp)
/* Break VALUE into a normalized fraction and an integral power of 2. */
__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
+libm_hidden_proto(frexp)
/* X times (two to the EXP power). */
__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
+libm_hidden_proto(ldexp)
/* Natural logarithm of X. */
__MATHCALL (log,, (_Mdouble_ __x));
+libm_hidden_proto(log)
/* Base-ten logarithm of X. */
__MATHCALL (log10,, (_Mdouble_ __x));
+libm_hidden_proto(log10)
/* Break VALUE into integral and fractional parts. */
__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
+libm_hidden_proto(modf)
_Mdouble_END_NAMESPACE
#if 0 /*def __USE_GNU*/
/* A function missing in all standards: compute exponent to base ten. */
__MATHCALL (exp10,, (_Mdouble_ __x));
+libm_hidden_proto(exp10)
/* Another name occasionally used. */
__MATHCALL (pow10,, (_Mdouble_ __x));
+libm_hidden_proto(pow10)
#endif
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return exp(X) - 1. */
__MATHCALL (expm1,, (_Mdouble_ __x));
+libm_hidden_proto(expm1)
/* Return log(1 + X). */
__MATHCALL (log1p,, (_Mdouble_ __x));
+libm_hidden_proto(log1p)
/* Return the base 2 signed integral exponent of X. */
__MATHCALL (logb,, (_Mdouble_ __x));
+libm_hidden_proto(logb)
__END_NAMESPACE_C99
#endif
@@ -140,9 +165,11 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_C99
/* Compute base-2 exponential of X. */
__MATHCALL (exp2,, (_Mdouble_ __x));
+libm_hidden_proto(exp2)
/* Compute base-2 logarithm of X. */
__MATHCALL (log2,, (_Mdouble_ __x));
+libm_hidden_proto(log2)
__END_NAMESPACE_C99
#endif
@@ -152,15 +179,18 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Return X to the Y power. */
__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(pow)
/* Return the square root of X. */
__MATHCALL (sqrt,, (_Mdouble_ __x));
+libm_hidden_proto(sqrt)
_Mdouble_END_NAMESPACE
#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return `sqrt(X*X + Y*Y)'. */
__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(hypot)
__END_NAMESPACE_C99
#endif
@@ -168,6 +198,7 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_C99
/* Return the cube root of X. */
__MATHCALL (cbrt,, (_Mdouble_ __x));
+libm_hidden_proto(cbrt)
__END_NAMESPACE_C99
#endif
@@ -177,45 +208,56 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Smallest integral value not less than X. */
__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
+libm_hidden_proto(ceil)
/* Absolute value of X. */
__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
+libm_hidden_proto(fabs)
/* Largest integer not greater than X. */
__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
+libm_hidden_proto(floor)
/* Floating-point modulo remainder of X/Y. */
__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(fmod)
/* Return 0 if VALUE is finite or NaN, +1 if it
is +Infinity, -1 if it is -Infinity. */
__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+libm_hidden_proto(__isinf)
/* Return nonzero if VALUE is finite and not NaN. */
__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+libm_hidden_proto(__finite)
_Mdouble_END_NAMESPACE
#ifdef __USE_MISC
/* Return 0 if VALUE is finite or NaN, +1 if it
is +Infinity, -1 if it is -Infinity. */
__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
+libm_hidden_proto(isinf)
/* Return nonzero if VALUE is finite and not NaN. */
__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
+libm_hidden_proto(finite)
/* Return the remainder of X/Y. */
__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(drem)
/* Return the fractional part of X after dividing out `ilogb (X)'. */
__MATHCALL (significand,, (_Mdouble_ __x));
+libm_hidden_proto(significand)
#endif /* Use misc. */
#if defined __USE_MISC || defined __USE_ISOC99
__BEGIN_NAMESPACE_C99
/* Return X with its signed changed to Y's. */
__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
+libm_hidden_proto(copysign)
__END_NAMESPACE_C99
#endif
@@ -223,24 +265,33 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_C99
/* Return representation of NaN for double type. */
__MATHCALLX (nan,, (__const char *__tagb), (__const__));
+libm_hidden_proto(nan)
__END_NAMESPACE_C99
#endif
/* Return nonzero if VALUE is not a number. */
__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+libm_hidden_proto(__isnan)
#if defined __USE_MISC || defined __USE_XOPEN
/* Return nonzero if VALUE is not a number. */
__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
+libm_hidden_proto(isnan)
/* Bessel functions. */
__MATHCALL (j0,, (_Mdouble_));
+libm_hidden_proto(j0)
__MATHCALL (j1,, (_Mdouble_));
+libm_hidden_proto(j1)
__MATHCALL (jn,, (int, _Mdouble_));
+libm_hidden_proto(jn)
__MATHCALL (y0,, (_Mdouble_));
+libm_hidden_proto(y0)
__MATHCALL (y1,, (_Mdouble_));
+libm_hidden_proto(y1)
__MATHCALL (yn,, (int, _Mdouble_));
+libm_hidden_proto(yn)
#endif
@@ -248,8 +299,11 @@ __MATHCALL (yn,, (int, _Mdouble_));
__BEGIN_NAMESPACE_C99
/* Error and gamma functions. */
__MATHCALL (erf,, (_Mdouble_));
+libm_hidden_proto(erf)
__MATHCALL (erfc,, (_Mdouble_));
+libm_hidden_proto(erfc)
__MATHCALL (lgamma,, (_Mdouble_));
+libm_hidden_proto(lgamma)
__END_NAMESPACE_C99
#endif
@@ -257,12 +311,14 @@ __END_NAMESPACE_C99
__BEGIN_NAMESPACE_C99
/* True gamma function. */
__MATHCALL (tgamma,, (_Mdouble_));
+libm_hidden_proto(tgamma)
__END_NAMESPACE_C99
#endif
#if defined __USE_MISC || defined __USE_XOPEN
/* Obsolete alias for `lgamma'. */
__MATHCALL (gamma,, (_Mdouble_));
+libm_hidden_proto(gamma)
#endif
#ifdef __USE_MISC
@@ -270,6 +326,7 @@ __MATHCALL (gamma,, (_Mdouble_));
`signgam'. The reentrant version instead takes a pointer and stores
the value through it. */
__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
+libm_hidden_proto(lgamma_r)
#endif
@@ -278,45 +335,56 @@ __BEGIN_NAMESPACE_C99
/* Return the integer nearest X in the direction of the
prevailing rounding mode. */
__MATHCALL (rint,, (_Mdouble_ __x));
+libm_hidden_proto(rint)
/* Return X + epsilon if X < Y, X - epsilon if X > Y. */
__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
+libm_hidden_proto(nextafter)
# if defined __USE_ISOC99 && !defined __LDBL_COMPAT
__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
+libm_hidden_proto(nexttoward)
# endif
/* Return the remainder of integer divison X / Y with infinite precision. */
__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(remainder)
# if defined __USE_MISC || defined __USE_ISOC99
/* Return X times (2 to the Nth power). */
__MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
+libm_hidden_proto(scalbn)
# endif
/* Return the binary exponent of X, which must be nonzero. */
__MATHDECL (int,ilogb,, (_Mdouble_ __x));
+libm_hidden_proto(ilogb)
#endif
#ifdef __USE_ISOC99
/* Return X times (2 to the Nth power). */
__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
+libm_hidden_proto(scalbln)
/* Round X to integral value in floating-point format using current
rounding direction, but do not raise inexact exception. */
__MATHCALL (nearbyint,, (_Mdouble_ __x));
+libm_hidden_proto(nearbyint)
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
__MATHCALLX (round,, (_Mdouble_ __x), (__const__));
+libm_hidden_proto(round)
/* Round X to the integral value in floating-point format nearest but
not larger in magnitude. */
__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
+libm_hidden_proto(trunc)
/* Compute remainder of X and Y and put in *QUO a value with sign of x/y
and magnitude congruent `mod 2^n' to the magnitude of the integral
quotient x/y, with n >= 3. */
__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
+libm_hidden_proto(remquo)
/* Conversion functions. */
@@ -324,35 +392,45 @@ __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
/* Round X to nearest integral value according to current rounding
direction. */
__MATHDECL (long int,lrint,, (_Mdouble_ __x));
+libm_hidden_proto(lrint)
__MATHDECL (long long int,llrint,, (_Mdouble_ __x));
+libm_hidden_proto(llrint)
/* Round X to nearest integral value, rounding halfway cases away from
zero. */
__MATHDECL (long int,lround,, (_Mdouble_ __x));
+libm_hidden_proto(lround)
__MATHDECL (long long int,llround,, (_Mdouble_ __x));
+libm_hidden_proto(llround)
/* Return positive difference between X and Y. */
__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(fdim)
/* Return maximum numeric value from X and Y. */
__MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(fmax)
/* Return minimum numeric value from X and Y. */
__MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
+libm_hidden_proto(fmin)
/* Classify given number. */
__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
__attribute__ ((__const__));
+libm_hidden_proto(__fpclassify)
/* Test for negative number. */
__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
__attribute__ ((__const__));
+libm_hidden_proto(__signbit)
/* Multiply-add function computed as a ternary operation. */
__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
+libm_hidden_proto(fma)
#endif /* Use ISO C99. */
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
@@ -362,4 +440,5 @@ __END_NAMESPACE_C99
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
/* Return X times (2 to the Nth power). */
__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
+libm_hidden_proto(scalb)
#endif
diff --git a/libc/sysdeps/linux/common/bits/mathdef.h b/libc/sysdeps/linux/common/bits/mathdef.h
index 00c67241a..1927299f9 100644
--- a/libc/sysdeps/linux/common/bits/mathdef.h
+++ b/libc/sysdeps/linux/common/bits/mathdef.h
@@ -35,9 +35,3 @@ typedef double double_t; /* `double' expressions are evaluated as
# define FP_ILOGBNAN 2147483647
#endif /* ISO C99 */
-
-#ifndef __NO_LONG_DOUBLE_MATH
-/* Signal that we do not really have a `long double'. The disables the
- declaration of all the `long double' function variants. */
-# define __NO_LONG_DOUBLE_MATH 1
-#endif
diff --git a/libm/Makefile.in b/libm/Makefile.in
index 8957f1bf6..7ec925653 100644
--- a/libm/Makefile.in
+++ b/libm/Makefile.in
@@ -1,6 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
@@ -34,15 +34,10 @@ libm_OUT:=$(top_builddir)libm
# Fix builds for powerpc as there are different cores in this
# section now.`
-ifeq ($(TARGET_ARCH),powerpc)
-ifeq ($(CONFIG_E500),y)
+ifeq ($(TARGET_ARCH)-$(CONFIG_E500),powerpc-y)
libm_ARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)/e500
libm_ARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)/e500
else
-libm_ARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)/classic
-libm_ARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)/classic
-endif
-else
libm_ARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)
libm_ARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)
endif
@@ -58,12 +53,13 @@ endif
endif
FL_MSRC := float_wrappers.c
+LD_MSRC := ldouble_wrappers.c
ifeq ($(DO_C99_MATH),y)
libm_CSRC := \
e_acos.c e_acosh.c e_asin.c e_atan2.c e_atanh.c e_cosh.c \
e_exp.c e_fmod.c e_gamma.c e_gamma_r.c e_hypot.c e_j0.c \
- e_j1.c e_jn.c e_lgamma.c e_lgamma_r.c e_log.c e_log10.c \
+ e_j1.c e_jn.c e_lgamma.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 \
s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \
@@ -72,10 +68,15 @@ libm_CSRC := \
s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.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 w_acos.c w_acosh.c w_asin.c w_atan2.c w_atanh.c \
- w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c w_gamma_r.c \
+ w_cabs.c w_cosh.c w_drem.c w_exp.c w_fmod.c w_gamma.c \
w_hypot.c w_j0.c w_j1.c w_jn.c w_lgamma.c w_lgamma_r.c \
- w_log.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \
- w_sqrt.c fpmacros.c nan.c carg.c s_llrint.c
+ w_log.c w_log2.c w_log10.c w_pow.c w_remainder.c w_scalb.c w_sinh.c \
+ w_sqrt.c nan.c carg.c s_llrint.c \
+ s_fpclassify.c s_fpclassifyf.c s_signbit.c s_signbitf.c \
+ s_isnan.c s_isnanf.c s_isinf.c s_isinff.c s_finitef.c \
+ s_fdim.c s_fma.c s_fmax.c s_fmin.c s_nearbyint.c \
+ s_remquo.c s_scalbln.c w_exp2.c w_tgamma.c
+# REMOVED: w_gamma_r.c
FL_MOBJ := \
acosf.o acoshf.o asinf.o asinhf.o atan2f.o atanf.o atanhf.o cbrtf.o \
ceilf.o copysignf.o cosf.o coshf.o erfcf.o erff.o exp2f.o expf.o \
@@ -85,6 +86,15 @@ FL_MOBJ := \
nextafterf.o powf.o remainderf.o remquof.o rintf.o roundf.o \
scalblnf.o scalbnf.o sinf.o sinhf.o sqrtf.o tanf.o tanhf.o \
tgammaf.o truncf.o cargf.o llrintf.o
+
+LD_MOBJ := acoshl.o acosl.o asinhl.o asinl.o atan2l.o atanhl.o atanl.o cbrtl.o \
+ ceill.o copysignl.o coshl.o cosl.o erfcl.o erfl.o exp2l.o expl.o \
+ expm1l.o fabsl.o fdiml.o floorl.o fmal.o fmaxl.o fminl.o fmodl.o \
+ frexpl.o gammal.o hypotl.o ilogbl.o ldexpl.o lgammal.o llrintl.o \
+ llroundl.o log10l.o log1pl.o XXXlog2l.o logbl.o logl.o lrintl.o lroundl.o \
+ modfl.o nearbyintl.o nextafterl.o XXXnexttowardl.o powl.o remainderl.o \
+ remquol.o rintl.o roundl.o scalblnl.o scalbnl.o sinhl.o sinl.o sqrtl.o \
+ tanhl.o tanl.o tgammal.o truncl.o
else
# This list of math functions was taken from POSIX/IEEE 1003.1b-1993
libm_CSRC := \
@@ -104,13 +114,9 @@ endif
ifeq ($(UCLIBC_HAS_FPU),y)
ifeq ($(DO_C99_MATH),y)
ifneq ($(strip $(libm_ARCH_OBJS)),)
-ifeq ($(TARGET_ARCH),powerpc)
-ifeq ($(CONFIG_E500),y)
+ifeq ($(TARGET_ARCH)-$(CONFIG_E500),powerpc-y)
CFLAGS-libm/$(TARGET_ARCH)/e500/ := $(CFLAGS-libm)
else
-CFLAGS-libm/$(TARGET_ARCH)/classic/ := $(CFLAGS-libm)
-endif
-else
CFLAGS-libm/$(TARGET_ARCH)/ := $(CFLAGS-libm)
endif
@@ -121,9 +127,11 @@ endif
# remove generic objects built from multi-sources, if arch specific version is present
FL_MOBJ := $(filter-out $(notdir $(libm_ARCH_OBJS)),$(FL_MOBJ))
+LD_MOBJ := $(filter-out $(notdir $(libm_ARCH_OBJS)),$(LD_MOBJ))
# we also try to remove % if s_% is in arch specific subdir
FL_MOBJ := $(filter-out $(patsubst s_%.o,%.o,$(notdir $(libm_ARCH_OBJS))),$(FL_MOBJ))
+LD_MOBJ := $(filter-out $(patsubst s_%.o,%.o,$(notdir $(libm_ARCH_OBJS))),$(LD_MOBJ))
endif
endif
endif
@@ -131,14 +139,22 @@ endif
libm_SRC := $(patsubst %.c,$(libm_DIR)/%.c,$(libm_CSRC))
libm_OBJ := $(patsubst $(libm_DIR)/%.c,$(libm_OUT)/%.o,$(libm_SRC))
+ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y)
+libm_MSRC2 := $(libm_DIR)/$(LD_MSRC)
+libm_MOBJ2 := $(patsubst %.o,$(libm_OUT)/%.o,$(LD_MOBJ))
+endif
libm_MSRC := $(libm_DIR)/$(FL_MSRC)
libm_MOBJ := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ))
+
ifneq ($(DOMULTI),n)
CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ))))
+ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y)
+CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ2))))
+endif
endif
-libm_OBJS := $(libm_OBJ) $(libm_MOBJ)
+libm_OBJS := $(libm_OBJ) $(libm_MOBJ) $(libm_MOBJ2)
ifeq ($(DOPIC),y)
libm-a-y += $(libm_OBJS:.o=.os)
@@ -167,7 +183,7 @@ $(libm_OUT)/libm_so.a: $(libm-so-y)
$(Q)$(RM) $@
$(do_ar)
-$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC) $(libm_ARCH_SRC)
+$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC) $(libm_MSRC2) $(libm_ARCH_SRC)
$(Q)$(RM) $@
$(compile-m)
@@ -179,8 +195,14 @@ $(top_builddir)lib/libm.a: $(libm-a-y)
$(libm_MOBJ): $(libm_MSRC)
$(compile.m)
+$(libm_MOBJ2): $(libm_MSRC2)
+ $(compile.m)
+
$(libm_MOBJ:.o=.os): $(libm_MSRC)
$(compile.m)
+$(libm_MOBJ2:.o=.os): $(libm_MSRC2)
+ $(compile.m)
+
libm_clean:
- $(RM) $(libm_OUT)/{,*/,*/*/}*.{o,os,oS,a}
+ $(do_rm) $(addprefix $(libm_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*.,$(d)$(e))))
diff --git a/libm/carg.c b/libm/carg.c
index 7641d5dfe..7b290b0b8 100644
--- a/libm/carg.c
+++ b/libm/carg.c
@@ -21,13 +21,9 @@
#include <complex.h>
#include <math.h>
-libm_hidden_proto(atan2)
-libm_hidden_proto(carg)
-
double
carg (__complex__ double x)
{
return atan2 (__imag__ x, __real__ x);
}
-
libm_hidden_def(carg)
diff --git a/libm/e_acosh.c b/libm/e_acosh.c
index d5e510eff..3d0a038f0 100644
--- a/libm/e_acosh.c
+++ b/libm/e_acosh.c
@@ -31,8 +31,6 @@ static char rcsid[] = "$NetBSD: e_acosh.c,v 1.9 1995/05/12 04:57:18 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log1p)
-libm_hidden_proto(sqrt)
#ifdef __STDC__
static const double
diff --git a/libm/e_asin.c b/libm/e_asin.c
index 8a639771b..ce8372c2d 100644
--- a/libm/e_asin.c
+++ b/libm/e_asin.c
@@ -48,7 +48,6 @@ static char rcsid[] = "$NetBSD: e_asin.c,v 1.9 1995/05/12 04:57:22 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
diff --git a/libm/e_atan2.c b/libm/e_atan2.c
index 7bb38da81..407a12920 100644
--- a/libm/e_atan2.c
+++ b/libm/e_atan2.c
@@ -44,8 +44,6 @@ static char rcsid[] = "$NetBSD: e_atan2.c,v 1.8 1995/05/10 20:44:51 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(atan)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
diff --git a/libm/e_atanh.c b/libm/e_atanh.c
index cfbe02bed..c6c47bcfa 100644
--- a/libm/e_atanh.c
+++ b/libm/e_atanh.c
@@ -35,7 +35,6 @@ static char rcsid[] = "$NetBSD: e_atanh.c,v 1.8 1995/05/10 20:44:55 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log1p)
#ifdef __STDC__
static const double one = 1.0, huge = 1e300;
diff --git a/libm/e_cosh.c b/libm/e_cosh.c
index aa25eefcb..a7e5e4496 100644
--- a/libm/e_cosh.c
+++ b/libm/e_cosh.c
@@ -38,8 +38,6 @@ static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(expm1)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double one = 1.0, half=0.5, huge = 1.0e300;
diff --git a/libm/e_gamma.c b/libm/e_gamma.c
index 296ebb8f3..05b3b86e8 100644
--- a/libm/e_gamma.c
+++ b/libm/e_gamma.c
@@ -22,9 +22,8 @@
#include "math_private.h"
libm_hidden_proto(signgam)
-
#ifdef __STDC__
- //__private_extern__
+ /* __private_extern__ */
double attribute_hidden __ieee754_gamma(double x)
#else
double attribute_hidden __ieee754_gamma(x)
diff --git a/libm/e_gamma_r.c b/libm/e_gamma_r.c
index 36b0d45d6..620f692b5 100644
--- a/libm/e_gamma_r.c
+++ b/libm/e_gamma_r.c
@@ -22,7 +22,7 @@
#include "math_private.h"
#ifdef __STDC__
- //__private_extern__
+ /* __private_extern__ */
double attribute_hidden __ieee754_gamma_r(double x, int *signgamp)
#else
double attribute_hidden __ieee754_gamma_r(x,signgamp)
diff --git a/libm/e_j0.c b/libm/e_j0.c
index 74defacdf..7778788fb 100644
--- a/libm/e_j0.c
+++ b/libm/e_j0.c
@@ -62,10 +62,6 @@ static char rcsid[] = "$NetBSD: e_j0.c,v 1.8 1995/05/10 20:45:23 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-libm_hidden_proto(cos)
-libm_hidden_proto(sqrt)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static double pzero(double), qzero(double);
diff --git a/libm/e_j1.c b/libm/e_j1.c
index bb3e650eb..4b4274ae5 100644
--- a/libm/e_j1.c
+++ b/libm/e_j1.c
@@ -62,10 +62,6 @@ static char rcsid[] = "$NetBSD: e_j1.c,v 1.8 1995/05/10 20:45:27 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-libm_hidden_proto(cos)
-libm_hidden_proto(sqrt)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static double pone(double), qone(double);
diff --git a/libm/e_jn.c b/libm/e_jn.c
index 53c6396f6..7771eaf5d 100644
--- a/libm/e_jn.c
+++ b/libm/e_jn.c
@@ -43,10 +43,6 @@ static char rcsid[] = "$NetBSD: e_jn.c,v 1.9 1995/05/10 20:45:34 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
-libm_hidden_proto(cos)
-libm_hidden_proto(sqrt)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
diff --git a/libm/e_lgamma.c b/libm/e_lgamma.c
index 4dce71c80..af7cccf54 100644
--- a/libm/e_lgamma.c
+++ b/libm/e_lgamma.c
@@ -22,9 +22,8 @@
#include "math_private.h"
libm_hidden_proto(signgam)
-
#ifdef __STDC__
- //__private_extern__
+ /* __private_extern__ */
double attribute_hidden __ieee754_lgamma(double x)
#else
double attribute_hidden __ieee754_lgamma(x)
diff --git a/libm/e_lgamma_r.c b/libm/e_lgamma_r.c
index 5e1b373c0..42b48b3a6 100644
--- a/libm/e_lgamma_r.c
+++ b/libm/e_lgamma_r.c
@@ -84,9 +84,6 @@ static char rcsid[] = "$NetBSD: e_lgamma_r.c,v 1.7 1995/05/10 20:45:42 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(floor)
-libm_hidden_proto(fabs)
-
#ifdef __STDC__
static const double
#else
@@ -167,7 +164,7 @@ static double zero= 0.00000000000000000000e+00;
static
#ifdef __GNUC__
-inline
+__inline__
#endif
#ifdef __STDC__
double sin_pi(double x)
diff --git a/libm/e_log2.c b/libm/e_log2.c
new file mode 100644
index 000000000..894a96df0
--- /dev/null
+++ b/libm/e_log2.c
@@ -0,0 +1,130 @@
+/* Adapted for log2 by Ulrich Drepper <drepper@cygnus.com>. */
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/* __ieee754_log2(x)
+ * Return the logarithm to base 2 of x
+ *
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * 2. Approximation of log(1+f).
+ * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * = 2s + s*R
+ * We use a special Reme algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
+ * of this polynomial approximation is bounded by 2**-58.45. In
+ * other words,
+ * 2 4 6 8 10 12 14
+ * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
+ * (the values of Lg1 to Lg7 are listed in the program)
+ * and
+ * | 2 14 | -58.45
+ * | Lg1*s +...+Lg7*s - R(z) | <= 2
+ * | |
+ * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ * In order to guarantee error in log below 1ulp, we compute log
+ * by
+ * log(1+f) = f - s*(f - R) (if f is not too large)
+ * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
+ *
+ * 3. Finally, log(x) = k + log(1+f).
+ * = k+(f-(hfsq-(s*(hfsq+R))))
+ *
+ * Special cases:
+ * log2(x) is NaN with signal if x < 0 (including -INF) ;
+ * log2(+INF) is +INF; log(0) is -INF with signal;
+ * log2(NaN) is that NaN with no signal.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+ln2 = 0.69314718055994530942,
+two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
+Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
+Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
+Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
+Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
+Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
+Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
+Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
+
+#ifdef __STDC__
+static const double zero = 0.0;
+#else
+static double zero = 0.0;
+#endif
+
+#ifdef __STDC__
+ double __ieee754_log2(double x)
+#else
+ double __ieee754_log2(x)
+ double x;
+#endif
+{
+ double hfsq,f,s,z,R,w,t1,t2,dk;
+ int32_t k,hx,i,j;
+ u_int32_t lx;
+
+ EXTRACT_WORDS(hx,lx,x);
+
+ k=0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx&0x7fffffff)|lx)==0)
+ return -two54/(x-x); /* log(+-0)=-inf */
+ if (hx<0) return (x-x)/(x-x); /* log(-#) = NaN */
+ k -= 54; x *= two54; /* subnormal number, scale up x */
+ GET_HIGH_WORD(hx,x);
+ }
+ if (hx >= 0x7ff00000) return x+x;
+ k += (hx>>20)-1023;
+ hx &= 0x000fffff;
+ i = (hx+0x95f64)&0x100000;
+ SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
+ k += (i>>20);
+ dk = (double) k;
+ f = x-1.0;
+ if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */
+ if(f==zero) return dk;
+ R = f*f*(0.5-0.33333333333333333*f);
+ return dk-(R-f)/ln2;
+ }
+ s = f/(2.0+f);
+ z = s*s;
+ i = hx-0x6147a;
+ w = z*z;
+ j = 0x6b851-hx;
+ t1= w*(Lg2+w*(Lg4+w*Lg6));
+ t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
+ i |= j;
+ R = t2+t1;
+ if(i>0) {
+ hfsq=0.5*f*f;
+ return dk-((hfsq-(s*(hfsq+R)))-f)/ln2;
+ } else {
+ return dk-((s*(f-R))-f)/ln2;
+ }
+}
diff --git a/libm/e_pow.c b/libm/e_pow.c
index 675149e1f..53ec81329 100644
--- a/libm/e_pow.c
+++ b/libm/e_pow.c
@@ -62,8 +62,6 @@ static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(scalbn)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
diff --git a/libm/e_rem_pio2.c b/libm/e_rem_pio2.c
index 97ce7bab1..92deaa33e 100644
--- a/libm/e_rem_pio2.c
+++ b/libm/e_rem_pio2.c
@@ -23,7 +23,6 @@ static char rcsid[] = "$NetBSD: e_rem_pio2.c,v 1.8 1995/05/10 20:46:02 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
/*
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
diff --git a/libm/e_remainder.c b/libm/e_remainder.c
index 17047b385..95eee7480 100644
--- a/libm/e_remainder.c
+++ b/libm/e_remainder.c
@@ -26,7 +26,6 @@ static char rcsid[] = "$NetBSD: e_remainder.c,v 1.8 1995/05/10 20:46:05 jtc Exp
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double zero = 0.0;
diff --git a/libm/e_scalb.c b/libm/e_scalb.c
index 772d95523..2f0dba14a 100644
--- a/libm/e_scalb.c
+++ b/libm/e_scalb.c
@@ -23,10 +23,6 @@ static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(scalbn)
-libm_hidden_proto(finite)
-libm_hidden_proto(rint)
-libm_hidden_proto(__isnan)
#ifdef _SCALB_INT
#ifdef __STDC__
diff --git a/libm/e_sinh.c b/libm/e_sinh.c
index e8452c287..ec2b1d865 100644
--- a/libm/e_sinh.c
+++ b/libm/e_sinh.c
@@ -35,8 +35,6 @@ static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(expm1)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double one = 1.0, shuge = 1.0e307;
diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c
index cd0ae1832..58d3926a7 100644
--- a/libm/float_wrappers.c
+++ b/libm/float_wrappers.c
@@ -75,7 +75,6 @@ float tanhf(float);
#ifdef L_acosf
-libm_hidden_proto(acos)
float acosf (float x)
{
return (float) acos( (double)x );
@@ -84,7 +83,6 @@ float acosf (float x)
#ifdef L_acoshf
-libm_hidden_proto(acosh)
float acoshf (float x)
{
return (float) acosh( (double)x );
@@ -93,7 +91,6 @@ float acoshf (float x)
#ifdef L_asinf
-libm_hidden_proto(asin)
float asinf (float x)
{
return (float) asin( (double)x );
@@ -102,7 +99,6 @@ float asinf (float x)
#ifdef L_asinhf
-libm_hidden_proto(asinh)
float asinhf (float x)
{
return (float) asinh( (double)x );
@@ -111,7 +107,6 @@ float asinhf (float x)
#ifdef L_atan2f
-libm_hidden_proto(atan2)
float atan2f (float x, float y)
{
return (float) atan2( (double)x, (double)y );
@@ -120,7 +115,6 @@ float atan2f (float x, float y)
#ifdef L_atanf
-libm_hidden_proto(atan)
float atanf (float x)
{
return (float) atan( (double)x );
@@ -129,7 +123,6 @@ float atanf (float x)
#ifdef L_atanhf
-libm_hidden_proto(atanh)
float atanhf (float x)
{
return (float) atanh( (double)x );
@@ -138,7 +131,6 @@ float atanhf (float x)
#ifdef L_cargf
-libm_hidden_proto(carg)
float cargf (float complex x)
{
return (float) carg( (double)x );
@@ -147,7 +139,6 @@ float cargf (float complex x)
#ifdef L_cbrtf
-libm_hidden_proto(cbrt)
float cbrtf (float x)
{
return (float) cbrt( (double)x );
@@ -156,7 +147,6 @@ float cbrtf (float x)
#ifdef L_ceilf
-libm_hidden_proto(ceil)
float ceilf (float x)
{
return (float) ceil( (double)x );
@@ -165,7 +155,6 @@ float ceilf (float x)
#ifdef L_copysignf
-libm_hidden_proto(copysign)
float copysignf (float x, float y)
{
return (float) copysign( (double)x, (double)y );
@@ -174,7 +163,6 @@ float copysignf (float x, float y)
#ifdef L_cosf
-libm_hidden_proto(cos)
float cosf (float x)
{
return (float) cos( (double)x );
@@ -183,7 +171,6 @@ float cosf (float x)
#ifdef L_coshf
-libm_hidden_proto(cosh)
float coshf (float x)
{
return (float) cosh( (double)x );
@@ -192,7 +179,6 @@ float coshf (float x)
#ifdef L_erfcf
-libm_hidden_proto(erfc)
float erfcf (float x)
{
return (float) erfc( (double)x );
@@ -201,7 +187,6 @@ float erfcf (float x)
#ifdef L_erff
-libm_hidden_proto(erf)
float erff (float x)
{
return (float) erf( (double)x );
@@ -210,7 +195,6 @@ float erff (float x)
#ifdef L_exp2f
-libm_hidden_proto(exp2)
float exp2f (float x)
{
return (float) exp2( (double)x );
@@ -219,7 +203,6 @@ float exp2f (float x)
#ifdef L_expf
-libm_hidden_proto(exp)
float expf (float x)
{
return (float) exp( (double)x );
@@ -228,7 +211,6 @@ float expf (float x)
#ifdef L_expm1f
-libm_hidden_proto(expm1)
float expm1f (float x)
{
return (float) expm1( (double)x );
@@ -237,7 +219,6 @@ float expm1f (float x)
#ifdef L_fabsf
-libm_hidden_proto(fabs)
float fabsf (float x)
{
return (float) fabs( (double)x );
@@ -246,7 +227,6 @@ float fabsf (float x)
#ifdef L_fdimf
-libm_hidden_proto(fdim)
float fdimf (float x, float y)
{
return (float) fdim( (double)x, (double)y );
@@ -255,7 +235,6 @@ float fdimf (float x, float y)
#ifdef L_floorf
-libm_hidden_proto(floor)
float floorf (float x)
{
return (float) floor( (double)x );
@@ -264,7 +243,6 @@ float floorf (float x)
#ifdef L_fmaf
-libm_hidden_proto(fma)
float fmaf (float x, float y, float z)
{
return (float) fma( (double)x, (double)y, (double)z );
@@ -273,7 +251,6 @@ float fmaf (float x, float y, float z)
#ifdef L_fmaxf
-libm_hidden_proto(fmax)
float fmaxf (float x, float y)
{
return (float) fmax( (double)x, (double)y );
@@ -282,7 +259,6 @@ float fmaxf (float x, float y)
#ifdef L_fminf
-libm_hidden_proto(fmin)
float fminf (float x, float y)
{
return (float) fmin( (double)x, (double)y );
@@ -291,7 +267,6 @@ float fminf (float x, float y)
#ifdef L_fmodf
-libm_hidden_proto(fmod)
float fmodf (float x, float y)
{
return (float) fmod( (double)x, (double)y );
@@ -300,7 +275,6 @@ float fmodf (float x, float y)
#ifdef L_frexpf
-libm_hidden_proto(frexp)
float frexpf (float x, int *_exp)
{
return (float) frexp( (double)x, _exp );
@@ -309,7 +283,6 @@ float frexpf (float x, int *_exp)
#ifdef L_hypotf
-libm_hidden_proto(hypot)
float hypotf (float x, float y)
{
return (float) hypot( (double)x, (double)y );
@@ -318,7 +291,6 @@ float hypotf (float x, float y)
#ifdef L_ilogbf
-libm_hidden_proto(ilogb)
int ilogbf (float x)
{
return (int) ilogb( (double)x );
@@ -327,7 +299,6 @@ int ilogbf (float x)
#ifdef L_ldexpf
-libm_hidden_proto(ldexp)
float ldexpf (float x, int _exp)
{
return (float) ldexp( (double)x, _exp );
@@ -336,7 +307,6 @@ float ldexpf (float x, int _exp)
#ifdef L_lgammaf
-libm_hidden_proto(lgamma)
float lgammaf (float x)
{
return (float) lgamma( (double)x );
@@ -345,7 +315,6 @@ float lgammaf (float x)
#ifdef L_llrintf
-libm_hidden_proto(llrint)
long long llrintf (float x)
{
return (long long) llrint( (double)x );
@@ -354,7 +323,6 @@ long long llrintf (float x)
#ifdef L_llroundf
-libm_hidden_proto(llround)
long long llroundf (float x)
{
return (long long) llround( (double)x );
@@ -363,7 +331,6 @@ long long llroundf (float x)
#ifdef L_log10f
-libm_hidden_proto(log10)
float log10f (float x)
{
return (float) log10( (double)x );
@@ -372,7 +339,6 @@ float log10f (float x)
#ifdef L_log1pf
-libm_hidden_proto(log1p)
float log1pf (float x)
{
return (float) log1p( (double)x );
@@ -381,7 +347,6 @@ float log1pf (float x)
#ifdef L_log2f
-libm_hidden_proto(log2)
float log2f (float x)
{
return (float) log2( (double)x );
@@ -390,7 +355,6 @@ float log2f (float x)
#ifdef L_logbf
-libm_hidden_proto(logb)
float logbf (float x)
{
return (float) logb( (double)x );
@@ -399,7 +363,6 @@ float logbf (float x)
#ifdef L_logf
-libm_hidden_proto(log)
float logf (float x)
{
return (float) log( (double)x );
@@ -408,7 +371,6 @@ float logf (float x)
#ifdef L_lrintf
-libm_hidden_proto(lrint)
long lrintf (float x)
{
return (long) lrint( (double)x );
@@ -417,7 +379,6 @@ long lrintf (float x)
#ifdef L_lroundf
-libm_hidden_proto(lround)
long lroundf (float x)
{
return (long) lround( (double)x );
@@ -426,7 +387,6 @@ long lroundf (float x)
#ifdef L_modff
-libm_hidden_proto(modf)
float modff (float x, float *iptr)
{
double y, result;
@@ -439,7 +399,6 @@ float modff (float x, float *iptr)
#ifdef L_nearbyintf
-libm_hidden_proto(nearbyint)
float nearbyintf (float x)
{
return (float) nearbyint( (double)x );
@@ -448,7 +407,6 @@ float nearbyintf (float x)
#ifdef L_nextafterf
-libm_hidden_proto(nextafter)
float nextafterf (float x, float y)
{
return (float) nextafter( (double)x, (double)y );
@@ -457,7 +415,6 @@ float nextafterf (float x, float y)
#ifdef L_nexttowardf
-libm_hidden_proto(nexttoward)
float nexttowardf (float x, long double y)
{
return (float) nexttoward( (double)x, (double)y );
@@ -466,7 +423,6 @@ float nexttowardf (float x, long double y)
#ifdef L_powf
-libm_hidden_proto(pow)
float powf (float x, float y)
{
return (float) pow( (double)x, (double)y );
@@ -475,7 +431,6 @@ float powf (float x, float y)
#ifdef L_remainderf
-libm_hidden_proto(remainder)
float remainderf (float x, float y)
{
return (float) remainder( (double)x, (double)y );
@@ -484,7 +439,6 @@ float remainderf (float x, float y)
#ifdef L_remquof
-libm_hidden_proto(remquo)
float remquof (float x, float y, int *quo)
{
return (float) remquo( (double)x, (double)y, quo );
@@ -493,7 +447,6 @@ float remquof (float x, float y, int *quo)
#ifdef L_rintf
-libm_hidden_proto(rint)
float rintf (float x)
{
return (float) rint( (double)x );
@@ -502,7 +455,6 @@ float rintf (float x)
#ifdef L_roundf
-libm_hidden_proto(round)
float roundf (float x)
{
return (float) round( (double)x );
@@ -511,7 +463,6 @@ float roundf (float x)
#ifdef L_scalblnf
-libm_hidden_proto(scalbln)
float scalblnf (float x, long _exp)
{
return (float) scalbln( (double)x, _exp );
@@ -520,7 +471,6 @@ float scalblnf (float x, long _exp)
#ifdef L_scalbnf
-libm_hidden_proto(scalbn)
float scalbnf (float x, int _exp)
{
return (float) scalbn( (double)x, _exp );
@@ -529,7 +479,6 @@ float scalbnf (float x, int _exp)
#ifdef L_sinf
-libm_hidden_proto(sin)
float sinf (float x)
{
return (float) sin( (double)x );
@@ -538,7 +487,6 @@ float sinf (float x)
#ifdef L_sinhf
-libm_hidden_proto(sinh)
float sinhf (float x)
{
return (float) sinh( (double)x );
@@ -547,7 +495,6 @@ float sinhf (float x)
#ifdef L_sqrtf
-libm_hidden_proto(sqrt)
float sqrtf (float x)
{
return (float) sqrt( (double)x );
@@ -556,7 +503,6 @@ float sqrtf (float x)
#ifdef L_tanf
-libm_hidden_proto(tan)
float tanf (float x)
{
return (float) tan( (double)x );
@@ -565,7 +511,6 @@ float tanf (float x)
#ifdef L_tanhf
-libm_hidden_proto(tanh)
float tanhf (float x)
{
return (float) tanh( (double)x );
@@ -574,7 +519,6 @@ float tanhf (float x)
#ifdef L_tgammaf
-libm_hidden_proto(tgamma)
float tgammaf (float x)
{
return (float) tgamma( (double)x );
@@ -583,7 +527,6 @@ float tgammaf (float x)
#ifdef L_truncf
-libm_hidden_proto(trunc)
float truncf (float x)
{
return (float) trunc( (double)x );
diff --git a/libm/fp_private.h b/libm/fp_private.h
deleted file mode 100644
index 0ddb616c4..000000000
--- a/libm/fp_private.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
-* *
-* File fp_private.h, *
-* All pack 4 dependencies for the MathLib elems plus some defines used *
-* throughout MathLib. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on October 1991, *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-*******************************************************************************/
-
-#define NoException 0
-
-/*******************************************************************************
-* Values of constants. *
-*******************************************************************************/
-
-//#define SgnMask 0x8000
-#define dSgnMask 0x80000000
-#define sSgnMask 0x7FFFFFFF
-
-//#define ExpMask 0x7FFF
-#define dExpMask 0x7FF00000
-#define sExpMask 0xFF000000
-
- /* according to rounding BIG & SMALL are: */
-#define BIG 1.1e+300 /* used to deliver ±° or largest number, */
-#define SMALL 1.1e-300 /* used to deliver ±0 or smallest number. */
-#define InfExp 0x7FF
-#define dMaxExp 0x7FF00000
-
-#define MaxExpP1 1024
-#define MaxExp 1023
-
-#define DenormLimit -52
-
-//#define ManMask 0x80000000
-#define dManMask 0x00080000
-
-//#define IsItDenorm 0x80000000
-#define dIsItDenorm 0x00080000
-
-//#define xIsItSNaN 0x40000000
-#define dIsItSNaN 0x00080000
-
-#define dHighMan 0x000FFFFF
-#define dFirstBitSet 0x00080000
-#define BIAS 0x3FF
-
-//#define GetSign 0x8000
-#define dGetSign 0x80000000
-#define sGetSign 0x80000000
-
-//#define Infinity(x) ( x.hex.exponent & ExpMask ) == ExpMask
-#define dInfinity(x) ( x.hex.high & dExpMask ) == dExpMask
-#define sInfinity(x) ( ( x.hexsgl << 1 ) & sExpMask ) == sExpMask
-
-//#define Exponent(x) x.hex.exponent & ExpMask
-#define dExponent(x) x.hex.high & dExpMask
-#define sExponent(x) ( ( x.hexsgl << 1 ) & sExpMask )
-
-#define sZero(x) ( x.hexsgl & sSgnMask ) == 0
-//#define Sign(x) ( x.hex.exponent & SgnMask ) == SgnMask
-
-/*******************************************************************************
-* Types used in the auxiliary functions. *
-*******************************************************************************/
-
-#include <stdint.h>
-#include <endian.h>
-
-typedef struct /* Hex representation of a double. */
- {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- uint32_t high;
- uint32_t low;
-#else
- uint32_t low;
- uint32_t high;
-#endif
- } dHexParts;
-
-typedef union
- {
- unsigned char byties[8];
- double dbl;
- } DblInHex;
diff --git a/libm/fpmacros.c b/libm/fpmacros.c
deleted file mode 100644
index 0a079c016..000000000
--- a/libm/fpmacros.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/***********************************************************************
-** File: fpmacros.c
-**
-** Contains: C source code for implementations of floating-point
-** functions which involve float format numbers, as
-** defined in header <fp.h>. In particular, this file
-** contains implementations of functions
-** __fpclassify(d,f), __isnormal(d,f), __isfinite(d,f),
-** __isnan(d,f), and __signbit(d,f). This file targets
-** PowerPC platforms.
-**
-** Written by: Robert A. Murley, Ali Sazegari
-**
-** Copyright: c 2001 by Apple Computer, Inc., all rights reserved
-**
-** Change History (most recent first):
-**
-** 07 Jul 01 ram First created from fpfloatfunc.c, fp.c,
-** classify.c and sign.c in MathLib v3 Mac OS9.
-**
-***********************************************************************/
-
-#include <features.h>
-#include <sys/types.h>
-#include <math.h>
-#include "fp_private.h"
-
-#define SIGN_MASK 0x80000000
-#define NSIGN_MASK 0x7fffffff
-#define FEXP_MASK 0x7f800000
-#define FFRAC_MASK 0x007fffff
-
-/***********************************************************************
- int __fpclassifyf(float x) returns the classification code of the
- argument x, as defined in <fp.h>.
-
- Exceptions: INVALID signaled if x is a signaling NaN; in this case,
- the FP_QNAN code is returned.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__fpclassifyf)
-int __fpclassifyf ( float x )
-{
- unsigned int iexp;
-
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- iexp = z.lval & FEXP_MASK; /* isolate float exponent */
-
- if (iexp == FEXP_MASK) { /* NaN or INF case */
- if ((z.lval & 0x007fffff) == 0)
- return FP_INFINITE;
- return FP_NAN;
- }
-
- if (iexp != 0) /* normal float */
- return FP_NORMAL;
-
- if (x == 0.0)
- return FP_ZERO; /* zero */
- else
- return FP_SUBNORMAL; /* must be subnormal */
-}
-libm_hidden_def(__fpclassifyf)
-
-
-/***********************************************************************
- Function __fpclassify,
- Implementation of classify of a double number for the PowerPC.
-
- Exceptions: INVALID signaled if x is a signaling NaN; in this case,
- the FP_QNAN code is returned.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__fpclassify)
-int __fpclassify ( double arg )
-{
- register unsigned int exponent;
- union
- {
- dHexParts hex;
- double dbl;
- } x;
-
- x.dbl = arg;
-
- exponent = x.hex.high & dExpMask;
- if ( exponent == dExpMask )
- {
- if ( ( ( x.hex.high & dHighMan ) | x.hex.low ) == 0 )
- return FP_INFINITE;
- else
- return FP_NAN;
- }
- else if ( exponent != 0)
- return FP_NORMAL;
- else {
- if ( arg == 0.0 )
- return FP_ZERO;
- else
- return FP_SUBNORMAL;
- }
-}
-libm_hidden_def(__fpclassify)
-
-
-/***********************************************************************
- int __isnormalf(float x) returns nonzero if and only if x is a
- normalized float number and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN; in this case,
- zero is returned.
-
- Calls: none
-***********************************************************************/
-
-int __isnormalf ( float x );
-int __isnormalf ( float x )
-{
- unsigned int iexp;
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- iexp = z.lval & FEXP_MASK; /* isolate float exponent */
- return ((iexp != FEXP_MASK) && (iexp != 0));
-}
-
-
-int __isnormal ( double x );
-int __isnormal ( double x )
-{
- return ( __fpclassify ( x ) == FP_NORMAL );
-}
-
-
-/***********************************************************************
- int __isfinitef(float x) returns nonzero if and only if x is a
- finite (normal, subnormal, or zero) float number and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN; in this case,
- zero is returned.
-
- Calls: none
-***********************************************************************/
-
-int __finitef ( float x )
-{
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- return ((z.lval & FEXP_MASK) != FEXP_MASK);
-}
-strong_alias(__finitef,finitef)
-
-#if 0 /* use __finite in s_finite.c */
-int __finite ( double x )
-{
- return ( __fpclassify ( x ) >= FP_ZERO );
-}
-strong_alias(__finite,finite)
-#endif
-
-
-/***********************************************************************
- int __signbitf(float x) returns nonzero if and only if the sign
- bit of x is set and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__signbitf)
-int __signbitf ( float x )
-{
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- return ((z.lval & SIGN_MASK) != 0);
-}
-libm_hidden_def(__signbitf)
-
-
-/***********************************************************************
- Function sign of a double.
- Implementation of sign bit for the PowerPC.
-
- Calls: none
-***********************************************************************/
-
-libm_hidden_proto(__signbit)
-int __signbit ( double arg )
-{
- union
- {
- dHexParts hex;
- double dbl;
- } x;
- int sign;
-
- x.dbl = arg;
- sign = ( ( x.hex.high & dSgnMask ) == dSgnMask ) ? 1 : 0;
- return sign;
-}
-libm_hidden_def(__signbit)
-
-
-/***********************************************************************
-* int __isinff(float x) returns -1 if value represents negative
-* infinity, 1 if value represents positive infinity,
-* and 0 otherwise.
-*
-* Calls: __signbit
-* +***********************************************************************/
-int __isinff ( float x )
-{
- int class = __fpclassifyf(x);
- if ( class == FP_INFINITE ) {
- return ( (__signbitf(x)) ? -1 : 1);
- }
- return 0;
-}
-strong_alias(__isinff,isinff)
-
-int __isinf ( double x )
-{
- int class = __fpclassify(x);
- if ( class == FP_INFINITE ) {
- return ( (__signbit(x)) ? -1 : 1);
- }
- return 0;
-}
-strong_alias(__isinf,isinf)
-
-#if 0
-int __isinfl ( long double x )
-{
- int class = __fpclassify(x);
- if ( class == FP_INFINITE ) {
- return ( (__signbit(x)) ? -1 : 1);
- }
- return 0;
-}
-strong_alias(__isinfl,isinfl)
-#endif
-
-/***********************************************************************
- int __isnanf(float x) returns nonzero if and only if x is a
- NaN and zero otherwise.
-
- Exceptions: INVALID is raised if x is a signaling NaN; in this case,
- nonzero is returned.
-
- Calls: none
-***********************************************************************/
-
-int __isnanf ( float x )
-{
- union {
- u_int32_t lval;
- float fval;
- } z;
-
- z.fval = x;
- return (((z.lval&FEXP_MASK) == FEXP_MASK) && ((z.lval&FFRAC_MASK) != 0));
-}
-strong_alias(__isnanf,isnanf)
-
-libm_hidden_proto(__isnan)
-int __isnan ( double x )
-{
- int class = __fpclassify(x);
- return ( class == FP_NAN );
-}
-libm_hidden_def(__isnan)
-strong_alias(__isnan,isnan)
-
-#if 0
-int __isnanl ( long double x )
-{
- int class = __fpclassify(x);
- return ( class == FP_NAN );
-}
-strong_alias(__isnanl,isnanl)
-#endif
-
diff --git a/libm/k_rem_pio2.c b/libm/k_rem_pio2.c
index e3b9bc195..8d1388de2 100644
--- a/libm/k_rem_pio2.c
+++ b/libm/k_rem_pio2.c
@@ -133,8 +133,6 @@ static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(scalbn)
-libm_hidden_proto(floor)
#ifdef __STDC__
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
diff --git a/libm/k_standard.c b/libm/k_standard.c
index 4df189853..ed8062c3e 100644
--- a/libm/k_standard.c
+++ b/libm/k_standard.c
@@ -20,9 +20,6 @@ static char rcsid[] = "$NetBSD: k_standard.c,v 1.6 1995/05/10 20:46:35 jtc Exp $
#ifndef _IEEE_LIBM
-libm_hidden_proto(copysign)
-libm_hidden_proto(matherr)
-libm_hidden_proto(rint)
#ifndef _USE_WRITE
#include <stdio.h> /* fputs(), stderr */
diff --git a/libm/k_tan.c b/libm/k_tan.c
index 2ba464421..95ec1510e 100644
--- a/libm/k_tan.c
+++ b/libm/k_tan.c
@@ -51,7 +51,6 @@ static char rcsid[] = "$NetBSD: k_tan.c,v 1.8 1995/05/10 20:46:37 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c
new file mode 100644
index 000000000..d82436da4
--- /dev/null
+++ b/libm/ldouble_wrappers.c
@@ -0,0 +1,523 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Wrapper functions implementing all the long double math functions
+ * defined by SuSv3 by actually calling the double version of
+ * each function and then casting the result back to a long double
+ * to return to the user.
+ *
+ * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include "math.h"
+
+/* Implement the following, as defined by SuSv3 */
+#if 0
+long double acoshl(long double);
+long double acosl(long double);
+long double asinhl(long double);
+long double asinl(long double);
+long double atan2l(long double, long double);
+long double atanhl(long double);
+long double atanl(long double);
+long double cbrtl(long double);
+long double ceill(long double);
+long double copysignl(long double, long double);
+long double coshl(long double);
+long double cosl(long double);
+long double erfcl(long double);
+long double erfl(long double);
+long double exp2l(long double);
+long double expl(long double);
+long double expm1l(long double);
+long double fabsl(long double);
+long double fdiml(long double, long double);
+long double floorl(long double);
+long double fmal(long double, long double, long double);
+long double fmaxl(long double, long double);
+long double fminl(long double, long double);
+long double fmodl(long double, long double);
+long double frexpl(long double value, int *);
+long double hypotl(long double, long double);
+int ilogbl(long double);
+long double ldexpl(long double, int);
+long double lgammal(long double);
+long long llrintl(long double);
+long long llroundl(long double);
+long double log10l(long double);
+long double log1pl(long double);
+long double log2l(long double);
+long double logbl(long double);
+long double logl(long double);
+long lrintl(long double);
+long lroundl(long double);
+long double modfl(long double, long double *);
+long double nearbyintl(long double);
+long double nextafterl(long double, long double);
+long double nexttowardl(long double, long double);
+long double powl(long double, long double);
+long double remainderl(long double, long double);
+long double remquol(long double, long double, int *);
+long double rintl(long double);
+long double roundl(long double);
+long double scalblnl(long double, long);
+long double scalbnl(long double, int);
+long double sinhl(long double);
+long double sinl(long double);
+long double sqrtl(long double);
+long double tanhl(long double);
+long double tanl(long double);
+long double tgammal(long double);
+long double truncl(long double);
+#endif
+
+#ifdef L_acoshl
+long double acoshl (long double x)
+{
+ return (long double) acosh( (double)x );
+}
+#endif
+
+
+#ifdef L_acosl
+long double acosl (long double x)
+{
+ return (long double) acos( (double)x );
+}
+#endif
+
+
+#ifdef L_asinhl
+long double asinhl (long double x)
+{
+ return (long double) asinh( (double)x );
+}
+#endif
+
+
+#ifdef L_asinl
+long double asinl (long double x)
+{
+ return (long double) asin( (double)x );
+}
+#endif
+
+
+#ifdef L_atan2l
+long double atan2l (long double x, long double y)
+{
+ return (long double) atan2( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_atanhl
+long double atanhl (long double x)
+{
+ return (long double) atanh( (double)x );
+}
+#endif
+
+
+#ifdef L_atanl
+long double atanl (long double x)
+{
+ return (long double) atan( (double)x );
+}
+#endif
+
+
+#ifdef L_cbrtl
+long double cbrtl (long double x)
+{
+ return (long double) cbrt( (double)x );
+}
+#endif
+
+
+#ifdef L_ceill
+long double ceill (long double x)
+{
+ return (long double) ceil( (double)x );
+}
+#endif
+
+
+#ifdef L_copysignl
+long double copysignl (long double x, long double y)
+{
+ return (long double) copysign( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_coshl
+long double coshl (long double x)
+{
+ return (long double) cosh( (double)x );
+}
+#endif
+
+
+#ifdef L_cosl
+long double cosl (long double x)
+{
+ return (long double) cos( (double)x );
+}
+#endif
+
+
+#ifdef L_erfcl
+long double erfcl (long double x)
+{
+ return (long double) erfc( (double)x );
+}
+#endif
+
+
+#ifdef L_erfl
+long double erfl (long double x)
+{
+ return (long double) erf( (double)x );
+}
+#endif
+
+
+#ifdef L_exp2l
+long double exp2l (long double x)
+{
+ return (long double) exp2( (double)x );
+}
+#endif
+
+
+#ifdef L_expl
+long double expl (long double x)
+{
+ return (long double) exp( (double)x );
+}
+#endif
+
+
+#ifdef L_expm1l
+long double expm1l (long double x)
+{
+ return (long double) expm1( (double)x );
+}
+#endif
+
+
+#ifdef L_fabsl
+long double fabsl (long double x)
+{
+ return (long double) fabs( (double)x );
+}
+#endif
+
+
+#ifdef L_fdiml
+long double fdiml (long double x, long double y)
+{
+ return (long double) fdim( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_floorl
+long double floorl (long double x)
+{
+ return (long double) floor( (double)x );
+}
+#endif
+
+
+#ifdef L_fmal
+long double fmal (long double x, long double y, long double z)
+{
+ return (long double) fma( (double)x, (double)y, (double)z );
+}
+#endif
+
+
+#ifdef L_fmaxl
+long double fmaxl (long double x, long double y)
+{
+ return (long double) fmax( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_fminl
+long double fminl (long double x, long double y)
+{
+ return (long double) fmin( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_fmodl
+long double fmodl (long double x, long double y)
+{
+ return (long double) fmod( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_frexpl
+long double frexpl (long double x, int *exp)
+{
+ return (long double) frexp( (double)x, exp );
+}
+#endif
+
+
+#ifdef L_hypotl
+long double hypotl (long double x, long double y)
+{
+ return (long double) hypot( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_ilogbl
+int ilogbl (long double x)
+{
+ return (long double) ilogb( (double)x );
+}
+#endif
+
+
+#ifdef L_ldexpl
+long double ldexpl (long double x, int exp)
+{
+ return (long double) ldexp( (double)x, exp );
+}
+#endif
+
+
+#ifdef L_lgammal
+long double lgammal (long double x)
+{
+ return (long double) lgamma( (double)x );
+}
+#endif
+
+
+#ifdef L_llrintl
+long long llrintl (long double x)
+{
+ return (long double) llrint( (double)x );
+}
+#endif
+
+
+#ifdef L_llroundl
+long long llroundl (long double x)
+{
+ return (long double) llround( (double)x );
+}
+#endif
+
+#ifdef L_log10l
+long double log10l (long double x)
+{
+ return (long double) log10( (double)x );
+}
+#endif
+
+
+#ifdef L_log1pl
+long double log1pl (long double x)
+{
+ return (long double) log1p( (double)x );
+}
+#endif
+
+
+#ifdef L_log2l
+long double log2l (long double x)
+{
+ return (long double) log2( (double)x );
+}
+#endif
+
+
+#ifdef L_logbl
+long double logbl (long double x)
+{
+ return (long double) logb( (double)x );
+}
+#endif
+
+
+#ifdef L_logl
+long double logl (long double x)
+{
+ return (long double) log( (double)x );
+}
+#endif
+
+
+#ifdef L_lrintl
+long lrintl (long double x)
+{
+ return (long double) lrint( (double)x );
+}
+#endif
+
+
+#ifdef L_lroundl
+long lroundl (long double x)
+{
+ return (long double) lround( (double)x );
+}
+#endif
+
+
+#ifdef L_modfl
+long double modfl (long double x, long double *iptr)
+{
+ double y, result;
+ result = modf ( x, &y );
+ *iptr = (long double)y;
+ return (long double) result;
+
+}
+#endif
+
+
+#ifdef L_nearbyintl
+long double nearbyintl (long double x)
+{
+ return (long double) nearbyint( (double)x );
+}
+#endif
+
+
+#ifdef L_nextafterl
+long double nextafterl (long double x, long double y)
+{
+ return (long double) nextafter( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_nexttowardl
+long double nexttowardl (long double x, long double y)
+{
+ return (long double) nexttoward( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_powl
+long double powl (long double x, long double y)
+{
+ return (long double) pow( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_remainderl
+long double remainderl (long double x, long double y)
+{
+ return (long double) remainder( (double)x, (double)y );
+}
+#endif
+
+
+#ifdef L_remquol
+long double remquol (long double x, long double y, int *quo)
+{
+ return (long double) remquo( (double)x, (double)y, quo );
+}
+#endif
+
+
+#ifdef L_rintl
+long double rintl (long double x)
+{
+ return (long double) rint( (double)x );
+}
+#endif
+
+
+#ifdef L_roundl
+long double roundl (long double x)
+{
+ return (long double) round( (double)x );
+}
+#endif
+
+
+#ifdef L_scalblnl
+long double scalblnl (long double x, long exp)
+{
+ return (long double) scalbln( (double)x, exp );
+}
+#endif
+
+
+#ifdef L_scalbnl
+long double scalbnl (long double x, int exp)
+{
+ return (long double) scalbn( (double)x, exp );
+}
+#endif
+
+
+#ifdef L_sinhl
+long double sinhl (long double x)
+{
+ return (long double) sinh( (double)x );
+}
+#endif
+
+
+#ifdef L_sinl
+long double sinl (long double x)
+{
+ return (long double) sin( (double)x );
+}
+#endif
+
+
+#ifdef L_sqrtl
+long double sqrtl (long double x)
+{
+ return (long double) sqrt( (double)x );
+}
+#endif
+
+
+#ifdef L_tanhl
+long double tanhl (long double x)
+{
+ return (long double) tanh( (double)x );
+}
+#endif
+
+
+#ifdef L_tanl
+long double tanl (long double x)
+{
+ return (long double) tan( (double)x );
+}
+#endif
+
+
+#ifdef L_tgammal
+long double tgammal (long double x)
+{
+ return (long double) tgamma( (double)x );
+}
+#endif
+
+
+#ifdef L_truncl
+long double truncl (long double x)
+{
+ return (long double) trunc( (double)x );
+}
+#endif
diff --git a/libm/math_private.h b/libm/math_private.h
index b0d948c07..f85db12a8 100644
--- a/libm/math_private.h
+++ b/libm/math_private.h
@@ -158,6 +158,7 @@ extern double __ieee754_sqrt (double) attribute_hidden;
extern double __ieee754_acos (double) attribute_hidden;
extern double __ieee754_acosh (double) attribute_hidden;
extern double __ieee754_log (double) attribute_hidden;
+extern double __ieee754_log2 (double) attribute_hidden;
extern double __ieee754_atanh (double) attribute_hidden;
extern double __ieee754_asin (double) attribute_hidden;
extern double __ieee754_atan2 (double,double) attribute_hidden;
diff --git a/libm/nan.c b/libm/nan.c
index 8d7998896..ec221ea71 100644
--- a/libm/nan.c
+++ b/libm/nan.c
@@ -1,3 +1,10 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
/***********************************************************************
nan, nanf, nanl - return quiet NaN
@@ -17,32 +24,37 @@
double nan (const char *tagp)
{
- if (tagp[0] != '\0') {
- char buf[6 + strlen (tagp)];
- sprintf (buf, "NAN(%s)", tagp);
- return strtod (buf, NULL);
- }
- return NAN;
+ if (tagp[0] != '\0') {
+ char buf[6 + strlen (tagp)];
+ sprintf (buf, "NAN(%s)", tagp);
+ return strtod (buf, NULL);
+ }
+ return NAN;
}
+libm_hidden_def(nan)
+libm_hidden_proto(nanf)
float nanf (const char *tagp)
{
- if (tagp[0] != '\0') {
- char buf[6 + strlen (tagp)];
- sprintf (buf, "NAN(%s)", tagp);
- return strtof (buf, NULL);
- }
- return NAN;
+ if (tagp[0] != '\0') {
+ char buf[6 + strlen (tagp)];
+ sprintf (buf, "NAN(%s)", tagp);
+ return strtof (buf, NULL);
+ }
+ return NAN;
}
+libm_hidden_def(nanf)
-#if 0
+#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__
+libm_hidden_proto(nanl)
long double nanl (const char *tagp)
{
- if (tagp[0] != '\0') {
- char buf[6 + strlen (tagp)];
- sprintf (buf, "NAN(%s)", tagp);
- return strtold (buf, NULL);
- }
- return NAN;
+ if (tagp[0] != '\0') {
+ char buf[6 + strlen (tagp)];
+ sprintf (buf, "NAN(%s)", tagp);
+ return strtold (buf, NULL);
+ }
+ return NAN;
}
+libm_hidden_def(nanl)
#endif
diff --git a/libm/powerpc/classic/s_ceil.c b/libm/powerpc/classic/s_ceil.c
deleted file mode 100644
index ee4ceb5fc..000000000
--- a/libm/powerpc/classic/s_ceil.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
-* *
-* File ceilfloor.c, *
-* Function ceil(x) and floor(x), *
-* Implementation of ceil and floor for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on November 1991, *
-* *
-* based on math.h, library code for Macintoshes with a 68881/68882 *
-* by Jim Thomas. *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December 03 1992: first rs6000 port. *
-* July 14 1993: comment changes and addition of #pragma fenv_access. *
-* May 06 1997: port of the ibm/taligent ceil and floor routines. *
-* April 11 2001: first port to os x using gcc. *
-* June 13 2001: replaced __setflm with in-line assembly *
-* *
-*******************************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-static const double twoTo52 = 4503599627370496.0;
-static const unsigned long signMask = 0x80000000ul;
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-/*******************************************************************************
-* Functions needed for the computation. *
-*******************************************************************************/
-
-/*******************************************************************************
-* Ceil(x) returns the smallest integer not less than x. *
-*******************************************************************************/
-
-libm_hidden_proto(ceil)
-double ceil ( double x )
- {
- DblInHex xInHex,OldEnvironment;
- register double y;
- register unsigned long int xhi;
- register int target;
-
- xInHex.dbl = x;
- xhi = xInHex.words.hi & 0x7fffffffUL; // xhi is the high half of |x|
- target = ( xInHex.words.hi < signMask );
-
- if ( xhi < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xhi < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( ( xhi | xInHex.words.lo ) == 0ul ) // zero x is exact case
- return ( x );
- else
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 1.0 );
- else
- return ( -0.0 );
- }
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- {
- y = ( x + twoTo52 ) - twoTo52; // round at binary pt.
- if ( y < x )
- return ( y + 1.0 );
- else
- return ( y );
- }
-
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary pt.
- if ( y < x )
- return ( y + 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(ceil)
diff --git a/libm/powerpc/classic/s_copysign.c b/libm/powerpc/classic/s_copysign.c
deleted file mode 100644
index c6f1307a3..000000000
--- a/libm/powerpc/classic/s_copysign.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
-* *
-* File sign.c, *
-* Functions copysign and __signbitd. *
-* For PowerPC based machines. *
-* *
-* Copyright © 1991, 2001 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on June 1991. *
-* *
-* August 26 1991: no CFront Version 1.1d17 warnings. *
-* September 06 1991: passes the test suite with invalid raised on *
-* signaling nans. sane rom code behaves the same. *
-* September 24 1992: took the Ò#include support.hÓ out. *
-* Dcember 02 1992: PowerPC port. *
-* July 20 1994: __fabs added *
-* July 21 1994: deleted unnecessary functions: neg, COPYSIGNnew, *
-* and SIGNNUMnew. *
-* April 11 2001: first port to os x using gcc. *
-* removed fabs and deffered to gcc for direct *
-* instruction generation. *
-* *
-*******************************************************************************/
-
-#include <math.h>
-#include "../../fp_private.h"
-
-/*******************************************************************************
-* *
-* Function copysign. *
-* Implementation of copysign for the PowerPC. *
-* *
-********************************************************************************
-* Note: The order of the operands in this function is reversed from that *
-* suggested in the IEEE standard 754. *
-*******************************************************************************/
-
-libm_hidden_proto(copysign)
-double copysign ( double arg2, double arg1 )
- {
- union
- {
- dHexParts hex;
- double dbl;
- } x, y;
-
-/*******************************************************************************
-* No need to flush NaNs out. *
-*******************************************************************************/
-
- x.dbl = arg1;
- y.dbl = arg2;
-
- y.hex.high = y.hex.high & 0x7FFFFFFF;
- y.hex.high = ( y.hex.high | ( x.hex.high & dSgnMask ) );
-
- return y.dbl;
- }
-libm_hidden_def(copysign)
diff --git a/libm/powerpc/classic/s_floor.c b/libm/powerpc/classic/s_floor.c
deleted file mode 100644
index 2cd720eff..000000000
--- a/libm/powerpc/classic/s_floor.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
-* *
-* File ceilfloor.c, *
-* Function ceil(x) and floor(x), *
-* Implementation of ceil and floor for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on November 1991, *
-* *
-* based on math.h, library code for Macintoshes with a 68881/68882 *
-* by Jim Thomas. *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December 03 1992: first rs6000 port. *
-* July 14 1993: comment changes and addition of #pragma fenv_access. *
-* May 06 1997: port of the ibm/taligent ceil and floor routines. *
-* April 11 2001: first port to os x using gcc. *
-* June 13 2001: replaced __setflm with in-line assembly *
-* *
-*******************************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-static const double twoTo52 = 4503599627370496.0;
-static const unsigned long signMask = 0x80000000ul;
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-/*******************************************************************************
-* Functions needed for the computation. *
-*******************************************************************************/
-
-/*******************************************************************************
-* Floor(x) returns the largest integer not greater than x. *
-*******************************************************************************/
-
-libm_hidden_proto(floor)
-double floor ( double x )
- {
- DblInHex xInHex,OldEnvironment;
- register double y;
- register unsigned long int xhi;
- register long int target;
-
- xInHex.dbl = x;
- xhi = xInHex.words.hi & 0x7fffffffUL; // xhi is the high half of |x|
- target = ( xInHex.words.hi < signMask );
-
- if ( xhi < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xhi < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( ( xhi | xInHex.words.lo ) == 0ul ) // zero x is exact case
- return ( x );
- else
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 0.0 );
- else
- return ( -1.0 );
- }
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- {
- y = ( x + twoTo52 ) - twoTo52; // round at binary pt.
- if ( y > x )
- return ( y - 1.0 );
- else
- return ( y );
- }
-
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary pt.
- if ( y > x )
- return ( y - 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(floor)
diff --git a/libm/powerpc/classic/s_frexp.c b/libm/powerpc/classic/s_frexp.c
deleted file mode 100644
index 001aaf708..000000000
--- a/libm/powerpc/classic/s_frexp.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
-* *
-* File frexpldexp.c, *
-* Functions frexp(x) and ldexp(x), *
-* Implementation of frexp and ldexp functions for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on January 1991, *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December03 1992: first rs6000 implementation. *
-* October 05 1993: added special cases for NaN and ° in frexp. *
-* May 27 1997: improved the performance of frexp by eliminating the *
-* switch statement. *
-* June 13 2001: (ram) rewrote frexp to eliminate calls to scalb and *
-* logb. *
-* *
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-libm_hidden_proto(frexp)
-double frexp ( double value, int *eptr )
- {
- DblInHex argument;
- unsigned long int valueHead;
-
- argument.dbl = value;
- valueHead = argument.words.hi & 0x7fffffffUL; // valueHead <- |x|
-
- *eptr = 0;
- if ( valueHead >= 0x7ff00000 || ( valueHead | argument.words.lo ) == 0 )
- return value; // 0, inf, or NaN
-
- if ( valueHead < 0x00100000 )
- { // denorm
- argument.dbl = two54 * value;
- valueHead = argument.words.hi &0x7fffffff;
- *eptr = -54;
- }
- *eptr += ( valueHead >> 20 ) - 1022;
- argument.words.hi = ( argument.words.hi & 0x800fffff ) | 0x3fe00000;
- return argument.dbl;
- }
-libm_hidden_def(frexp)
diff --git a/libm/powerpc/classic/s_ldexp.c b/libm/powerpc/classic/s_ldexp.c
deleted file mode 100644
index 10100d7c2..000000000
--- a/libm/powerpc/classic/s_ldexp.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
-* *
-* File frexpldexp.c, *
-* Functions frexp(x) and ldexp(x), *
-* Implementation of frexp and ldexp functions for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on January 1991, *
-* *
-* W A R N I N G: This routine expects a 64 bit double model. *
-* *
-* December03 1992: first rs6000 implementation. *
-* October 05 1993: added special cases for NaN and ° in frexp. *
-* May 27 1997: improved the performance of frexp by eliminating the *
-* switch statement. *
-* June 13 2001: (ram) rewrote frexp to eliminate calls to scalb and *
-* logb. *
-* *
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-libm_hidden_proto(ldexp)
-double ldexp ( double value, int exp )
- {
- if ( exp > SHRT_MAX )
- exp = SHRT_MAX;
- else if ( exp < -SHRT_MAX )
- exp = -SHRT_MAX;
- return scalb ( value, exp );
- }
-libm_hidden_def(ldexp)
diff --git a/libm/powerpc/classic/s_logb.c b/libm/powerpc/classic/s_logb.c
deleted file mode 100644
index 81daa412e..000000000
--- a/libm/powerpc/classic/s_logb.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
-* *
-* File logb.c, *
-* Functions logb. *
-* Implementation of logb for the PowerPC. *
-* *
-* Copyright © 1991 Apple Computer, Inc. All rights reserved. *
-* *
-* Written by Ali Sazegari, started on June 1991, *
-* *
-* August 26 1991: removed CFront Version 1.1d17 warnings. *
-* August 27 1991: no errors reported by the test suite. *
-* November 11 1991: changed CLASSEXTENDED to the macro CLASSIFY and *
-* + or - infinity to constants. *
-* November 18 1991: changed the macro CLASSIFY to CLASSEXTENDEDint to *
-* improve performance. *
-* February 07 1992: changed bit operations to macros ( object size is *
-* unchanged ). *
-* September24 1992: took the "#include support.h" out. *
-* December 03 1992: first rs/6000 port. *
-* August 30 1992: set the divide by zero for the zero argument case. *
-* October 05 1993: corrected the environment. *
-* October 17 1994: replaced all environmental functions with __setflm. *
-* May 28 1997: made speed improvements. *
-* April 30 2001: forst mac os x port using gcc. *
-* *
-********************************************************************************
-* The C math library offers a similar function called "frexp". It is *
-* different in details from logb, but similar in spirit. This current *
-* implementation of logb follows the recommendation in IEEE Standard 854 *
-* which is different in its handling of denormalized numbers from the IEEE *
-* Standard 754. *
-*******************************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const double twoTo52 = 4.50359962737049600e15; // 0x1p52
-static const double klTod = 4503601774854144.0; // 0x1.000008p52
-static const unsigned long int signMask = 0x80000000ul;
-static const DblInHex minusInf = {{ 0xFFF00000, 0x00000000 }};
-
-
-/*******************************************************************************
-********************************************************************************
-* L O G B *
-********************************************************************************
-*******************************************************************************/
-
-libm_hidden_proto(logb)
-double logb ( double x )
- {
- DblInHex xInHex;
- long int shiftedExp;
-
- xInHex.dbl = x;
- shiftedExp = ( xInHex.words.hi & 0x7ff00000UL ) >> 20;
-
- if ( shiftedExp == 2047 )
- { // NaN or INF
- if ( ( ( xInHex.words.hi & signMask ) == 0 ) || ( x != x ) )
- return x; // NaN or +INF return x
- else
- return -x; // -INF returns +INF
- }
-
- if ( shiftedExp != 0 ) // normal number
- shiftedExp -= 1023; // unbias exponent
-
- else if ( x == 0.0 )
- { // zero
- xInHex.words.hi = 0x0UL; // return -infinity
- return ( minusInf.dbl );
- }
-
- else
- { // subnormal number
- xInHex.dbl *= twoTo52; // scale up
- shiftedExp = ( xInHex.words.hi & 0x7ff00000UL ) >> 20;
- shiftedExp -= 1075; // unbias exponent
- }
-
- if ( shiftedExp == 0 ) // zero result
- return ( 0.0 );
-
- else
- { // nonzero result
- xInHex.dbl = klTod;
- xInHex.words.lo += shiftedExp;
- return ( xInHex.dbl - klTod );
- }
- }
-libm_hidden_def(logb)
diff --git a/libm/powerpc/classic/s_modf.c b/libm/powerpc/classic/s_modf.c
deleted file mode 100644
index c2221bc0b..000000000
--- a/libm/powerpc/classic/s_modf.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
-** File: rndint.c
-**
-** Contains: C source code for implementations of floating-point
-** functions which round to integral value or format, as
-** defined in header <fp.h>. In particular, this file
-** contains implementations of functions rinttol, roundtol,
-** modf and modfl. This file targets PowrPC or Power platforms.
-**
-** Written by: A. Sazegari, Apple AltiVec Group
-** Created originally by Jon Okada, Apple Numerics Group
-**
-** Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved
-**
-** Change History (most recent first):
-**
-** 13 Jul 01 ram replaced --setflm calls with inline assembly
-** 03 Mar 01 ali first port to os x using gcc, added the crucial __setflm
-** definition.
-** 1. removed double_t, put in double for now.
-** 2. removed iclass from nearbyint.
-** 3. removed wrong comments intrunc.
-** 4.
-** 13 May 97 ali made performance improvements in rint, rinttol, roundtol
-** and trunc by folding some of the taligent ideas into this
-** implementation. nearbyint is faster than the one in taligent,
-** rint is more elegant, but slower by %30 than the taligent one.
-** 09 Apr 97 ali deleted modfl and deferred to AuxiliaryDD.c
-** 15 Sep 94 ali Major overhaul and performance improvements of all functions.
-** 20 Jul 94 PAF New faster version
-** 16 Jul 93 ali Added the modfl function.
-** 18 Feb 93 ali Changed the return value of fenv functions
-** feclearexcept and feraiseexcept to their new
-** NCEG X3J11.1/93-001 definitions.
-** 16 Dec 92 JPO Removed __itrunc implementation to a
-** separate file.
-** 15 Dec 92 JPO Added __itrunc implementation and modified
-** rinttol to include conversion from double
-** to long int format. Modified roundtol to
-** call __itrunc.
-** 10 Dec 92 JPO Added modf (double) implementation.
-** 04 Dec 92 JPO First created.
-**
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-#define SET_INVALID 0x01000000UL
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-static const double doubleToLong = 4503603922337792.0; // 2^52
-static const DblInHex TOWARDZERO = {{ 0x00000000, 0x00000001 }};
-
-
-/*******************************************************************************
-* *
-* The function rinttol converts its double argument to integral value *
-* according to the current rounding direction and returns the result in *
-* long int format. This conversion signals invalid if the argument is a *
-* NaN or the rounded intermediate result is out of range of the *
-* destination long int format, and it delivers an unspecified result in *
-* this case. This function signals inexact if the rounded result is *
-* within range of the long int format but unequal to the operand. *
-* *
-*******************************************************************************/
-
-long int rinttol ( double x )
- {
- register double y;
- DblInHex argument, OldEnvironment;
- unsigned long int xHead;
- register long int target;
-
- argument.dbl = x;
- target = ( argument.words.hi < signMask ); // flag positive sign
- xHead = argument.words.hi & 0x7ffffffful; // high 32 bits of x
-
- if ( target )
-/*******************************************************************************
-* Sign of x is positive. *
-*******************************************************************************/
- {
- if ( xHead < 0x41dffffful )
- { // x is safely in long range
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- argument.dbl = y + doubleToLong; // force result into argument.words.lo
- return ( ( long ) argument.words.lo );
- }
-
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
-
- if ( xHead > 0x41dffffful )
- { // x is safely out of long range
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MAX );
- }
-
-/*******************************************************************************
-* x > 0.0 and may or may not be out of range of long. *
-*******************************************************************************/
-
- y = ( x + twoTo52 ) - twoTo52; // do rounding
- if ( y > ( double ) LONG_MAX )
- { // out of range of long
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MAX );
- }
- argument.dbl = y + doubleToLong; // in range
- return ( ( long ) argument.words.lo ); // return result & flags
- }
-
-/*******************************************************************************
-* Sign of x is negative. *
-*******************************************************************************/
- if ( xHead < 0x41e00000ul )
- { // x is safely in long range
- y = ( x - twoTo52 ) + twoTo52;
- argument.dbl = y + doubleToLong;
- return ( ( long ) argument.words.lo );
- }
-
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
-
- if ( xHead > 0x41e00000ul )
- { // x is safely out of long range
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MIN );
- }
-
-/*******************************************************************************
-* x < 0.0 and may or may not be out of range of long. *
-*******************************************************************************/
-
- y = ( x - twoTo52 ) + twoTo52; // do rounding
- if ( y < ( double ) LONG_MIN )
- { // out of range of long
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MIN );
- }
- argument.dbl = y + doubleToLong; // in range
- return ( ( long ) argument.words.lo ); // return result & flags
- }
-
-/*******************************************************************************
-* *
-* The function roundtol converts its double argument to integral format *
-* according to the "add half to the magnitude and chop" rounding mode of *
-* Pascal's Round function and FORTRAN's NINT function. This conversion *
-* signals invalid if the argument is a NaN or the rounded intermediate *
-* result is out of range of the destination long int format, and it *
-* delivers an unspecified result in this case. This function signals *
-* inexact if the rounded result is within range of the long int format but *
-* unequal to the operand. *
-* *
-*******************************************************************************/
-
-long int roundtol ( double x )
- {
- register double y, z;
- DblInHex argument, OldEnvironment;
- register unsigned long int xhi;
- register long int target;
- const DblInHex kTZ = {{ 0x0, 0x1 }};
- const DblInHex kUP = {{ 0x0, 0x2 }};
-
- argument.dbl = x;
- xhi = argument.words.hi & 0x7ffffffful; // high 32 bits of x
- target = ( argument.words.hi < signMask ); // flag positive sign
-
- if ( xhi > 0x41e00000ul )
-/*******************************************************************************
-* Is x is out of long range or NaN? *
-*******************************************************************************/
- {
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target ) // pin result
- return ( LONG_MAX );
- else
- return ( LONG_MIN );
- }
-
- if ( target )
-/*******************************************************************************
-* Is sign of x is "+"? *
-*******************************************************************************/
- {
- if ( x < 2147483647.5 )
-/*******************************************************************************
-* x is in the range of a long. *
-*******************************************************************************/
- {
- y = ( x + doubleToLong ) - doubleToLong; // round at binary point
- if ( y != x )
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // save environment
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( kTZ.dbl )); // truncate rounding
- z = x + 0.5; // truncate x + 0.5
- argument.dbl = z + doubleToLong;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( ( long ) argument.words.lo );
- }
-
- argument.dbl = y + doubleToLong; // force result into argument.words.lo
- return ( ( long ) argument.words.lo ); // return long result
- }
-/*******************************************************************************
-* Rounded positive x is out of the range of a long. *
-*******************************************************************************/
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MAX ); // return pinned result
- }
-/*******************************************************************************
-* x < 0.0 and may or may not be out of the range of a long. *
-*******************************************************************************/
- if ( x > -2147483648.5 )
-/*******************************************************************************
-* x is in the range of a long. *
-*******************************************************************************/
- {
- y = ( x + doubleToLong ) - doubleToLong; // round at binary point
- if ( y != x )
- { // inexact case
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // save environment
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( kUP.dbl )); // round up
- z = x - 0.5; // truncate x - 0.5
- argument.dbl = z + doubleToLong;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( ( long ) argument.words.lo );
- }
-
- argument.dbl = y + doubleToLong;
- return ( ( long ) argument.words.lo ); // return long result
- }
-/*******************************************************************************
-* Rounded negative x is out of the range of a long. *
-*******************************************************************************/
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= SET_INVALID;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- return ( LONG_MIN ); // return pinned result
- }
-
-/*******************************************************************************
-* The modf family of functions separate a floating-point number into its *
-* fractional and integral parts, returning the fractional part and writing *
-* the integral part in floating-point format to the object pointed to by a *
-* pointer argument. If the input argument is integral or infinite in *
-* value, the return value is a zero with the sign of the input argument. *
-* The modf family of functions raises no floating-point exceptions. older *
-* implemenation set the INVALID flag due to signaling NaN input. *
-* *
-*******************************************************************************/
-
-/*******************************************************************************
-* modf is the double implementation. *
-*******************************************************************************/
-
-libm_hidden_proto(modf)
-double modf ( double x, double *iptr )
- {
- register double OldEnvironment, xtrunc;
- register unsigned long int xHead, signBit;
- DblInHex argument;
-
- argument.dbl = x;
- xHead = argument.words.hi & 0x7ffffffful; // |x| high bit pattern
- signBit = ( argument.words.hi & 0x80000000ul ); // isolate sign bit
- if (xHead == 0x7ff81fe0)
- signBit = signBit | 0;
-
- if ( xHead < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^53? *
-*******************************************************************************/
- {
- if ( xHead < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- argument.words.hi = signBit; // truncate to zero
- argument.words.lo = 0ul;
- *iptr = argument.dbl;
- return ( x );
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- __asm__ ("mffs %0" : "=f" (OldEnvironment)); // save environment
- // round toward zero
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( TOWARDZERO.dbl ));
- if ( signBit == 0ul ) // truncate to integer
- xtrunc = ( x + twoTo52 ) - twoTo52;
- else
- xtrunc = ( x - twoTo52 ) + twoTo52;
- // restore caller's env
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment ));
- *iptr = xtrunc; // store integral part
- if ( x != xtrunc ) // nonzero fraction
- return ( x - xtrunc );
- else
- { // zero with x's sign
- argument.words.hi = signBit;
- argument.words.lo = 0ul;
- return ( argument.dbl );
- }
- }
-
- *iptr = x; // x is integral or NaN
- if ( x != x ) // NaN is returned
- return x;
- else
- { // zero with x's sign
- argument.words.hi = signBit;
- argument.words.lo = 0ul;
- return ( argument.dbl );
- }
- }
-libm_hidden_def(modf)
diff --git a/libm/powerpc/classic/s_nearbyint.c b/libm/powerpc/classic/s_nearbyint.c
deleted file mode 100644
index d08430dc6..000000000
--- a/libm/powerpc/classic/s_nearbyint.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <limits.h>
-#include <math.h>
-
-/*******************************************************************************
-* *
-* The function nearbyint rounds its double argument to integral value *
-* according to the current rounding direction and returns the result in *
-* double format. This function does not signal inexact. *
-* *
-********************************************************************************
-* *
-* This function calls fabs and copysign. *
-* *
-*******************************************************************************/
-
-static const double twoTo52 = 4503599627370496.0;
-
-libm_hidden_proto(nearbyint)
-double nearbyint ( double x )
- {
- double y;
- double OldEnvironment;
-
- y = twoTo52;
-
- __asm__ ("mffs %0" : "=f" (OldEnvironment)); /* get the environement */
-
- if ( fabs ( x ) >= y ) /* huge case is exact */
- return x;
- if ( x < 0 ) y = -y; /* negative case */
- y = ( x + y ) - y; /* force rounding */
- if ( y == 0.0 ) /* zero results mirror sign of x */
- y = copysign ( y, x );
-// restore old flags
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment ));
- return ( y );
- }
-libm_hidden_def(nearbyint)
diff --git a/libm/powerpc/classic/s_rint.c b/libm/powerpc/classic/s_rint.c
deleted file mode 100644
index dd2ae585e..000000000
--- a/libm/powerpc/classic/s_rint.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
-** File: rndint.c
-**
-** Contains: C source code for implementations of floating-point
-** functions which round to integral value or format, as
-** defined in header <fp.h>. In particular, this file
-** contains implementations of functions rint, nearbyint,
-** rinttol, round, roundtol, trunc, modf and modfl. This file
-** targets PowerPC or Power platforms.
-**
-** Written by: A. Sazegari, Apple AltiVec Group
-** Created originally by Jon Okada, Apple Numerics Group
-**
-** Copyright: © 1992-2001 by Apple Computer, Inc., all rights reserved
-**
-** Change History (most recent first):
-**
-** 13 Jul 01 ram replaced --setflm calls with inline assembly
-** 03 Mar 01 ali first port to os x using gcc, added the crucial __setflm
-** definition.
-** 1. removed double_t, put in double for now.
-** 2. removed iclass from nearbyint.
-** 3. removed wrong comments intrunc.
-** 4.
-** 13 May 97 ali made performance improvements in rint, rinttol, roundtol
-** and trunc by folding some of the taligent ideas into this
-** implementation. nearbyint is faster than the one in taligent,
-** rint is more elegant, but slower by %30 than the taligent one.
-** 09 Apr 97 ali deleted modfl and deferred to AuxiliaryDD.c
-** 15 Sep 94 ali Major overhaul and performance improvements of all functions.
-** 20 Jul 94 PAF New faster version
-** 16 Jul 93 ali Added the modfl function.
-** 18 Feb 93 ali Changed the return value of fenv functions
-** feclearexcept and feraiseexcept to their new
-** NCEG X3J11.1/93-001 definitions.
-** 16 Dec 92 JPO Removed __itrunc implementation to a
-** separate file.
-** 15 Dec 92 JPO Added __itrunc implementation and modified
-** rinttol to include conversion from double
-** to long int format. Modified roundtol to
-** call __itrunc.
-** 10 Dec 92 JPO Added modf (double) implementation.
-** 04 Dec 92 JPO First created.
-**
-*******************************************************************************/
-
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-#define SET_INVALID 0x01000000UL
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-static const double doubleToLong = 4503603922337792.0; // 2^52
-static const DblInHex Huge = {{ 0x7FF00000, 0x00000000 }};
-static const DblInHex TOWARDZERO = {{ 0x00000000, 0x00000001 }};
-
-libm_hidden_proto(rint)
-/*******************************************************************************
-* *
-* The function rint rounds its double argument to integral value *
-* according to the current rounding direction and returns the result in *
-* double format. This function signals inexact if an ordered return *
-* value is not equal to the operand. *
-* *
-********************************************************************************
-* *
-* This function calls: fabs. *
-* *
-*******************************************************************************/
-
-/*******************************************************************************
-* First, an elegant implementation. *
-********************************************************************************
-*
-*double rint ( double x )
-* {
-* double y;
-*
-* y = twoTo52.fval;
-*
-* if ( fabs ( x ) >= y ) // huge case is exact
-* return x;
-* if ( x < 0 ) y = -y; // negative case
-* y = ( x + y ) - y; // force rounding
-* if ( y == 0.0 ) // zero results mirror sign of x
-* y = copysign ( y, x );
-* return ( y );
-* }
-********************************************************************************
-* Now a bit twidling version that is about %30 faster. *
-*******************************************************************************/
-
-double rint ( double x )
- {
- DblInHex argument;
- register double y;
- unsigned long int xHead;
- register long int target;
-
- argument.dbl = x;
- xHead = argument.words.hi & 0x7fffffffUL; // xHead <- high half of |x|
- target = ( argument.words.hi < signMask ); // flags positive sign
-
- if ( xHead < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xHead < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( target )
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- else
- y = ( x - twoTo52 ) + twoTo52; // round at binary point
- if ( y == 0.0 )
- { // fix sign of zero result
- if ( target )
- return ( 0.0 );
- else
- return ( -0.0 );
- }
- return y;
- }
-
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
-
- if ( target )
- return ( ( x + twoTo52 ) - twoTo52 ); // round at binary pt.
- else
- return ( ( x - twoTo52 ) + twoTo52 );
- }
-
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(rint)
diff --git a/libm/powerpc/classic/s_round.c b/libm/powerpc/classic/s_round.c
deleted file mode 100644
index 9fd73801d..000000000
--- a/libm/powerpc/classic/s_round.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-
-/*******************************************************************************
-* *
-* The function round rounds its double argument to integral value *
-* according to the "add half to the magnitude and truncate" rounding of *
-* Pascal's Round function and FORTRAN's ANINT function and returns the *
-* result in double format. This function signals inexact if an ordered *
-* return value is not equal to the operand. *
-* *
-*******************************************************************************/
-
-libm_hidden_proto(round)
-double round ( double x )
- {
- DblInHex argument, OldEnvironment;
- register double y, z;
- register unsigned long int xHead;
- register long int target;
-
- argument.dbl = x;
- xHead = argument.words.hi & 0x7fffffffUL; // xHead <- high half of |x|
- target = ( argument.words.hi < signMask ); // flag positive sign
-
- if ( xHead < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^52? *
-*******************************************************************************/
- {
- if ( xHead < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl)); // get environment
- if ( xHead < 0x3fe00000ul )
-/*******************************************************************************
-* Is |x| < 0.5? *
-*******************************************************************************/
- {
- if ( ( xHead | argument.words.lo ) != 0ul )
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 0.0 );
- else
- return ( -0.0 );
- }
-/*******************************************************************************
-* Is 0.5 ² |x| < 1.0? *
-*******************************************************************************/
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- if ( target )
- return ( 1.0 );
- else
- return ( -1.0 );
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- { // positive x
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- if ( y == x ) // exact case
- return ( x );
- z = x + 0.5; // inexact case
- y = ( z + twoTo52 ) - twoTo52; // round at binary point
- if ( y > z )
- return ( y - 1.0 );
- else
- return ( y );
- }
-
-/*******************************************************************************
-* Is x < 0? *
-*******************************************************************************/
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary point
- if ( y == x )
- return ( x );
- z = x - 0.5;
- y = ( z - twoTo52 ) + twoTo52; // round at binary point
- if ( y < z )
- return ( y + 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(round)
diff --git a/libm/powerpc/classic/s_trunc.c b/libm/powerpc/classic/s_trunc.c
deleted file mode 100644
index e9c668127..000000000
--- a/libm/powerpc/classic/s_trunc.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <limits.h>
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const unsigned long int signMask = 0x80000000ul;
-static const double twoTo52 = 4503599627370496.0;
-
-/*******************************************************************************
-* *
-* The function trunc truncates its double argument to integral value *
-* and returns the result in double format. This function signals *
-* inexact if an ordered return value is not equal to the operand. *
-* *
-*******************************************************************************/
-
-libm_hidden_proto(trunc)
-double trunc ( double x )
- {
- DblInHex argument,OldEnvironment;
- register double y;
- register unsigned long int xhi;
- register long int target;
-
- argument.dbl = x;
- xhi = argument.words.hi & 0x7fffffffUL; // xhi <- high half of |x|
- target = ( argument.words.hi < signMask ); // flag positive sign
-
- if ( xhi < 0x43300000ul )
-/*******************************************************************************
-* Is |x| < 2.0^53? *
-*******************************************************************************/
- {
- if ( xhi < 0x3ff00000ul )
-/*******************************************************************************
-* Is |x| < 1.0? *
-*******************************************************************************/
- {
- if ( ( xhi | argument.words.lo ) != 0ul )
- { // raise deserved INEXACT
- __asm__ ("mffs %0" : "=f" (OldEnvironment.dbl));
- OldEnvironment.words.lo |= 0x02000000ul;
- __asm__ ("mtfsf 255,%0" : /*NULLOUT*/ : /*IN*/ "f" ( OldEnvironment.dbl ));
- }
- if ( target ) // return properly signed zero
- return ( 0.0 );
- else
- return ( -0.0 );
- }
-/*******************************************************************************
-* Is 1.0 < |x| < 2.0^52? *
-*******************************************************************************/
- if ( target )
- {
- y = ( x + twoTo52 ) - twoTo52; // round at binary point
- if ( y > x )
- return ( y - 1.0 );
- else
- return ( y );
- }
-
- else
- {
- y = ( x - twoTo52 ) + twoTo52; // round at binary point.
- if ( y < x )
- return ( y + 1.0 );
- else
- return ( y );
- }
- }
-/*******************************************************************************
-* Is |x| >= 2.0^52 or x is a NaN. *
-*******************************************************************************/
- return ( x );
- }
-libm_hidden_def(trunc)
diff --git a/libm/powerpc/classic/w_scalb.c b/libm/powerpc/classic/w_scalb.c
deleted file mode 100644
index 408136001..000000000
--- a/libm/powerpc/classic/w_scalb.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/***********************************************************************
-** File: scalb.c
-**
-** Contains: C source code for implementations of floating-point
-** scalb functions defined in header <fp.h>. In
-** particular, this file contains implementations of
-** functions scalb and scalbl for double and long double
-** formats on PowerPC platforms.
-**
-** Written by: Jon Okada, SANEitation Engineer, ext. 4-4838
-**
-** Copyright: © 1992 by Apple Computer, Inc., all rights reserved
-**
-** Change History ( most recent first ):
-**
-** 28 May 97 ali made an speed improvement for large n,
-** removed scalbl.
-** 12 Dec 92 JPO First created.
-**
-***********************************************************************/
-
-#include <math.h>
-#include <endian.h>
-
-typedef union
- {
- struct {
-#if (__BYTE_ORDER == __BIG_ENDIAN)
- unsigned long int hi;
- unsigned long int lo;
-#else
- unsigned long int lo;
- unsigned long int hi;
-#endif
- } words;
- double dbl;
- } DblInHex;
-
-static const double twoTo1023 = 8.988465674311579539e307; // 0x1p1023
-static const double twoToM1022 = 2.225073858507201383e-308; // 0x1p-1022
-
-
-/***********************************************************************
- double scalb( double x, long int n ) returns its argument x scaled
- by the factor 2^m. NaNs, signed zeros, and infinities are propagated
- by this function regardless of the value of n.
-
- Exceptions: OVERFLOW/INEXACT or UNDERFLOW inexact may occur;
- INVALID for signaling NaN inputs ( quiet NaN returned ).
-
- Calls: none.
-***********************************************************************/
-
-libm_hidden_proto(scalb)
-#ifdef _SCALB_INT
-double scalb ( double x, int n )
-#else
-double scalb ( double x, double n )
-#endif
- {
- DblInHex xInHex;
-
- xInHex.words.lo = 0UL; // init. low half of xInHex
-
- if ( n > 1023 )
- { // large positive scaling
- if ( n > 2097 ) // huge scaling
- return ( ( x * twoTo1023 ) * twoTo1023 ) * twoTo1023;
- while ( n > 1023 )
- { // scale reduction loop
- x *= twoTo1023; // scale x by 2^1023
- n -= 1023; // reduce n by 1023
- }
- }
-
- else if ( n < -1022 )
- { // large negative scaling
- if ( n < -2098 ) // huge negative scaling
- return ( ( x * twoToM1022 ) * twoToM1022 ) * twoToM1022;
- while ( n < -1022 )
- { // scale reduction loop
- x *= twoToM1022; // scale x by 2^( -1022 )
- n += 1022; // incr n by 1022
- }
- }
-
-/*******************************************************************************
-* -1022 <= n <= 1023; convert n to double scale factor. *
-*******************************************************************************/
-
- xInHex.words.hi = ( ( unsigned long ) ( n + 1023 ) ) << 20;
- return ( x * xInHex.dbl );
- }
-libm_hidden_def(scalb)
diff --git a/libm/s_asinh.c b/libm/s_asinh.c
index 9e9a05660..efdee84a6 100644
--- a/libm/s_asinh.c
+++ b/libm/s_asinh.c
@@ -28,8 +28,6 @@ static char rcsid[] = "$NetBSD: s_asinh.c,v 1.9 1995/05/12 04:57:37 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log1p)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
@@ -40,7 +38,6 @@ one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
huge= 1.00000000000000000000e+300;
-libm_hidden_proto(asinh)
#ifdef __STDC__
double asinh(double x)
#else
diff --git a/libm/s_atan.c b/libm/s_atan.c
index 9c8035569..7546ae9a0 100644
--- a/libm/s_atan.c
+++ b/libm/s_atan.c
@@ -37,7 +37,6 @@ static char rcsid[] = "$NetBSD: s_atan.c,v 1.8 1995/05/10 20:46:45 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double atanhi[] = {
@@ -79,7 +78,6 @@ static double aT[] = {
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
};
-libm_hidden_proto(atan)
#ifdef __STDC__
static const double
#else
diff --git a/libm/s_cbrt.c b/libm/s_cbrt.c
index f4635874c..d47373e82 100644
--- a/libm/s_cbrt.c
+++ b/libm/s_cbrt.c
@@ -39,7 +39,6 @@ E = 1.41428571428571436819e+00, /* 99/70 = 0x3FF6A0EA, 0x0EA0EA0F */
F = 1.60714285714285720630e+00, /* 45/28 = 0x3FF9B6DB, 0x6DB6DB6E */
G = 3.57142857142857150787e-01; /* 5/14 = 0x3FD6DB6D, 0xB6DB6DB7 */
-libm_hidden_proto(cbrt)
#ifdef __STDC__
double cbrt(double x)
#else
diff --git a/libm/s_ceil.c b/libm/s_ceil.c
index 46839410e..76be3ea43 100644
--- a/libm/s_ceil.c
+++ b/libm/s_ceil.c
@@ -32,7 +32,6 @@ static const double huge = 1.0e300;
static double huge = 1.0e300;
#endif
-libm_hidden_proto(ceil)
#ifdef __STDC__
double ceil(double x)
#else
diff --git a/libm/s_copysign.c b/libm/s_copysign.c
index 145a26cc1..cb2e0c9ca 100644
--- a/libm/s_copysign.c
+++ b/libm/s_copysign.c
@@ -23,7 +23,6 @@ static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(copysign)
#ifdef __STDC__
double copysign(double x, double y)
#else
diff --git a/libm/s_cos.c b/libm/s_cos.c
index f05a8a53b..74420fdfc 100644
--- a/libm/s_cos.c
+++ b/libm/s_cos.c
@@ -48,7 +48,6 @@ static char rcsid[] = "$NetBSD: s_cos.c,v 1.7 1995/05/10 20:47:02 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(cos)
#ifdef __STDC__
double cos(double x)
#else
diff --git a/libm/s_erf.c b/libm/s_erf.c
index 0d24e2174..0996a396f 100644
--- a/libm/s_erf.c
+++ b/libm/s_erf.c
@@ -112,7 +112,6 @@ static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double
@@ -193,7 +192,6 @@ sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
-libm_hidden_proto(erf)
#ifdef __STDC__
double erf(double x)
#else
@@ -251,7 +249,6 @@ libm_hidden_proto(erf)
}
libm_hidden_def(erf)
-libm_hidden_proto(erfc)
#ifdef __STDC__
double erfc(double x)
#else
diff --git a/libm/s_expm1.c b/libm/s_expm1.c
index 2adeead0b..4eab15c43 100644
--- a/libm/s_expm1.c
+++ b/libm/s_expm1.c
@@ -131,7 +131,6 @@ Q3 = -7.93650757867487942473e-05, /* BF14CE19 9EAADBB7 */
Q4 = 4.00821782732936239552e-06, /* 3ED0CFCA 86E65239 */
Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
-libm_hidden_proto(expm1)
#ifdef __STDC__
double expm1(double x)
#else
diff --git a/libm/s_fabs.c b/libm/s_fabs.c
index c1538ca9e..deb91382d 100644
--- a/libm/s_fabs.c
+++ b/libm/s_fabs.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: s_fabs.c,v 1.7 1995/05/10 20:47:13 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
#ifdef __STDC__
double fabs(double x)
#else
diff --git a/libm/s_fdim.c b/libm/s_fdim.c
new file mode 100644
index 000000000..98f140d17
--- /dev/null
+++ b/libm/s_fdim.c
@@ -0,0 +1,24 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * 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"
+
+#ifdef __STDC__
+ double fdim(double x, double y)
+#else
+ double fdim(x,y)
+ double x;
+ double y;
+#endif
+{
+ int c = __fpclassify(x);
+ if (c == FP_NAN || c == FP_INFINITE)
+ return HUGE_VAL;
+
+ return x > y ? x - y : 0.0;
+}
+libm_hidden_def(fdim)
diff --git a/libm/s_finite.c b/libm/s_finite.c
index 70b9aadc4..758da9a40 100644
--- a/libm/s_finite.c
+++ b/libm/s_finite.c
@@ -10,10 +10,6 @@
* ====================================================
*/
-#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
-#endif
-
/*
* finite(x) returns 1 is x is finite, else 0;
* no branching!
@@ -22,17 +18,12 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
#include "math.h"
#include "math_private.h"
-#ifdef __STDC__
- int __finite(double x)
-#else
- int __finite(x)
- double x;
-#endif
+int __finite(double x)
{
int32_t hx;
GET_HIGH_WORD(hx,x);
return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31);
}
-libm_hidden_proto(finite)
-strong_alias(__finite,finite)
-libm_hidden_def(finite)
+libm_hidden_def(__finite)
+weak_alias(__finite,finite)
+libm_hidden_weak(finite)
diff --git a/libm/s_finitef.c b/libm/s_finitef.c
new file mode 100644
index 000000000..66eba8f98
--- /dev/null
+++ b/libm/s_finitef.c
@@ -0,0 +1,32 @@
+/* s_finitef.c -- float version of s_finite.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/*
+ * finitef(x) returns 1 is x is finite, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+libm_hidden_proto(__finitef)
+int __finitef(float x)
+{
+ int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31);
+}
+libm_hidden_def(__finitef)
+strong_alias(__finitef,finitef)
diff --git a/libm/s_floor.c b/libm/s_floor.c
index 39b24c05b..1eccfcd8c 100644
--- a/libm/s_floor.c
+++ b/libm/s_floor.c
@@ -32,7 +32,6 @@ static const double huge = 1.0e300;
static double huge = 1.0e300;
#endif
-libm_hidden_proto(floor)
#ifdef __STDC__
double floor(double x)
#else
diff --git a/libm/s_fma.c b/libm/s_fma.c
new file mode 100644
index 000000000..f9e8cf974
--- /dev/null
+++ b/libm/s_fma.c
@@ -0,0 +1,30 @@
+/* Compute x * y + z as ternary operation.
+ Copyright (C) 1997, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+libm_hidden_proto(__fma)
+double
+__fma (double x, double y, double z)
+{
+ return (x * y) + z;
+}
+libm_hidden_def(__fma)
+strong_alias (__fma, fma)
diff --git a/libm/s_fmax.c b/libm/s_fmax.c
new file mode 100644
index 000000000..e3cda763f
--- /dev/null
+++ b/libm/s_fmax.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * 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"
+
+#ifdef __STDC__
+ double fmax(double x, double y)
+#else
+ double fmax(x,y)
+ double x;
+ double y;
+#endif
+{
+ if (__fpclassify(x) == FP_NAN)
+ return x;
+ if (__fpclassify(y) == FP_NAN)
+ return y;
+
+ return x > y ? x : y;
+}
+libm_hidden_def(fmax)
diff --git a/libm/s_fmin.c b/libm/s_fmin.c
new file mode 100644
index 000000000..4d2a0cf56
--- /dev/null
+++ b/libm/s_fmin.c
@@ -0,0 +1,25 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * 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"
+
+#ifdef __STDC__
+ double fmin(double x, double y)
+#else
+ double fmin(x,y)
+ double x;
+ double y;
+#endif
+{
+ if (__fpclassify(x) == FP_NAN)
+ return x;
+ if (__fpclassify(y) == FP_NAN)
+ return y;
+
+ return x < y ? x : y;
+}
+libm_hidden_def(fmin)
diff --git a/libm/s_fpclassify.c b/libm/s_fpclassify.c
new file mode 100644
index 000000000..d2c4c8232
--- /dev/null
+++ b/libm/s_fpclassify.c
@@ -0,0 +1,43 @@
+/* Return classification value corresponding to argument.
+ Copyright (C) 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#include "math_private.h"
+
+int
+__fpclassify (double x)
+{
+ u_int32_t hx, lx;
+ int retval = FP_NORMAL;
+
+ EXTRACT_WORDS (hx, lx, x);
+ lx |= hx & 0xfffff;
+ hx &= 0x7ff00000;
+ if ((hx | lx) == 0)
+ retval = FP_ZERO;
+ else if (hx == 0)
+ retval = FP_SUBNORMAL;
+ else if (hx == 0x7ff00000)
+ retval = lx != 0 ? FP_NAN : FP_INFINITE;
+
+ return retval;
+}
+libm_hidden_def (__fpclassify)
diff --git a/libm/s_fpclassifyf.c b/libm/s_fpclassifyf.c
new file mode 100644
index 000000000..602d8b2b4
--- /dev/null
+++ b/libm/s_fpclassifyf.c
@@ -0,0 +1,42 @@
+/* Return classification value corresponding to argument.
+ Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+#include "math_private.h"
+
+libm_hidden_proto (__fpclassifyf)
+int
+__fpclassifyf (float x)
+{
+ u_int32_t wx;
+ int retval = FP_NORMAL;
+
+ GET_FLOAT_WORD (wx, x);
+ wx &= 0x7fffffff;
+ if (wx == 0)
+ retval = FP_ZERO;
+ else if (wx < 0x800000)
+ retval = FP_SUBNORMAL;
+ else if (wx >= 0x7f800000)
+ retval = wx > 0x7f800000 ? FP_NAN : FP_INFINITE;
+
+ return retval;
+}
+libm_hidden_def (__fpclassifyf)
diff --git a/libm/s_frexp.c b/libm/s_frexp.c
index ed5e31395..9ec46244a 100644
--- a/libm/s_frexp.c
+++ b/libm/s_frexp.c
@@ -34,7 +34,6 @@ static double
#endif
two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
-libm_hidden_proto(frexp)
#ifdef __STDC__
double frexp(double x, int *eptr)
#else
diff --git a/libm/s_ilogb.c b/libm/s_ilogb.c
index db7c8553e..2617757fd 100644
--- a/libm/s_ilogb.c
+++ b/libm/s_ilogb.c
@@ -23,7 +23,6 @@ static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(ilogb)
#ifdef __STDC__
int ilogb(double x)
#else
diff --git a/libm/s_isinf.c b/libm/s_isinf.c
new file mode 100644
index 000000000..99a1cdf18
--- /dev/null
+++ b/libm/s_isinf.c
@@ -0,0 +1,26 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Changed to return -1 for -Inf by Ulrich Drepper <drepper@cygnus.com>.
+ * Public domain.
+ */
+
+/*
+ * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+int
+__isinf (double x)
+{
+ int32_t hx,lx;
+ EXTRACT_WORDS(hx,lx,x);
+ lx |= (hx & 0x7fffffff) ^ 0x7ff00000;
+ lx |= -lx;
+ return ~(lx >> 31) & (hx >> 30);
+}
+libm_hidden_def(__isinf)
+weak_alias (__isinf, isinf)
+libm_hidden_weak(isinf)
diff --git a/libm/s_isinff.c b/libm/s_isinff.c
new file mode 100644
index 000000000..6827024af
--- /dev/null
+++ b/libm/s_isinff.c
@@ -0,0 +1,26 @@
+/*
+ * Written by J.T. Conklin <jtc@netbsd.org>.
+ * Public domain.
+ */
+
+/*
+ * isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+libm_hidden_proto(__isinff)
+int
+__isinff (float x)
+{
+ int32_t ix,t;
+ GET_FLOAT_WORD(ix,x);
+ t = ix & 0x7fffffff;
+ t ^= 0x7f800000;
+ t |= -t;
+ return ~(t >> 31) & (ix >> 30);
+}
+libm_hidden_def(__isinff)
+strong_alias (__isinff, isinff)
diff --git a/libm/s_isnan.c b/libm/s_isnan.c
new file mode 100644
index 000000000..671c5cb2e
--- /dev/null
+++ b/libm/s_isnan.c
@@ -0,0 +1,37 @@
+/* @(#)s_isnan.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/*
+ * isnan(x) returns 1 is x is nan, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+ int __isnan(double x)
+#else
+ int __isnan(x)
+ double x;
+#endif
+{
+ int32_t hx,lx;
+ EXTRACT_WORDS(hx,lx,x);
+ hx &= 0x7fffffff;
+ hx |= (u_int32_t)(lx|(-lx))>>31;
+ hx = 0x7ff00000 - hx;
+ return (int)(((u_int32_t)hx)>>31);
+}
+libm_hidden_def(__isnan)
+weak_alias(__isnan,isnan)
+libm_hidden_weak(isnan)
diff --git a/libm/s_isnanf.c b/libm/s_isnanf.c
new file mode 100644
index 000000000..97c354d1a
--- /dev/null
+++ b/libm/s_isnanf.c
@@ -0,0 +1,34 @@
+/* s_isnanf.c -- float version of s_isnan.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/*
+ * isnanf(x) returns 1 is x is nan, else 0;
+ * no branching!
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+libm_hidden_proto (__isnanf)
+int __isnanf(float x)
+{
+ int32_t ix;
+ GET_FLOAT_WORD(ix,x);
+ ix &= 0x7fffffff;
+ ix = 0x7f800000 - ix;
+ return (int)(((u_int32_t)(ix))>>31);
+}
+libm_hidden_def (__isnanf)
+weak_alias (__isnanf, isnanf)
diff --git a/libm/s_ldexp.c b/libm/s_ldexp.c
index ffc268b52..a065f5ada 100644
--- a/libm/s_ldexp.c
+++ b/libm/s_ldexp.c
@@ -18,10 +18,7 @@ static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $";
#include "math_private.h"
#include <errno.h>
-libm_hidden_proto(scalbn)
-libm_hidden_proto(finite)
-libm_hidden_proto(ldexp)
#ifdef __STDC__
double ldexp(double value, int exp)
#else
diff --git a/libm/s_llrint.c b/libm/s_llrint.c
index 047290ab8..96e1495c7 100644
--- a/libm/s_llrint.c
+++ b/libm/s_llrint.c
@@ -29,8 +29,6 @@ static const double two52[2] =
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
};
-libm_hidden_proto(llrint)
-
long long int
llrint (double x)
{
diff --git a/libm/s_llround.c b/libm/s_llround.c
index 1db0c2836..a549ccc8c 100644
--- a/libm/s_llround.c
+++ b/libm/s_llround.c
@@ -22,7 +22,6 @@
#include "math_private.h"
-libm_hidden_proto(llround)
long long int
llround (double x)
{
diff --git a/libm/s_log1p.c b/libm/s_log1p.c
index 7acf6289b..695019a9e 100644
--- a/libm/s_log1p.c
+++ b/libm/s_log1p.c
@@ -104,7 +104,6 @@ static const double zero = 0.0;
static double zero = 0.0;
#endif
-libm_hidden_proto(log1p)
#ifdef __STDC__
double log1p(double x)
#else
diff --git a/libm/s_logb.c b/libm/s_logb.c
index ff47ab476..173b47764 100644
--- a/libm/s_logb.c
+++ b/libm/s_logb.c
@@ -23,9 +23,7 @@ static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fabs)
-libm_hidden_proto(logb)
#ifdef __STDC__
double logb(double x)
#else
diff --git a/libm/s_lrint.c b/libm/s_lrint.c
index 61c521240..a0db12d76 100644
--- a/libm/s_lrint.c
+++ b/libm/s_lrint.c
@@ -30,7 +30,6 @@ static const double two52[2] =
};
-libm_hidden_proto(lrint)
long int
lrint (double x)
{
diff --git a/libm/s_lround.c b/libm/s_lround.c
index 604004f7f..056a48724 100644
--- a/libm/s_lround.c
+++ b/libm/s_lround.c
@@ -22,7 +22,6 @@
#include "math_private.h"
-libm_hidden_proto(lround)
long int
lround (double x)
{
diff --git a/libm/s_matherr.c b/libm/s_matherr.c
index 0c102e628..fda4e191b 100644
--- a/libm/s_matherr.c
+++ b/libm/s_matherr.c
@@ -19,7 +19,6 @@ static char rcsid[] = "$NetBSD: s_matherr.c,v 1.6 1995/05/10 20:47:53 jtc Exp $"
#ifndef _IEEE_LIBM
-libm_hidden_proto(matherr)
#ifdef __STDC__
int matherr(struct exception *x)
#else
diff --git a/libm/s_modf.c b/libm/s_modf.c
index 0cf0e8356..24369c02d 100644
--- a/libm/s_modf.c
+++ b/libm/s_modf.c
@@ -33,7 +33,6 @@ static const double one = 1.0;
static double one = 1.0;
#endif
-libm_hidden_proto(modf)
#ifdef __STDC__
double modf(double x, double *iptr)
#else
diff --git a/libm/s_nearbyint.c b/libm/s_nearbyint.c
new file mode 100644
index 000000000..52ebbdba1
--- /dev/null
+++ b/libm/s_nearbyint.c
@@ -0,0 +1,24 @@
+/*
+ * ====================================================
+ * 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"
+
+#ifdef __STDC__
+ double nearbyint(double x)
+#else
+ double nearbyint(x)
+ double x;
+#endif
+{
+ return rint(x);
+}
+libm_hidden_def(nearbyint)
diff --git a/libm/s_nextafter.c b/libm/s_nextafter.c
index bdc6f3a61..1034e3290 100644
--- a/libm/s_nextafter.c
+++ b/libm/s_nextafter.c
@@ -24,7 +24,6 @@ static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(nextafter)
#ifdef __STDC__
double nextafter(double x, double y)
#else
diff --git a/libm/s_remquo.c b/libm/s_remquo.c
new file mode 100644
index 000000000..9cbf8c4ab
--- /dev/null
+++ b/libm/s_remquo.c
@@ -0,0 +1,37 @@
+/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
+ *
+ * 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"
+
+#ifdef __STDC__
+ double remquo(double x, double y, int *quo) /* wrapper remquo */
+#else
+ double remquo(x,y,quo) /* wrapper remquo */
+ double x,y;
+ int *quo;
+#endif
+{
+ int signx, signy, signres;
+ int mswx;
+ int mswy;
+ double x_over_y;
+
+ GET_HIGH_WORD(mswx, x);
+ GET_HIGH_WORD(mswy, y);
+
+ signx = (mswx & 0x80000000) >> 31;
+ signy = (mswy & 0x80000000) >> 31;
+
+ signres = (signx ^ signy) ? -1 : 1;
+
+ x_over_y = fabs(x / y);
+
+ *quo = signres * (lrint(x_over_y) & 0x7f);
+
+ return remainder(x,y);
+}
+libm_hidden_def(remquo)
diff --git a/libm/s_rint.c b/libm/s_rint.c
index ce42aa99d..d20f1bd3f 100644
--- a/libm/s_rint.c
+++ b/libm/s_rint.c
@@ -37,7 +37,6 @@ TWO52[2]={
-4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
};
-libm_hidden_proto(rint)
#ifdef __STDC__
double rint(double x)
#else
diff --git a/libm/s_round.c b/libm/s_round.c
index 03089482b..7965c6f68 100644
--- a/libm/s_round.c
+++ b/libm/s_round.c
@@ -25,7 +25,6 @@
static const double huge = 1.0e300;
-libm_hidden_proto(round)
double
round (double x)
{
diff --git a/libm/s_scalbln.c b/libm/s_scalbln.c
new file mode 100644
index 000000000..d2ea79153
--- /dev/null
+++ b/libm/s_scalbln.c
@@ -0,0 +1,62 @@
+/* @(#)s_scalbn.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/*
+ * scalbn (double x, int n)
+ * scalbn(x,n) returns x* 2**n computed by exponent
+ * manipulation rather than by actually performing an
+ * exponentiation or a multiplication.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
+huge = 1.0e+300,
+tiny = 1.0e-300;
+
+#ifdef __STDC__
+ double scalbln (double x, long int n)
+#else
+ double scalbln (x,n)
+ double x; long int n;
+#endif
+{
+ int32_t k,hx,lx;
+ EXTRACT_WORDS(hx,lx,x);
+ k = (hx&0x7ff00000)>>20; /* extract exponent */
+ if (k==0) { /* 0 or subnormal x */
+ if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
+ x *= two54;
+ GET_HIGH_WORD(hx,x);
+ k = ((hx&0x7ff00000)>>20) - 54;
+ }
+ if (k==0x7ff) return x+x; /* NaN or Inf */
+ k = k+n;
+ if (n> 50000 || k > 0x7fe)
+ return huge*copysign(huge,x); /* overflow */
+ if (n< -50000) return tiny*copysign(tiny,x); /*underflow*/
+ if (k > 0) /* normal result */
+ {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
+ if (k <= -54)
+ return tiny*copysign(tiny,x); /*underflow*/
+ k += 54; /* subnormal result */
+ SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
+ return x*twom54;
+}
+libm_hidden_def(scalbln)
diff --git a/libm/s_scalbn.c b/libm/s_scalbn.c
index 6a7452485..2c5ada3fc 100644
--- a/libm/s_scalbn.c
+++ b/libm/s_scalbn.c
@@ -24,7 +24,6 @@ static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(copysign)
#ifdef __STDC__
static const double
@@ -36,7 +35,6 @@ twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
huge = 1.0e+300,
tiny = 1.0e-300;
-libm_hidden_proto(scalbn)
#ifdef __STDC__
double scalbn (double x, int n)
#else
diff --git a/libm/s_signbit.c b/libm/s_signbit.c
new file mode 100644
index 000000000..c9f6527af
--- /dev/null
+++ b/libm/s_signbit.c
@@ -0,0 +1,33 @@
+/* Return nonzero value if number is negative.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#include "math_private.h"
+
+int
+__signbit (double x)
+{
+ int32_t hx;
+
+ GET_HIGH_WORD (hx, x);
+ return hx & 0x80000000;
+}
+libm_hidden_def(__signbit)
diff --git a/libm/s_signbitf.c b/libm/s_signbitf.c
new file mode 100644
index 000000000..ef83d6b7f
--- /dev/null
+++ b/libm/s_signbitf.c
@@ -0,0 +1,34 @@
+/* Return nonzero value if number is negative.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <math.h>
+
+#include "math_private.h"
+
+libm_hidden_proto(__signbitf)
+int
+__signbitf (float x)
+{
+ int32_t hx;
+
+ GET_FLOAT_WORD (hx, x);
+ return hx & 0x80000000;
+}
+libm_hidden_def(__signbitf)
diff --git a/libm/s_significand.c b/libm/s_significand.c
index e47618cfc..2a7980a44 100644
--- a/libm/s_significand.c
+++ b/libm/s_significand.c
@@ -23,7 +23,6 @@ static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Ex
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(ilogb)
#ifdef __STDC__
double significand(double x)
@@ -34,3 +33,4 @@ libm_hidden_proto(ilogb)
{
return __ieee754_scalb(x,(double) -ilogb(x));
}
+libm_hidden_def(significand)
diff --git a/libm/s_sin.c b/libm/s_sin.c
index ef9a36d7d..c14709b28 100644
--- a/libm/s_sin.c
+++ b/libm/s_sin.c
@@ -48,7 +48,6 @@ static char rcsid[] = "$NetBSD: s_sin.c,v 1.7 1995/05/10 20:48:15 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sin)
#ifdef __STDC__
double sin(double x)
#else
diff --git a/libm/s_tan.c b/libm/s_tan.c
index bab343c73..26bb39f9b 100644
--- a/libm/s_tan.c
+++ b/libm/s_tan.c
@@ -47,7 +47,6 @@ static char rcsid[] = "$NetBSD: s_tan.c,v 1.7 1995/05/10 20:48:18 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(tan)
#ifdef __STDC__
double tan(double x)
#else
diff --git a/libm/s_tanh.c b/libm/s_tanh.c
index ecabbef98..edadbfe21 100644
--- a/libm/s_tanh.c
+++ b/libm/s_tanh.c
@@ -41,8 +41,6 @@ static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(expm1)
-libm_hidden_proto(fabs)
#ifdef __STDC__
static const double one=1.0, two=2.0, tiny = 1.0e-300;
@@ -50,7 +48,6 @@ static const double one=1.0, two=2.0, tiny = 1.0e-300;
static double one=1.0, two=2.0, tiny = 1.0e-300;
#endif
-libm_hidden_proto(tanh)
#ifdef __STDC__
double tanh(double x)
#else
diff --git a/libm/s_trunc.c b/libm/s_trunc.c
index 8a4f5ae05..6e5678be1 100644
--- a/libm/s_trunc.c
+++ b/libm/s_trunc.c
@@ -23,7 +23,6 @@
#include "math_private.h"
-libm_hidden_proto(trunc)
double
trunc (double x)
{
diff --git a/libm/w_acos.c b/libm/w_acos.c
index ea00cf010..f93f6bb4d 100644
--- a/libm/w_acos.c
+++ b/libm/w_acos.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_acos.c,v 1.6 1995/05/10 20:48:26 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(acos)
#ifdef __STDC__
double acos(double x) /* wrapper acos */
#else
diff --git a/libm/w_acosh.c b/libm/w_acosh.c
index e0efb8a63..3268218bf 100644
--- a/libm/w_acosh.c
+++ b/libm/w_acosh.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_acosh.c,v 1.6 1995/05/10 20:48:31 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(acosh)
#ifdef __STDC__
double acosh(double x) /* wrapper acosh */
#else
diff --git a/libm/w_asin.c b/libm/w_asin.c
index ad156ef05..a028a1d34 100644
--- a/libm/w_asin.c
+++ b/libm/w_asin.c
@@ -23,7 +23,6 @@ static char rcsid[] = "$NetBSD: w_asin.c,v 1.6 1995/05/10 20:48:35 jtc Exp $";
#include "math_private.h"
-libm_hidden_proto(asin)
#ifdef __STDC__
double asin(double x) /* wrapper asin */
#else
diff --git a/libm/w_atan2.c b/libm/w_atan2.c
index c2da4681c..6a13d2b3c 100644
--- a/libm/w_atan2.c
+++ b/libm/w_atan2.c
@@ -20,7 +20,6 @@ static char rcsid[] = "$NetBSD: w_atan2.c,v 1.6 1995/05/10 20:48:39 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(atan2)
#ifdef __STDC__
double atan2(double y, double x) /* wrapper atan2 */
#else
diff --git a/libm/w_atanh.c b/libm/w_atanh.c
index 18d0a4a80..9839313ad 100644
--- a/libm/w_atanh.c
+++ b/libm/w_atanh.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_atanh.c,v 1.6 1995/05/10 20:48:43 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(atanh)
#ifdef __STDC__
double atanh(double x) /* wrapper atanh */
#else
diff --git a/libm/w_cabs.c b/libm/w_cabs.c
index 485e120db..d2a54cd9f 100644
--- a/libm/w_cabs.c
+++ b/libm/w_cabs.c
@@ -8,9 +8,9 @@
#include <complex.h>
#include <math.h>
-libm_hidden_proto(hypot)
double cabs(double _Complex z)
{
return hypot(__real__ z, __imag__ z);
}
+libm_hidden_def(cabs)
diff --git a/libm/w_cosh.c b/libm/w_cosh.c
index c785af4b5..0766e373d 100644
--- a/libm/w_cosh.c
+++ b/libm/w_cosh.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_cosh.c,v 1.6 1995/05/10 20:48:47 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(cosh)
#ifdef __STDC__
double cosh(double x) /* wrapper cosh */
#else
diff --git a/libm/w_drem.c b/libm/w_drem.c
index 22e281761..6b3dd3937 100644
--- a/libm/w_drem.c
+++ b/libm/w_drem.c
@@ -7,9 +7,9 @@
#include <math.h>
-libm_hidden_proto(remainder)
double drem(double x, double y)
{
return remainder(x, y);
}
+libm_hidden_def(drem)
diff --git a/libm/w_exp.c b/libm/w_exp.c
index b9b7ccc26..e11222499 100644
--- a/libm/w_exp.c
+++ b/libm/w_exp.c
@@ -29,7 +29,6 @@ static double
o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
-libm_hidden_proto(exp)
#ifdef __STDC__
double exp(double x) /* wrapper exp */
#else
diff --git a/libm/w_exp2.c b/libm/w_exp2.c
new file mode 100644
index 000000000..604d6ecff
--- /dev/null
+++ b/libm/w_exp2.c
@@ -0,0 +1,26 @@
+
+/* @(#)w_exp2.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * 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"
+
+#ifdef __STDC__
+ double exp2(double x)
+#else
+ double exp2(x)
+ double x;
+#endif
+{
+ return pow(2.0, x);
+}
+libm_hidden_def(exp2)
diff --git a/libm/w_fmod.c b/libm/w_fmod.c
index eed38372b..ce7d78469 100644
--- a/libm/w_fmod.c
+++ b/libm/w_fmod.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_fmod.c,v 1.6 1995/05/10 20:48:55 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(fmod)
#ifdef __STDC__
double fmod(double x, double y) /* wrapper fmod */
#else
diff --git a/libm/w_gamma.c b/libm/w_gamma.c
index 182dece3e..0b286e190 100644
--- a/libm/w_gamma.c
+++ b/libm/w_gamma.c
@@ -24,7 +24,6 @@ static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $";
#include "math_private.h"
libm_hidden_proto(signgam)
-
#ifdef __STDC__
double gamma(double x)
#else
@@ -47,3 +46,4 @@ libm_hidden_proto(signgam)
return y;
#endif
}
+libm_hidden_def(gamma)
diff --git a/libm/w_gamma_r.c b/libm/w_gamma_r.c
index 321e86480..b9f14fb48 100644
--- a/libm/w_gamma_r.c
+++ b/libm/w_gamma_r.c
@@ -23,6 +23,7 @@ static char rcsid[] = "$NetBSD: w_gamma_r.c,v 1.7 1995/11/20 22:06:45 jtc Exp $"
double gamma_r(double x, int *signgamp);
+libm_hidden_proto(gamma_r)
#ifdef __STDC__
double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */
#else
@@ -45,3 +46,4 @@ double gamma_r(double x, int *signgamp);
return y;
#endif
}
+libm_hidden_def(gamma_r)
diff --git a/libm/w_hypot.c b/libm/w_hypot.c
index e4b299d5f..9ed348e3e 100644
--- a/libm/w_hypot.c
+++ b/libm/w_hypot.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_hypot.c,v 1.6 1995/05/10 20:49:07 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(hypot)
#ifdef __STDC__
double hypot(double x, double y)/* wrapper hypot */
#else
diff --git a/libm/w_j0.c b/libm/w_j0.c
index 61f4f20fc..27290c858 100644
--- a/libm/w_j0.c
+++ b/libm/w_j0.c
@@ -39,6 +39,7 @@ static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(j0)
#ifdef __STDC__
double y0(double x) /* wrapper y0 */
@@ -67,3 +68,4 @@ static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(y0)
diff --git a/libm/w_j1.c b/libm/w_j1.c
index 389dc156c..9ce34cca3 100644
--- a/libm/w_j1.c
+++ b/libm/w_j1.c
@@ -40,6 +40,7 @@ static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(j1)
#ifdef __STDC__
double y1(double x) /* wrapper y1 */
@@ -68,3 +69,4 @@ static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(y1)
diff --git a/libm/w_jn.c b/libm/w_jn.c
index 173f6aa9e..2ba74d812 100644
--- a/libm/w_jn.c
+++ b/libm/w_jn.c
@@ -62,6 +62,7 @@ static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(jn)
#ifdef __STDC__
double yn(int n, double x) /* wrapper yn */
@@ -90,3 +91,4 @@ static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(yn)
diff --git a/libm/w_lgamma.c b/libm/w_lgamma.c
index de0394b5e..24b8b02b4 100644
--- a/libm/w_lgamma.c
+++ b/libm/w_lgamma.c
@@ -24,8 +24,6 @@ static char rcsid[] = "$NetBSD: w_lgamma.c,v 1.6 1995/05/10 20:49:24 jtc Exp $";
#include "math_private.h"
libm_hidden_proto(signgam)
-
-libm_hidden_proto(lgamma)
#ifdef __STDC__
double lgamma(double x)
#else
diff --git a/libm/w_lgamma_r.c b/libm/w_lgamma_r.c
index 6ca56d6da..20b002608 100644
--- a/libm/w_lgamma_r.c
+++ b/libm/w_lgamma_r.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_lgamma_r.c,v 1.6 1995/05/10 20:49:27 jtc Exp $
#include "math.h"
#include "math_private.h"
-
#ifdef __STDC__
double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */
#else
@@ -44,3 +43,4 @@ static char rcsid[] = "$NetBSD: w_lgamma_r.c,v 1.6 1995/05/10 20:49:27 jtc Exp $
return y;
#endif
}
+libm_hidden_def(lgamma_r)
diff --git a/libm/w_log.c b/libm/w_log.c
index 12c8282d5..22cdda148 100644
--- a/libm/w_log.c
+++ b/libm/w_log.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_log.c,v 1.6 1995/05/10 20:49:33 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log)
#ifdef __STDC__
double log(double x) /* wrapper log */
#else
diff --git a/libm/w_log10.c b/libm/w_log10.c
index cf52f6e65..efb523ecf 100644
--- a/libm/w_log10.c
+++ b/libm/w_log10.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_log10.c,v 1.6 1995/05/10 20:49:35 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(log10)
#ifdef __STDC__
double log10(double x) /* wrapper log10 */
#else
diff --git a/libm/w_log2.c b/libm/w_log2.c
new file mode 100644
index 000000000..ec274f761
--- /dev/null
+++ b/libm/w_log2.c
@@ -0,0 +1,14 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2008 by Bernhard Reutner-Fischer <uclibc@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <math.h>
+#include "math_private.h"
+
+double log2 (double d)
+{
+ return __ieee754_log2 (d);
+}
+libm_hidden_def(log2)
diff --git a/libm/w_pow.c b/libm/w_pow.c
index 89cd08f73..94d30bcec 100644
--- a/libm/w_pow.c
+++ b/libm/w_pow.c
@@ -19,7 +19,6 @@
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(pow)
#ifdef __STDC__
double pow(double x, double y) /* wrapper pow */
#else
diff --git a/libm/w_remainder.c b/libm/w_remainder.c
index be3dd02c9..a30ff880a 100644
--- a/libm/w_remainder.c
+++ b/libm/w_remainder.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_remainder.c,v 1.6 1995/05/10 20:49:44 jtc Exp
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(remainder)
#ifdef __STDC__
double remainder(double x, double y) /* wrapper remainder */
#else
diff --git a/libm/w_scalb.c b/libm/w_scalb.c
index a5f88de39..a770877ea 100644
--- a/libm/w_scalb.c
+++ b/libm/w_scalb.c
@@ -58,3 +58,4 @@ static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $";
return z;
#endif
}
+libm_hidden_def(scalb)
diff --git a/libm/w_sinh.c b/libm/w_sinh.c
index bed9bb3f9..dabfdd918 100644
--- a/libm/w_sinh.c
+++ b/libm/w_sinh.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_sinh.c,v 1.6 1995/05/10 20:49:51 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sinh)
#ifdef __STDC__
double sinh(double x) /* wrapper sinh */
#else
diff --git a/libm/w_sqrt.c b/libm/w_sqrt.c
index 0a37249b1..d695b1d8d 100644
--- a/libm/w_sqrt.c
+++ b/libm/w_sqrt.c
@@ -21,7 +21,6 @@ static char rcsid[] = "$NetBSD: w_sqrt.c,v 1.6 1995/05/10 20:49:55 jtc Exp $";
#include "math.h"
#include "math_private.h"
-libm_hidden_proto(sqrt)
#ifdef __STDC__
double sqrt(double x) /* wrapper sqrt */
#else
diff --git a/libm/w_tgamma.c b/libm/w_tgamma.c
new file mode 100644
index 000000000..0449e16d8
--- /dev/null
+++ b/libm/w_tgamma.c
@@ -0,0 +1,47 @@
+/* @(#)w_gamma.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * 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.
+ * ====================================================
+ */
+
+/* double gamma(double x)
+ * Return the logarithm of the Gamma function of x or the Gamma function of x,
+ * depending on the library mode.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+libm_hidden_proto(signgam)
+#ifdef __STDC__
+ double tgamma(double x)
+#else
+ double tgamma(x)
+ double x;
+#endif
+{
+ double y;
+ int local_signgam;
+ y = __ieee754_gamma_r(x,&local_signgam);
+ if (local_signgam < 0) y = -y;
+#ifdef _IEEE_LIBM
+ return y;
+#else
+ if(_LIB_VERSION == _IEEE_) return y;
+
+ if(!finite(y)&&finite(x)) {
+ if(floor(x)==x&&x<=0.0)
+ return __kernel_standard(x,x,41); /* tgamma pole */
+ else
+ return __kernel_standard(x,x,40); /* tgamma overflow */
+ }
+ return y;
+#endif
+}
+libm_hidden_def(tgamma)