diff options
Diffstat (limited to 'libm')
181 files changed, 3027 insertions, 5622 deletions
diff --git a/libm/Makefile.in b/libm/Makefile.in index f3768d38e..835e7bf3f 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. # @@ -20,9 +20,11 @@ # by Erik Andersen <andersen@codepoet.org> # +subdirs += libm libm/$(TARGET_ARCH) + CFLAGS-libm := -DNOT_IN_libc -DIS_IN_libm $(SSP_ALL_CFLAGS) -CFLAGS-libm += -D_IEEE_LIBM +LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libm.so := -Wl,--dsbt-index=5 LDFLAGS-libm.so := $(LDFLAGS) LIBS-libm.so := $(LIBS) @@ -32,86 +34,222 @@ libm_FULL_NAME := libm-$(VERSION).so libm_DIR:=$(top_srcdir)libm 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) -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 -libm_ARCH_fpu_DIR:=$(libm_ARCH_DIR)/fpu -libm_ARCH_fpu_OUT:=$(libm_ARCH_OUT)/fpu +ifneq ($(TARGET_SUBARCH),) +libm_SUBARCH_DIR:=$(libm_DIR)/$(TARGET_ARCH)/$(TARGET_SUBARCH) +libm_SUBARCH_OUT:=$(libm_OUT)/$(TARGET_ARCH)/$(TARGET_SUBARCH) +endif ifeq ($(UCLIBC_HAS_FPU),y) ifeq ($(DO_C99_MATH),y) -include $(libm_ARCH_DIR)/Makefile.arch +-include $(libm_SUBARCH_DIR)/Makefile.arch 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_exp.c e_exp10.c e_fmod.c e_hypot.c \ + e_lgamma_r.c e_log.c e_log2.c e_log10.c \ e_pow.c e_remainder.c e_rem_pio2.c e_scalb.c e_sinh.c \ - e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_standard.c k_tan.c \ + e_sqrt.c k_cos.c k_rem_pio2.c k_sin.c k_tan.c \ s_asinh.c s_atan.c s_cbrt.c s_ceil.c s_copysign.c s_cos.c \ s_erf.c s_expm1.c s_fabs.c s_finite.c s_floor.c s_frexp.c \ s_ilogb.c s_ldexp.c s_lib_version.c s_lrint.c s_lround.c s_llround.c \ - s_log1p.c s_logb.c s_matherr.c s_modf.c s_nextafter.c s_round.c \ + s_log1p.c s_logb.c s_modf.c s_nextafter.c \ + s_nextafterf.c s_round.c \ s_rint.c s_scalbn.c s_signgam.c s_significand.c s_sin.c s_tan.c \ - s_tanh.c s_trunc.c 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_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 + s_tanh.c s_trunc.c \ + w_cabs.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_remquo.c w_exp2.c \ + cexp.c sincos.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 \ - expm1f.o fabsf.o fdimf.o floorf.o fmaf.o fmaxf.o fminf.o fmodf.o \ - frexpf.o hypotf.o ilogbf.o ldexpf.o lgammaf.o llroundf.o log10f.o \ - log1pf.o log2f.o logbf.o logf.o lrintf.o lroundf.o modff.o nearbyintf.o \ - 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 + acosf.o \ + acoshf.o \ + asinf.o \ + asinhf.o \ + atan2f.o \ + atanf.o \ + atanhf.o \ + cargf.o \ + cbrtf.o \ + ceilf.o \ + copysignf.o \ + cosf.o \ + coshf.o \ + erfcf.o \ + erff.o \ + exp2f.o \ + expf.o \ + expm1f.o \ + fabsf.o \ + fdimf.o \ + floorf.o \ + fmaf.o \ + fmaxf.o \ + fminf.o \ + fmodf.o \ + frexpf.o \ + gammaf.o \ + hypotf.o \ + ilogbf.o \ + ldexpf.o \ + lgammaf.o \ + llrintf.o \ + llroundf.o \ + log10f.o \ + log1pf.o \ + log2f.o \ + logbf.o \ + logf.o \ + lrintf.o \ + lroundf.o \ + modff.o \ + nearbyintf.o \ + nexttowardf.o \ + powf.o \ + remainderf.o \ + remquof.o \ + rintf.o \ + roundf.o \ + scalblnf.o \ + scalbnf.o \ + significandf.o \ + sinf.o \ + sinhf.o \ + sqrtf.o \ + tanf.o \ + tanhf.o \ + tgammaf.o \ + truncf.o \ + +ifeq ($(UCLIBC_SUSV3_LEGACY),y) +FL_MOBJ += scalbf.o +endif + +# Do not (yet?) implement the float variants of bessel functions +ifeq (not-yet-implemented-$(DO_XSI_MATH),y) +FL_MOBJ += \ + j0f.o \ + j1f.o \ + jnf.o \ + y0f.o \ + y1f.o \ + ynf.o +endif + +LD_MOBJ := \ + __finitel.o \ + __fpclassifyl.o \ + __isinfl.o \ + __isnanl.o \ + __signbitl.o \ + acoshl.o \ + acosl.o \ + asinhl.o \ + asinl.o \ + atan2l.o \ + atanhl.o \ + atanl.o \ + cargl.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 \ + log2l.o \ + logbl.o \ + logl.o \ + lrintl.o \ + lroundl.o \ + modfl.o \ + nearbyintl.o \ + nextafterl.o \ + nexttowardl.o \ + powl.o \ + remainderl.o \ + remquol.o \ + rintl.o \ + roundl.o \ + scalblnl.o \ + scalbnl.o \ + significandl.o \ + sinhl.o \ + sinl.o \ + sqrtl.o \ + tanhl.o \ + tanl.o \ + tgammal.o \ + truncl.o \ + +# Do not (yet?) implement the long double variants of bessel functions +ifeq (not-yet-implemented-$(DO_XSI_MATH),y) +LD_MOBJ += \ + j0l.o \ + j1l.o \ + jnl.o \ + y0l.o \ + y1l.o \ + ynl.o +endif + else + # This list of math functions was taken from POSIX/IEEE 1003.1b-1993 libm_CSRC := \ - w_acos.c w_asin.c s_atan.c w_atan2.c s_ceil.c s_cos.c \ - w_cosh.c w_exp.c s_fabs.c s_floor.c w_fmod.c s_frexp.c \ - s_ldexp.c w_log.c w_log10.c s_modf.c w_pow.c s_sin.c \ - w_sinh.c w_sqrt.c s_tan.c s_tanh.c \ + s_atan.c s_ceil.c s_cos.c \ + s_fabs.c s_floor.c s_frexp.c \ + s_ldexp.c s_modf.c s_sin.c \ + s_tan.c s_tanh.c \ s_expm1.c s_scalbn.c s_copysign.c e_acos.c e_asin.c e_atan2.c \ k_cos.c e_cosh.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c \ k_sin.c e_sinh.c e_sqrt.c k_tan.c e_rem_pio2.c k_rem_pio2.c \ - s_finite.c + s_finite.c e_exp10.c # We'll add sqrtf to avoid problems with libstdc++ FL_MOBJ := sqrtf.o endif +ifeq ($(DO_XSI_MATH),y) +libm_CSRC += e_j0.c e_j1.c e_jn.c +endif + # assume that arch specific versions are provided as single sources/objects ifeq ($(UCLIBC_HAS_FPU),y) ifeq ($(DO_C99_MATH),y) ifneq ($(strip $(libm_ARCH_OBJS)),) -ifeq ($(TARGET_ARCH),powerpc) -ifeq ($(CONFIG_E500),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 # remove generic sources, if arch specific version is present ifneq ($(strip $(libm_ARCH_SRC)),) @@ -120,9 +258,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 @@ -130,14 +270,22 @@ endif libm_SRC := $(patsubst %.c,$(libm_DIR)/%.c,$(libm_CSRC)) libm_OBJ := $(patsubst $(libm_DIR)/%.c,$(libm_OUT)/%.o,$(libm_SRC)) -libm_MSRC := $(libm_DIR)/$(FL_MSRC) -libm_MOBJ := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ)) +ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y) +libm_MSRC_LD := $(libm_DIR)/$(LD_MSRC) +libm_MOBJ_LD := $(patsubst %.o,$(libm_OUT)/%.o,$(LD_MOBJ)) +endif +libm_MSRC_FL := $(libm_DIR)/$(FL_MSRC) +libm_MOBJ_FL := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ)) + ifneq ($(DOMULTI),n) -CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ)))) +CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ_FL)))) +ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y) +CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ_LD)))) +endif endif -libm_OBJS := $(libm_OBJ) $(libm_MOBJ) +libm_OBJS := $(libm_OBJ) $(libm_MOBJ_FL) $(libm_MOBJ_LD) ifeq ($(DOPIC),y) libm-a-y += $(libm_OBJS:.o=.os) @@ -148,7 +296,7 @@ libm-so-y += $(libm_OBJS:.o=.os) lib-a-$(UCLIBC_HAS_FLOATS) += $(top_builddir)lib/libm.a lib-so-$(UCLIBC_HAS_FLOATS) += $(top_builddir)lib/libm.so -objclean-y += libm_clean +objclean-y += CLEAN_libm ifeq ($(DOMULTI),n) ifeq ($(DOPIC),y) @@ -156,17 +304,17 @@ $(top_builddir)lib/libm.so: $(top_builddir)lib/libm.a $(libc.depend) else $(top_builddir)lib/libm.so: $(libm_OUT)/libm_so.a $(libc.depend) endif - $(call link.so,$(libm_FULL_NAME),$(MAJOR_VERSION)) + $(call link.so,$(libm_FULL_NAME),$(ABI_VERSION)) else $(top_builddir)lib/libm.so: $(libm_OUT)/libm.oS | $(libc.depend) - $(call linkm.so,$(libm_FULL_NAME),$(MAJOR_VERSION)) + $(call linkm.so,$(libm_FULL_NAME),$(ABI_VERSION)) endif $(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_FL) $(libm_MSRC_LD) $(libm_ARCH_SRC) $(Q)$(RM) $@ $(compile-m) @@ -175,11 +323,24 @@ $(top_builddir)lib/libm.a: $(libm-a-y) $(Q)$(RM) $@ $(do_ar) -$(libm_MOBJ): $(libm_MSRC) +$(libm_MOBJ_FL): $(libm_MSRC_FL) + $(compile.m) + +$(libm_MOBJ_LD): $(libm_MSRC_LD) $(compile.m) -$(libm_MOBJ:.o=.os): $(libm_MSRC) +$(libm_MOBJ_FL:.o=.os): $(libm_MSRC_FL) $(compile.m) -libm_clean: - $(RM) $(libm_OUT)/{,*/,*/*/}*.{o,os,oS,a} +$(libm_MOBJ_LD:.o=.os): $(libm_MSRC_LD) + $(compile.m) + +# spare us from adding a gazillion dummy two-liner files +$(libm_MOBJ_FL:.o=.i): $(libm_MSRC_FL) + $(compile.mi) + +$(libm_MOBJ_LD:.o=.i): $(libm_MSRC_LD) + $(compile.mi) + +CLEAN_libm: + $(do_rm) $(addprefix $(libm_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*.,$(d)$(e)))) diff --git a/libm/README b/libm/README index 2c69a54af..306f03e40 100644 --- a/libm/README +++ b/libm/README @@ -13,4 +13,3 @@ is as follows: It has been ported to work with uClibc and generally behave by Erik Andersen <andersen@codepoet.org> 22 May, 2001 - diff --git a/libm/carg.c b/libm/carg.c index 7641d5dfe..305320d9c 100644 --- a/libm/carg.c +++ b/libm/carg.c @@ -14,20 +14,15 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #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/cexp.c b/libm/cexp.c new file mode 100644 index 000000000..87512b7c5 --- /dev/null +++ b/libm/cexp.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <features.h> +#include <math.h> +#include <complex.h> + +__complex__ double cexp(__complex__ double z) +{ + __complex__ double ret; + double r_exponent = exp(__real__ z); + + __real__ ret = r_exponent * cos(__imag__ z); + __imag__ ret = r_exponent * sin(__imag__ z); + + return ret; +} +libm_hidden_def(cexp) + +libm_hidden_proto(cexpf) +__complex__ float cexpf(__complex__ float z) +{ + __complex__ float ret; + double r_exponent = exp(__real__ z); + + __real__ ret = r_exponent * cosf(__imag__ z); + __imag__ ret = r_exponent * sinf(__imag__ z); + + return ret; +} +libm_hidden_def(cexpf) + +#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH +libm_hidden_proto(cexpl) +__complex__ long double cexpl(__complex__ long double z) +{ + __complex__ long double ret; + long double r_exponent = expl(__real__ z); + + __real__ ret = r_exponent * cosl(__imag__ z); + __imag__ ret = r_exponent * sinl(__imag__ z); + + return ret; +} +libm_hidden_def(cexpl) +#endif diff --git a/libm/e_acos.c b/libm/e_acos.c index 265619325..acf10130e 100644 --- a/libm/e_acos.c +++ b/libm/e_acos.c @@ -1,4 +1,3 @@ -/* @(#)e_acos.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_acos.c,v 1.9 1995/05/12 04:57:13 jtc Exp $"; -#endif - /* __ieee754_acos(x) * Method : * acos(x) = pi/2 - asin(x) @@ -41,11 +36,7 @@ static char rcsid[] = "$NetBSD: e_acos.c,v 1.9 1995/05/12 04:57:13 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ @@ -61,12 +52,7 @@ qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ -#ifdef __STDC__ - double attribute_hidden __ieee754_acos(double x) -#else - double attribute_hidden __ieee754_acos(x) - double x; -#endif +double __ieee754_acos(double x) { double z,p,q,r,w,s,c,df; int32_t hx,ix; @@ -109,3 +95,6 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ return 2.0*(df+w); } } + +strong_alias(__ieee754_acos, acos) +libm_hidden_def(acos) diff --git a/libm/e_acosh.c b/libm/e_acosh.c index d5e510eff..17e29c824 100644 --- a/libm/e_acosh.c +++ b/libm/e_acosh.c @@ -1,4 +1,3 @@ -/* @(#)e_acosh.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_acosh.c,v 1.9 1995/05/12 04:57:18 jtc Exp $"; -#endif - /* __ieee754_acosh(x) * Method : * Based on @@ -31,23 +26,11 @@ 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 -#else -static double -#endif one = 1.0, ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ -#ifdef __STDC__ - double attribute_hidden __ieee754_acosh(double x) -#else - double attribute_hidden __ieee754_acosh(x) - double x; -#endif +double __ieee754_acosh(double x) { double t; int32_t hx; @@ -70,3 +53,6 @@ ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ return log1p(t+sqrt(2.0*t+t*t)); } } + +strong_alias(__ieee754_acosh, acosh) +libm_hidden_def(acosh) diff --git a/libm/e_asin.c b/libm/e_asin.c index 8a639771b..1441acb3d 100644 --- a/libm/e_asin.c +++ b/libm/e_asin.c @@ -1,4 +1,3 @@ -/* @(#)e_asin.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_asin.c,v 1.9 1995/05/12 04:57:22 jtc Exp $"; -#endif - /* __ieee754_asin(x) * Method : * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... @@ -44,17 +39,10 @@ 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 -#else -static double -#endif one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ huge = 1.000e+300, pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ @@ -72,12 +60,7 @@ qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */ qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ -#ifdef __STDC__ - double attribute_hidden __ieee754_asin(double x) -#else - double attribute_hidden __ieee754_asin(x) - double x; -#endif +double __ieee754_asin(double x) { double t=0.0,w,p,q,c,r,s; int32_t hx,ix; @@ -121,3 +104,6 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */ } if(hx>0) return t; else return -t; } + +strong_alias(__ieee754_asin, asin) +libm_hidden_def(asin) diff --git a/libm/e_atan2.c b/libm/e_atan2.c index 7bb38da81..ef379aa7a 100644 --- a/libm/e_atan2.c +++ b/libm/e_atan2.c @@ -1,4 +1,3 @@ -/* @(#)e_atan2.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_atan2.c,v 1.8 1995/05/10 20:44:51 jtc Exp $"; -#endif - /* __ieee754_atan2(y,x) * Method : * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). @@ -44,14 +39,7 @@ 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 -#else -static double -#endif tiny = 1.0e-300, zero = 0.0, pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */ @@ -59,12 +47,7 @@ pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */ pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ -#ifdef __STDC__ - double attribute_hidden __ieee754_atan2(double y, double x) -#else - double attribute_hidden __ieee754_atan2(y,x) - double y,x; -#endif +double __ieee754_atan2(double y, double x) { double z; int32_t k,m,hx,hy,ix,iy; @@ -131,3 +114,6 @@ pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */ return (z-pi_lo)-pi;/* atan(-,-) */ } } + +strong_alias(__ieee754_atan2, atan2) +libm_hidden_def(atan2) diff --git a/libm/e_atanh.c b/libm/e_atanh.c index cfbe02bed..fb36a1af1 100644 --- a/libm/e_atanh.c +++ b/libm/e_atanh.c @@ -1,4 +1,3 @@ -/* @(#)e_atanh.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_atanh.c,v 1.8 1995/05/10 20:44:55 jtc Exp $"; -#endif - /* __ieee754_atanh(x) * Method : * 1.Reduced x to positive by atanh(-x) = -atanh(x) @@ -35,26 +30,11 @@ 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; -#else -static double one = 1.0, huge = 1e300; -#endif -#ifdef __STDC__ static const double zero = 0.0; -#else -static double zero = 0.0; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_atanh(double x) -#else - double attribute_hidden __ieee754_atanh(x) - double x; -#endif +double __ieee754_atanh(double x) { double t; int32_t hx,ix; @@ -74,3 +54,6 @@ static double zero = 0.0; t = 0.5*log1p((x+x)/(one-x)); if(hx>=0) return t; else return -t; } + +strong_alias(__ieee754_atanh, atanh) +libm_hidden_def(atanh) diff --git a/libm/e_cosh.c b/libm/e_cosh.c index aa25eefcb..a8e34aa45 100644 --- a/libm/e_cosh.c +++ b/libm/e_cosh.c @@ -1,4 +1,3 @@ -/* @(#)e_cosh.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_cosh.c,v 1.7 1995/05/10 20:44:58 jtc Exp $"; -#endif - /* __ieee754_cosh(x) * Method : * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2 @@ -38,21 +33,9 @@ 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; -#else -static double one = 1.0, half=0.5, huge = 1.0e300; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_cosh(double x) -#else - double attribute_hidden __ieee754_cosh(x) - double x; -#endif +double __ieee754_cosh(double x) { double t,w; int32_t ix; @@ -94,3 +77,6 @@ static double one = 1.0, half=0.5, huge = 1.0e300; /* |x| > overflowthresold, cosh(x) overflow */ return huge*huge; } + +strong_alias(__ieee754_cosh, cosh) +libm_hidden_def(cosh) diff --git a/libm/e_exp.c b/libm/e_exp.c index f9c5371d9..ce958d111 100644 --- a/libm/e_exp.c +++ b/libm/e_exp.c @@ -1,4 +1,3 @@ -/* @(#)e_exp.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_exp.c,v 1.8 1995/05/10 20:45:03 jtc Exp $"; -#endif - /* __ieee754_exp(x) * Returns the exponential of x. * @@ -80,11 +75,7 @@ static char rcsid[] = "$NetBSD: e_exp.c,v 1.8 1995/05/10 20:45:03 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif one = 1.0, halF[2] = {0.5,-0.5,}, huge = 1.0e+300, @@ -102,13 +93,7 @@ P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ - -#ifdef __STDC__ - double attribute_hidden __ieee754_exp(double x) /* default IEEE double exp */ -#else - double attribute_hidden __ieee754_exp(x) /* default IEEE double exp */ - double x; -#endif +double __ieee754_exp(double x) /* default IEEE double exp */ { double y; double hi = 0.0; @@ -170,3 +155,6 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ return y*twom1000; } } + +strong_alias(__ieee754_exp, exp) +libm_hidden_def(exp) diff --git a/libm/e_exp10.c b/libm/e_exp10.c new file mode 100644 index 000000000..f0ee87809 --- /dev/null +++ b/libm/e_exp10.c @@ -0,0 +1,33 @@ +/* Copyright (C) 1998-2015 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. + + 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, see + <http://www.gnu.org/licenses/>. */ + +#include "math.h" +#include "math_private.h" +#include <float.h> + +double __ieee754_exp10 (double arg) +{ + if (isfinite (arg) && arg < DBL_MIN_10_EXP - DBL_DIG - 10) + return DBL_MIN * DBL_MIN; + else + /* This is a very stupid and inprecise implementation. It'll get + replaced sometime (soon?). */ + return __ieee754_exp (M_LN10 * arg); +} +strong_alias(__ieee754_exp10, exp10) +libm_hidden_def(exp10) diff --git a/libm/e_fmod.c b/libm/e_fmod.c index 1e8487cf0..7857854f8 100644 --- a/libm/e_fmod.c +++ b/libm/e_fmod.c @@ -1,4 +1,3 @@ -/* @(#)e_fmod.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_fmod.c,v 1.8 1995/05/10 20:45:07 jtc Exp $"; -#endif - /* * __ieee754_fmod(x,y) * Return x mod y in exact arithmetic @@ -23,18 +18,9 @@ static char rcsid[] = "$NetBSD: e_fmod.c,v 1.8 1995/05/10 20:45:07 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double one = 1.0, Zero[] = {0.0, -0.0,}; -#else -static double one = 1.0, Zero[] = {0.0, -0.0,}; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_fmod(double x, double y) -#else - double attribute_hidden __ieee754_fmod(x,y) - double x,y ; -#endif +double __ieee754_fmod(double x, double y) { int32_t n,hx,hy,hz,ix,iy,sx,i; u_int32_t lx,ly,lz; @@ -138,3 +124,6 @@ static double one = 1.0, Zero[] = {0.0, -0.0,}; } return x; /* exact output */ } + +strong_alias(__ieee754_fmod, fmod) +libm_hidden_def(fmod) diff --git a/libm/e_gamma_r.c b/libm/e_gamma_r.c deleted file mode 100644 index 36b0d45d6..000000000 --- a/libm/e_gamma_r.c +++ /dev/null @@ -1,33 +0,0 @@ - -/* @(#)e_gamma_r.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. - * ==================================================== - * - */ - -/* __ieee754_gamma_r(x, signgamp) - * Reentrant version of the logarithm of the Gamma function - * with user provide pointer for the sign of Gamma(x). - * - * Method: See __ieee754_lgamma_r - */ - -#include "math_private.h" - -#ifdef __STDC__ - //__private_extern__ - double attribute_hidden __ieee754_gamma_r(double x, int *signgamp) -#else - double attribute_hidden __ieee754_gamma_r(x,signgamp) - double x; int *signgamp; -#endif -{ - return __ieee754_lgamma_r(x,signgamp); -} diff --git a/libm/e_hypot.c b/libm/e_hypot.c index 62acc8d03..cd63b73ae 100644 --- a/libm/e_hypot.c +++ b/libm/e_hypot.c @@ -1,4 +1,3 @@ -/* @(#)e_hypot.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $"; -#endif - /* __ieee754_hypot(x,y) * * Method : @@ -49,14 +44,9 @@ static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ - double attribute_hidden __ieee754_hypot(double x, double y) -#else - double attribute_hidden __ieee754_hypot(x,y) - double x, y; -#endif +double __ieee754_hypot(double x, double y) { - double a=x,b=y,t1,t2,y1,y2,w; + double a=x,b=y,t1,t2,_y1,y2,w; int32_t j,k,ha,hb; GET_HIGH_WORD(ha,x); @@ -110,13 +100,13 @@ static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $"; w = __ieee754_sqrt(t1*t1-(b*(-b)-t2*(a+t1))); } else { a = a+a; - y1 = 0; - SET_HIGH_WORD(y1,hb); - y2 = b - y1; + _y1 = 0; + SET_HIGH_WORD(_y1,hb); + y2 = b - _y1; t1 = 0; SET_HIGH_WORD(t1,ha+0x00100000); t2 = a - t1; - w = __ieee754_sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); + w = __ieee754_sqrt(t1*_y1-(w*(-w)-(t1*y2+t2*b))); } if(k!=0) { u_int32_t high; @@ -126,3 +116,6 @@ static char rcsid[] = "$NetBSD: e_hypot.c,v 1.9 1995/05/12 04:57:27 jtc Exp $"; return t1*w; } else return w; } + +strong_alias(__ieee754_hypot, hypot) +libm_hidden_def(hypot) diff --git a/libm/e_j0.c b/libm/e_j0.c index 74defacdf..f740d1902 100644 --- a/libm/e_j0.c +++ b/libm/e_j0.c @@ -1,4 +1,3 @@ -/* @(#)e_j0.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_j0.c,v 1.8 1995/05/10 20:45:23 jtc Exp $"; -#endif - /* __ieee754_j0(x), __ieee754_y0(x) * Bessel function of the first and second kinds of order zero. * Method -- j0(x): @@ -62,22 +57,9 @@ 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); -#else -static double pzero(), qzero(); -#endif -#ifdef __STDC__ static const double -#else -static double -#endif huge = 1e300, one = 1.0, invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ @@ -92,18 +74,9 @@ S02 = 1.16926784663337450260e-04, /* 0x3F1EA6D2, 0xDD57DBF4 */ S03 = 5.13546550207318111446e-07, /* 0x3EA13B54, 0xCE84D5A9 */ S04 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */ -#ifdef __STDC__ static const double zero = 0.0; -#else -static double zero = 0.0; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_j0(double x) -#else - double attribute_hidden __ieee754_j0(x) - double x; -#endif +double __ieee754_j0(double x) { double z, s,c,ss,cc,r,u,v; int32_t hx,ix; @@ -150,11 +123,9 @@ static double zero = 0.0; } } -#ifdef __STDC__ +strong_alias(__ieee754_j0, j0) + static const double -#else -static double -#endif u00 = -7.38042951086872317523e-02, /* 0xBFB2E4D6, 0x99CBD01F */ u01 = 1.76666452509181115538e-01, /* 0x3FC69D01, 0x9DE9E3FC */ u02 = -1.38185671945596898896e-02, /* 0xBF8C4CE8, 0xB16CFA97 */ @@ -167,12 +138,7 @@ v02 = 7.60068627350353253702e-05, /* 0x3F13ECBB, 0xF578C6C1 */ v03 = 2.59150851840457805467e-07, /* 0x3E91642D, 0x7FF202FD */ v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */ -#ifdef __STDC__ - double attribute_hidden __ieee754_y0(double x) -#else - double attribute_hidden __ieee754_y0(x) - double x; -#endif +double __ieee754_y0(double x) { double z, s,c,ss,cc,u,v; int32_t hx,ix,lx; @@ -224,6 +190,8 @@ v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */ return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x))); } +strong_alias(__ieee754_y0, y0) + /* The asymptotic expansions of pzero is * 1 - 9/128 s^2 + 11025/98304 s^4 - ..., where s = 1/x. * For x >= 2, We approximate pzero by @@ -233,11 +201,7 @@ v04 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */ * and * | pzero(x)-1-R/S | <= 2 ** ( -60.26) */ -#ifdef __STDC__ static const double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#else -static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#endif 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ -7.03124999999900357484e-02, /* 0xBFB1FFFF, 0xFFFFFD32 */ -8.08167041275349795626e+00, /* 0xC02029D0, 0xB44FA779 */ @@ -245,11 +209,7 @@ static double pR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -2.48521641009428822144e+03, /* 0xC0A36A6E, 0xCD4DCAFC */ -5.25304380490729545272e+03, /* 0xC0B4850B, 0x36CC643D */ }; -#ifdef __STDC__ static const double pS8[5] = { -#else -static double pS8[5] = { -#endif 1.16534364619668181717e+02, /* 0x405D2233, 0x07A96751 */ 3.83374475364121826715e+03, /* 0x40ADF37D, 0x50596938 */ 4.05978572648472545552e+04, /* 0x40E3D2BB, 0x6EB6B05F */ @@ -257,11 +217,7 @@ static double pS8[5] = { 4.76277284146730962675e+04, /* 0x40E74177, 0x4F2C49DC */ }; -#ifdef __STDC__ static const double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#else -static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#endif -1.14125464691894502584e-11, /* 0xBDA918B1, 0x47E495CC */ -7.03124940873599280078e-02, /* 0xBFB1FFFF, 0xE69AFBC6 */ -4.15961064470587782438e+00, /* 0xC010A370, 0xF90C6BBF */ @@ -269,11 +225,7 @@ static double pR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -3.31231299649172967747e+02, /* 0xC074B3B3, 0x6742CC63 */ -3.46433388365604912451e+02, /* 0xC075A6EF, 0x28A38BD7 */ }; -#ifdef __STDC__ static const double pS5[5] = { -#else -static double pS5[5] = { -#endif 6.07539382692300335975e+01, /* 0x404E6081, 0x0C98C5DE */ 1.05125230595704579173e+03, /* 0x40906D02, 0x5C7E2864 */ 5.97897094333855784498e+03, /* 0x40B75AF8, 0x8FBE1D60 */ @@ -281,11 +233,7 @@ static double pS5[5] = { 2.40605815922939109441e+03, /* 0x40A2CC1D, 0xC70BE864 */ }; -#ifdef __STDC__ static const double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -#else -static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -#endif -2.54704601771951915620e-09, /* 0xBE25E103, 0x6FE1AA86 */ -7.03119616381481654654e-02, /* 0xBFB1FFF6, 0xF7C0E24B */ -2.40903221549529611423e+00, /* 0xC00345B2, 0xAEA48074 */ @@ -293,11 +241,7 @@ static double pR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -5.80791704701737572236e+01, /* 0xC04D0A22, 0x420A1A45 */ -3.14479470594888503854e+01, /* 0xC03F72AC, 0xA892D80F */ }; -#ifdef __STDC__ static const double pS3[5] = { -#else -static double pS3[5] = { -#endif 3.58560338055209726349e+01, /* 0x4041ED92, 0x84077DD3 */ 3.61513983050303863820e+02, /* 0x40769839, 0x464A7C0E */ 1.19360783792111533330e+03, /* 0x4092A66E, 0x6D1061D6 */ @@ -305,11 +249,7 @@ static double pS3[5] = { 1.73580930813335754692e+02, /* 0x4065B296, 0xFC379081 */ }; -#ifdef __STDC__ static const double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#else -static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#endif -8.87534333032526411254e-08, /* 0xBE77D316, 0xE927026D */ -7.03030995483624743247e-02, /* 0xBFB1FF62, 0x495E1E42 */ -1.45073846780952986357e+00, /* 0xBFF73639, 0x8A24A843 */ @@ -317,11 +257,7 @@ static double pR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -1.11931668860356747786e+01, /* 0xC02662E6, 0xC5246303 */ -3.23364579351335335033e+00, /* 0xC009DE81, 0xAF8FE70F */ }; -#ifdef __STDC__ static const double pS2[5] = { -#else -static double pS2[5] = { -#endif 2.22202997532088808441e+01, /* 0x40363865, 0x908B5959 */ 1.36206794218215208048e+02, /* 0x4061069E, 0x0EE8878F */ 2.70470278658083486789e+02, /* 0x4070E786, 0x42EA079B */ @@ -329,18 +265,9 @@ static double pS2[5] = { 1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */ }; -#ifdef __STDC__ - static double pzero(double x) -#else - static double pzero(x) - double x; -#endif +static double pzero(double x) { -#ifdef __STDC__ const double *p = 0,*q = 0; -#else - double *p,*q; -#endif double z,r,s; int32_t ix; GET_HIGH_WORD(ix,x); @@ -365,11 +292,7 @@ static double pS2[5] = { * and * | qzero(x)/s +1.25-R/S | <= 2 ** ( -61.22) */ -#ifdef __STDC__ static const double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#else -static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#endif 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ 7.32421874999935051953e-02, /* 0x3FB2BFFF, 0xFFFFFE2C */ 1.17682064682252693899e+01, /* 0x40278952, 0x5BB334D6 */ @@ -377,11 +300,7 @@ static double qR8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ 8.85919720756468632317e+03, /* 0x40C14D99, 0x3E18F46D */ 3.70146267776887834771e+04, /* 0x40E212D4, 0x0E901566 */ }; -#ifdef __STDC__ static const double qS8[6] = { -#else -static double qS8[6] = { -#endif 1.63776026895689824414e+02, /* 0x406478D5, 0x365B39BC */ 8.09834494656449805916e+03, /* 0x40BFA258, 0x4E6B0563 */ 1.42538291419120476348e+05, /* 0x41016652, 0x54D38C3F */ @@ -390,11 +309,7 @@ static double qS8[6] = { -3.43899293537866615225e+05, /* 0xC114FD6D, 0x2C9530C5 */ }; -#ifdef __STDC__ static const double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#else -static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#endif 1.84085963594515531381e-11, /* 0x3DB43D8F, 0x29CC8CD9 */ 7.32421766612684765896e-02, /* 0x3FB2BFFF, 0xD172B04C */ 5.83563508962056953777e+00, /* 0x401757B0, 0xB9953DD3 */ @@ -402,11 +317,7 @@ static double qR5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ 1.02724376596164097464e+03, /* 0x40900CF9, 0x9DC8C481 */ 1.98997785864605384631e+03, /* 0x409F17E9, 0x53C6E3A6 */ }; -#ifdef __STDC__ static const double qS5[6] = { -#else -static double qS5[6] = { -#endif 8.27766102236537761883e+01, /* 0x4054B1B3, 0xFB5E1543 */ 2.07781416421392987104e+03, /* 0x40A03BA0, 0xDA21C0CE */ 1.88472887785718085070e+04, /* 0x40D267D2, 0x7B591E6D */ @@ -415,11 +326,7 @@ static double qS5[6] = { -5.35434275601944773371e+03, /* 0xC0B4EA57, 0xBEDBC609 */ }; -#ifdef __STDC__ static const double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -#else -static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -#endif 4.37741014089738620906e-09, /* 0x3E32CD03, 0x6ADECB82 */ 7.32411180042911447163e-02, /* 0x3FB2BFEE, 0x0E8D0842 */ 3.34423137516170720929e+00, /* 0x400AC0FC, 0x61149CF5 */ @@ -427,11 +334,7 @@ static double qR3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ 1.70808091340565596283e+02, /* 0x406559DB, 0xE25EFD1F */ 1.66733948696651168575e+02, /* 0x4064D77C, 0x81FA21E0 */ }; -#ifdef __STDC__ static const double qS3[6] = { -#else -static double qS3[6] = { -#endif 4.87588729724587182091e+01, /* 0x40486122, 0xBFE343A6 */ 7.09689221056606015736e+02, /* 0x40862D83, 0x86544EB3 */ 3.70414822620111362994e+03, /* 0x40ACF04B, 0xE44DFC63 */ @@ -440,11 +343,7 @@ static double qS3[6] = { -1.49247451836156386662e+02, /* 0xC062A7EB, 0x201CF40F */ }; -#ifdef __STDC__ static const double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#else -static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#endif 1.50444444886983272379e-07, /* 0x3E84313B, 0x54F76BDB */ 7.32234265963079278272e-02, /* 0x3FB2BEC5, 0x3E883E34 */ 1.99819174093815998816e+00, /* 0x3FFFF897, 0xE727779C */ @@ -452,11 +351,7 @@ static double qR2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ 3.16662317504781540833e+01, /* 0x403FAA8E, 0x29FBDC4A */ 1.62527075710929267416e+01, /* 0x403040B1, 0x71814BB4 */ }; -#ifdef __STDC__ static const double qS2[6] = { -#else -static double qS2[6] = { -#endif 3.03655848355219184498e+01, /* 0x403E5D96, 0xF7C07AED */ 2.69348118608049844624e+02, /* 0x4070D591, 0xE4D14B40 */ 8.44783757595320139444e+02, /* 0x408A6645, 0x22B3BF22 */ @@ -465,18 +360,9 @@ static double qS2[6] = { -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */ }; -#ifdef __STDC__ - static double qzero(double x) -#else - static double qzero(x) - double x; -#endif +static double qzero(double x) { -#ifdef __STDC__ const double *p=0,*q=0; -#else - double *p,*q; -#endif double s,r,z; int32_t ix; GET_HIGH_WORD(ix,x); diff --git a/libm/e_j1.c b/libm/e_j1.c index bb3e650eb..78754b4c1 100644 --- a/libm/e_j1.c +++ b/libm/e_j1.c @@ -1,4 +1,3 @@ -/* @(#)e_j1.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_j1.c,v 1.8 1995/05/10 20:45:27 jtc Exp $"; -#endif - /* __ieee754_j1(x), __ieee754_y1(x) * Bessel function of the first and second kinds of order zero. * Method -- j1(x): @@ -62,22 +57,9 @@ 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); -#else -static double pone(), qone(); -#endif -#ifdef __STDC__ static const double -#else -static double -#endif huge = 1e300, one = 1.0, invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ @@ -93,18 +75,9 @@ s03 = 1.17718464042623683263e-06, /* 0x3EB3BFF8, 0x333F8498 */ s04 = 5.04636257076217042715e-09, /* 0x3E35AC88, 0xC97DFF2C */ s05 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */ -#ifdef __STDC__ static const double zero = 0.0; -#else -static double zero = 0.0; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_j1(double x) -#else - double attribute_hidden __ieee754_j1(x) - double x; -#endif +double __ieee754_j1(double x) { double z, s,c,ss,cc,r,u,v,y; int32_t hx,ix; @@ -145,22 +118,16 @@ static double zero = 0.0; return(x*0.5+r/s); } -#ifdef __STDC__ +strong_alias(__ieee754_j1, j1) + static const double U0[5] = { -#else -static double U0[5] = { -#endif -1.96057090646238940668e-01, /* 0xBFC91866, 0x143CBC8A */ 5.04438716639811282616e-02, /* 0x3FA9D3C7, 0x76292CD1 */ -1.91256895875763547298e-03, /* 0xBF5F55E5, 0x4844F50F */ 2.35252600561610495928e-05, /* 0x3EF8AB03, 0x8FA6B88E */ -9.19099158039878874504e-08, /* 0xBE78AC00, 0x569105B8 */ }; -#ifdef __STDC__ static const double V0[5] = { -#else -static double V0[5] = { -#endif 1.99167318236649903973e-02, /* 0x3F94650D, 0x3F4DA9F0 */ 2.02552581025135171496e-04, /* 0x3F2A8C89, 0x6C257764 */ 1.35608801097516229404e-06, /* 0x3EB6C05A, 0x894E8CA6 */ @@ -168,12 +135,7 @@ static double V0[5] = { 1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */ }; -#ifdef __STDC__ - double attribute_hidden __ieee754_y1(double x) -#else - double attribute_hidden __ieee754_y1(x) - double x; -#endif +double __ieee754_y1(double x) { double z, s,c,ss,cc,u,v; int32_t hx,ix,lx; @@ -221,6 +183,8 @@ static double V0[5] = { return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x)); } +strong_alias(__ieee754_y1, y1) + /* For x >= 8, the asymptotic expansions of pone is * 1 + 15/128 s^2 - 4725/2^15 s^4 - ..., where s = 1/x. * We approximate pone by @@ -231,11 +195,7 @@ static double V0[5] = { * | pone(x)-1-R/S | <= 2 ** ( -60.06) */ -#ifdef __STDC__ static const double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#else -static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#endif 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ 1.17187499999988647970e-01, /* 0x3FBDFFFF, 0xFFFFFCCE */ 1.32394806593073575129e+01, /* 0x402A7A9D, 0x357F7FCE */ @@ -243,11 +203,7 @@ static double pr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ 3.87474538913960532227e+03, /* 0x40AE457D, 0xA3A532CC */ 7.91447954031891731574e+03, /* 0x40BEEA7A, 0xC32782DD */ }; -#ifdef __STDC__ static const double ps8[5] = { -#else -static double ps8[5] = { -#endif 1.14207370375678408436e+02, /* 0x405C8D45, 0x8E656CAC */ 3.65093083420853463394e+03, /* 0x40AC85DC, 0x964D274F */ 3.69562060269033463555e+04, /* 0x40E20B86, 0x97C5BB7F */ @@ -255,11 +211,7 @@ static double ps8[5] = { 3.08042720627888811578e+04, /* 0x40DE1511, 0x697A0B2D */ }; -#ifdef __STDC__ static const double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#else -static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#endif 1.31990519556243522749e-11, /* 0x3DAD0667, 0xDAE1CA7D */ 1.17187493190614097638e-01, /* 0x3FBDFFFF, 0xE2C10043 */ 6.80275127868432871736e+00, /* 0x401B3604, 0x6E6315E3 */ @@ -267,11 +219,7 @@ static double pr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ 5.17636139533199752805e+02, /* 0x40802D16, 0xD052D649 */ 5.28715201363337541807e+02, /* 0x408085B8, 0xBB7E0CB7 */ }; -#ifdef __STDC__ static const double ps5[5] = { -#else -static double ps5[5] = { -#endif 5.92805987221131331921e+01, /* 0x404DA3EA, 0xA8AF633D */ 9.91401418733614377743e+02, /* 0x408EFB36, 0x1B066701 */ 5.35326695291487976647e+03, /* 0x40B4E944, 0x5706B6FB */ @@ -279,11 +227,7 @@ static double ps5[5] = { 1.50404688810361062679e+03, /* 0x40978030, 0x036F5E51 */ }; -#ifdef __STDC__ static const double pr3[6] = { -#else -static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -#endif 3.02503916137373618024e-09, /* 0x3E29FC21, 0xA7AD9EDD */ 1.17186865567253592491e-01, /* 0x3FBDFFF5, 0x5B21D17B */ 3.93297750033315640650e+00, /* 0x400F76BC, 0xE85EAD8A */ @@ -291,11 +235,7 @@ static double pr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ 9.10550110750781271918e+01, /* 0x4056C385, 0x4D2C1837 */ 4.85590685197364919645e+01, /* 0x4048478F, 0x8EA83EE5 */ }; -#ifdef __STDC__ static const double ps3[5] = { -#else -static double ps3[5] = { -#endif 3.47913095001251519989e+01, /* 0x40416549, 0xA134069C */ 3.36762458747825746741e+02, /* 0x40750C33, 0x07F1A75F */ 1.04687139975775130551e+03, /* 0x40905B7C, 0x5037D523 */ @@ -303,11 +243,7 @@ static double ps3[5] = { 1.03787932439639277504e+02, /* 0x4059F26D, 0x7C2EED53 */ }; -#ifdef __STDC__ static const double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#else -static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#endif 1.07710830106873743082e-07, /* 0x3E7CE9D4, 0xF65544F4 */ 1.17176219462683348094e-01, /* 0x3FBDFF42, 0xBE760D83 */ 2.36851496667608785174e+00, /* 0x4002F2B7, 0xF98FAEC0 */ @@ -315,11 +251,7 @@ static double pr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ 1.76939711271687727390e+01, /* 0x4031B1A8, 0x177F8EE2 */ 5.07352312588818499250e+00, /* 0x40144B49, 0xA574C1FE */ }; -#ifdef __STDC__ static const double ps2[5] = { -#else -static double ps2[5] = { -#endif 2.14364859363821409488e+01, /* 0x40356FBD, 0x8AD5ECDC */ 1.25290227168402751090e+02, /* 0x405F5293, 0x14F92CD5 */ 2.32276469057162813669e+02, /* 0x406D08D8, 0xD5A2DBD9 */ @@ -327,18 +259,9 @@ static double ps2[5] = { 8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */ }; -#ifdef __STDC__ - static double pone(double x) -#else - static double pone(x) - double x; -#endif +static double pone(double x) { -#ifdef __STDC__ const double *p=0,*q=0; -#else - double *p,*q; -#endif double z,r,s; int32_t ix; GET_HIGH_WORD(ix,x); @@ -364,11 +287,7 @@ static double ps2[5] = { * | qone(x)/s -0.375-R/S | <= 2 ** ( -61.13) */ -#ifdef __STDC__ static const double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#else -static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -#endif 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ -1.02539062499992714161e-01, /* 0xBFBA3FFF, 0xFFFFFDF3 */ -1.62717534544589987888e+01, /* 0xC0304591, 0xA26779F7 */ @@ -376,11 +295,7 @@ static double qr8[6] = { /* for x in [inf, 8]=1/[0,0.125] */ -1.18498066702429587167e+04, /* 0xC0C724E7, 0x40F87415 */ -4.84385124285750353010e+04, /* 0xC0E7A6D0, 0x65D09C6A */ }; -#ifdef __STDC__ static const double qs8[6] = { -#else -static double qs8[6] = { -#endif 1.61395369700722909556e+02, /* 0x40642CA6, 0xDE5BCDE5 */ 7.82538599923348465381e+03, /* 0x40BE9162, 0xD0D88419 */ 1.33875336287249578163e+05, /* 0x4100579A, 0xB0B75E98 */ @@ -389,11 +304,7 @@ static double qs8[6] = { -2.94490264303834643215e+05, /* 0xC111F969, 0x0EA5AA18 */ }; -#ifdef __STDC__ static const double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#else -static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -#endif -2.08979931141764104297e-11, /* 0xBDB6FA43, 0x1AA1A098 */ -1.02539050241375426231e-01, /* 0xBFBA3FFF, 0xCB597FEF */ -8.05644828123936029840e+00, /* 0xC0201CE6, 0xCA03AD4B */ @@ -401,11 +312,7 @@ static double qr5[6] = { /* for x in [8,4.5454]=1/[0.125,0.22001] */ -1.37319376065508163265e+03, /* 0xC09574C6, 0x6931734F */ -2.61244440453215656817e+03, /* 0xC0A468E3, 0x88FDA79D */ }; -#ifdef __STDC__ static const double qs5[6] = { -#else -static double qs5[6] = { -#endif 8.12765501384335777857e+01, /* 0x405451B2, 0xFF5A11B2 */ 1.99179873460485964642e+03, /* 0x409F1F31, 0xE77BF839 */ 1.74684851924908907677e+04, /* 0x40D10F1F, 0x0D64CE29 */ @@ -414,11 +321,7 @@ static double qs5[6] = { -4.71918354795128470869e+03, /* 0xC0B26F2E, 0xFCFFA004 */ }; -#ifdef __STDC__ static const double qr3[6] = { -#else -static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -#endif -5.07831226461766561369e-09, /* 0xBE35CFA9, 0xD38FC84F */ -1.02537829820837089745e-01, /* 0xBFBA3FEB, 0x51AEED54 */ -4.61011581139473403113e+00, /* 0xC01270C2, 0x3302D9FF */ @@ -426,11 +329,7 @@ static double qr3[6] = {/* for x in [4.547,2.8571]=1/[0.2199,0.35001] */ -2.28244540737631695038e+02, /* 0xC06C87D3, 0x4718D55F */ -2.19210128478909325622e+02, /* 0xC06B66B9, 0x5F5C1BF6 */ }; -#ifdef __STDC__ static const double qs3[6] = { -#else -static double qs3[6] = { -#endif 4.76651550323729509273e+01, /* 0x4047D523, 0xCCD367E4 */ 6.73865112676699709482e+02, /* 0x40850EEB, 0xC031EE3E */ 3.38015286679526343505e+03, /* 0x40AA684E, 0x448E7C9A */ @@ -439,11 +338,7 @@ static double qs3[6] = { -1.35201191444307340817e+02, /* 0xC060E670, 0x290A311F */ }; -#ifdef __STDC__ static const double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#else -static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -#endif -1.78381727510958865572e-07, /* 0xBE87F126, 0x44C626D2 */ -1.02517042607985553460e-01, /* 0xBFBA3E8E, 0x9148B010 */ -2.75220568278187460720e+00, /* 0xC0060484, 0x69BB4EDA */ @@ -451,11 +346,7 @@ static double qr2[6] = {/* for x in [2.8570,2]=1/[0.3499,0.5] */ -4.23253133372830490089e+01, /* 0xC04529A3, 0xDE104AAA */ -2.13719211703704061733e+01, /* 0xC0355F36, 0x39CF6E52 */ }; -#ifdef __STDC__ static const double qs2[6] = { -#else -static double qs2[6] = { -#endif 2.95333629060523854548e+01, /* 0x403D888A, 0x78AE64FF */ 2.52981549982190529136e+02, /* 0x406F9F68, 0xDB821CBA */ 7.57502834868645436472e+02, /* 0x4087AC05, 0xCE49A0F7 */ @@ -464,18 +355,9 @@ static double qs2[6] = { -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */ }; -#ifdef __STDC__ - static double qone(double x) -#else - static double qone(x) - double x; -#endif +static double qone(double x) { -#ifdef __STDC__ const double *p=0,*q=0; -#else - double *p,*q; -#endif double s,r,z; int32_t ix; GET_HIGH_WORD(ix,x); diff --git a/libm/e_jn.c b/libm/e_jn.c index 53c6396f6..2133905e4 100644 --- a/libm/e_jn.c +++ b/libm/e_jn.c @@ -1,4 +1,3 @@ -/* @(#)e_jn.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_jn.c,v 1.9 1995/05/10 20:45:34 jtc Exp $"; -#endif - /* * __ieee754_jn(n, x), __ieee754_yn(n, x) * floating point Bessel's function of the 1st and 2nd kind @@ -43,32 +38,14 @@ 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 -#else -static double -#endif invsqrtpi= 5.64189583547756279280e-01, /* 0x3FE20DD7, 0x50429B6D */ two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */ one = 1.00000000000000000000e+00; /* 0x3FF00000, 0x00000000 */ -#ifdef __STDC__ static const double zero = 0.00000000000000000000e+00; -#else -static double zero = 0.00000000000000000000e+00; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_jn(int n, double x) -#else - double attribute_hidden __ieee754_jn(n,x) - int n; double x; -#endif +double __ieee754_jn(int n, double x) { int32_t i,hx,ix,lx, sgn; double a, b, temp=0, di; @@ -223,12 +200,9 @@ static double zero = 0.00000000000000000000e+00; if(sgn==1) return -b; else return b; } -#ifdef __STDC__ - double attribute_hidden __ieee754_yn(int n, double x) -#else - double attribute_hidden __ieee754_yn(n,x) - int n; double x; -#endif +strong_alias(__ieee754_jn, jn) + +double __ieee754_yn(int n, double x) { int32_t i,hx,ix,lx; int32_t sign; @@ -284,3 +258,5 @@ static double zero = 0.00000000000000000000e+00; } if(sign>0) return b; else return -b; } + +strong_alias(__ieee754_yn, yn) diff --git a/libm/e_lgamma_r.c b/libm/e_lgamma_r.c index 5e1b373c0..82005ea17 100644 --- a/libm/e_lgamma_r.c +++ b/libm/e_lgamma_r.c @@ -1,4 +1,3 @@ -/* @(#)er_lgamma.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_lgamma_r.c,v 1.7 1995/05/10 20:45:42 jtc Exp $"; -#endif - /* __ieee754_lgamma_r(x, signgamp) * Reentrant version of the logarithm of the Gamma function * with user provide pointer for the sign of Gamma(x). @@ -84,14 +79,7 @@ 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 -static double -#endif two52= 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ @@ -159,22 +147,13 @@ w4 = -5.95187557450339963135e-04, /* 0xBF4380CB, 0x8C0FE741 */ w5 = 8.36339918996282139126e-04, /* 0x3F4B67BA, 0x4CDAD5D1 */ w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */ -#ifdef __STDC__ static const double zero= 0.00000000000000000000e+00; -#else -static double zero= 0.00000000000000000000e+00; -#endif static #ifdef __GNUC__ -inline -#endif -#ifdef __STDC__ - double sin_pi(double x) -#else - double sin_pi(x) - double x; +__inline__ #endif +double sin_pi(double x) { double y,z; int n,ix; @@ -218,13 +197,7 @@ inline return -y; } - -#ifdef __STDC__ - double attribute_hidden __ieee754_lgamma_r(double x, int *signgamp) -#else - double attribute_hidden __ieee754_lgamma_r(x,signgamp) - double x; int *signgamp; -#endif +double __ieee754_lgamma_r(double x, int *signgamp) { double t,y,z,nadj=0,p,p1,p2,p3,q,r,w; int i,hx,lx,ix; @@ -235,7 +208,11 @@ inline *signgamp = 1; ix = hx&0x7fffffff; if(ix>=0x7ff00000) return x*x; - if((ix|lx)==0) return one/zero; + if((ix|lx)==0) { + if (signbit(x)) + *signgamp = -1; + return one/zero; + } if(ix<0x3b900000) { /* |x|<2**-70, return -log(|x|) */ if(hx<0) { *signgamp = -1; @@ -317,3 +294,62 @@ inline if(hx<0) r = nadj - r; return r; } + +strong_alias(__ieee754_lgamma_r, lgamma_r) +libm_hidden_def(lgamma_r) + +/* __ieee754_lgamma(x) + * Return the logarithm of the Gamma function of x. + */ +double __ieee754_lgamma(double x) +{ + return __ieee754_lgamma_r(x, &signgam); +} + +strong_alias(__ieee754_lgamma, lgamma); +libm_hidden_def(lgamma) + + +/* NB: gamma function is an old name for lgamma. + * It is deprecated. + * Some C math libraries redefine it as a "true gamma", i.e., + * not a ln(|Gamma(x)|) but just Gamma(x), but standards + * introduced tgamma name for that. + */ +strong_alias(__ieee754_lgamma_r, gamma_r) +strong_alias(__ieee754_lgamma, gamma) +libm_hidden_def(gamma) + + +/* double tgamma(double x) + * Return the Gamma function of x. + */ +double tgamma(double x) +{ + int sign_of_gamma; + int32_t hx; + u_int32_t lx; + + /* We don't have a real gamma implementation now. We'll use lgamma + and the exp function. But due to the required boundary + conditions we must check some values separately. */ + + EXTRACT_WORDS(hx, lx, x); + + if (((hx & 0x7fffffff) | lx) == 0) { + /* Return value for x == 0 is Inf with divide by zero exception. */ + return 1.0 / x; + } + if (hx < 0 && (u_int32_t)hx < 0xfff00000 && rint(x) == x) { + /* Return value for integer x < 0 is NaN with invalid exception. */ + return (x - x) / (x - x); + } + if ((u_int32_t)hx == 0xfff00000 && lx == 0) { + /* x == -Inf. According to ISO this is NaN. */ + return x - x; + } + + x = exp(lgamma_r(x, &sign_of_gamma)); + return sign_of_gamma >= 0 ? x : -x; +} +libm_hidden_def(tgamma) diff --git a/libm/e_log.c b/libm/e_log.c index fce0617aa..1ca453d04 100644 --- a/libm/e_log.c +++ b/libm/e_log.c @@ -1,4 +1,3 @@ -/* @(#)e_log.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_log.c,v 1.8 1995/05/10 20:45:49 jtc Exp $"; -#endif - /* __ieee754_log(x) * Return the logrithm of x * @@ -68,11 +63,7 @@ static char rcsid[] = "$NetBSD: e_log.c,v 1.8 1995/05/10 20:45:49 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ @@ -84,18 +75,9 @@ 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 attribute_hidden __ieee754_log(double x) -#else - double attribute_hidden __ieee754_log(x) - double x; -#endif +double __ieee754_log(double x) { double hfsq,f,s,z,R,w,t1,t2,dk; int32_t k,hx,i,j; @@ -145,3 +127,6 @@ static double zero = 0.0; return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); } } + +strong_alias(__ieee754_log, log) +libm_hidden_def(log) diff --git a/libm/e_log10.c b/libm/e_log10.c index 5b25c0f76..3c62081e6 100644 --- a/libm/e_log10.c +++ b/libm/e_log10.c @@ -1,4 +1,3 @@ -/* @(#)e_log10.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_log10.c,v 1.9 1995/05/10 20:45:51 jtc Exp $"; -#endif - /* __ieee754_log10(x) * Return the base 10 logarithm of x * @@ -50,28 +45,15 @@ static char rcsid[] = "$NetBSD: e_log10.c,v 1.9 1995/05/10 20:45:51 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */ log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */ log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */ -#ifdef __STDC__ -static const double zero = 0.0; -#else -static double zero = 0.0; -#endif +static const double zero = 0.0; -#ifdef __STDC__ - double attribute_hidden __ieee754_log10(double x) -#else - double attribute_hidden __ieee754_log10(x) - double x; -#endif +double __ieee754_log10(double x) { double y,z; int32_t i,k,hx; @@ -96,3 +78,6 @@ static double zero = 0.0; z = y*log10_2lo + ivln10*__ieee754_log(x); return z+y*log10_2hi; } + +strong_alias(__ieee754_log10, log10) +libm_hidden_def(log10) diff --git a/libm/e_log2.c b/libm/e_log2.c new file mode 100644 index 000000000..b5dfc802d --- /dev/null +++ b/libm/e_log2.c @@ -0,0 +1,119 @@ +/* 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" + +static const double +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 */ + +static const double zero = 0.0; + +double __ieee754_log2(double x) +{ + 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; + } +} +strong_alias(__ieee754_log2,log2) +libm_hidden_def(log2) diff --git a/libm/e_pow.c b/libm/e_pow.c index 675149e1f..1958fe619 100644 --- a/libm/e_pow.c +++ b/libm/e_pow.c @@ -1,4 +1,3 @@ -/* @(#)e_pow.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; -#endif - /* __ieee754_pow(x,y) return x**y * * n @@ -26,25 +21,26 @@ static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; * 3. Return x**y = 2**n*exp(y'*log2) * * Special cases: - * 1. (anything) ** 0 is 1 - * 2. (anything) ** 1 is itself - * 3. (anything) ** NAN is NAN - * 4. NAN ** (anything except 0) is NAN - * 5. +-(|x| > 1) ** +INF is +INF - * 6. +-(|x| > 1) ** -INF is +0 - * 7. +-(|x| < 1) ** +INF is +0 - * 8. +-(|x| < 1) ** -INF is +INF - * 9. +-1 ** +-INF is NAN - * 10. +0 ** (+anything except 0, NAN) is +0 - * 11. -0 ** (+anything except 0, NAN, odd integer) is +0 - * 12. +0 ** (-anything except 0, NAN) is +INF - * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF - * 14. -0 ** (odd integer) = -( +0 ** (odd integer) ) - * 15. +INF ** (+anything except 0,NAN) is +INF - * 16. +INF ** (-anything except 0,NAN) is +0 - * 17. -INF ** (anything) = -0 ** (-anything) - * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) - * 19. (-anything except 0 and inf) ** (non-integer) is NAN + * 1. +-1 ** anything is 1.0 + * 2. +-1 ** +-INF is 1.0 + * 3. (anything) ** 0 is 1 + * 4. (anything) ** 1 is itself + * 5. (anything) ** NAN is NAN + * 6. NAN ** (anything except 0) is NAN + * 7. +-(|x| > 1) ** +INF is +INF + * 8. +-(|x| > 1) ** -INF is +0 + * 9. +-(|x| < 1) ** +INF is +0 + * 10 +-(|x| < 1) ** -INF is +INF + * 11. +0 ** (+anything except 0, NAN) is +0 + * 12. -0 ** (+anything except 0, NAN, odd integer) is +0 + * 13. +0 ** (-anything except 0, NAN) is +INF + * 14. -0 ** (-anything except 0, NAN, odd integer) is +INF + * 15. -0 ** (odd integer) = -( +0 ** (odd integer) ) + * 16. +INF ** (+anything except 0,NAN) is +INF + * 17. +INF ** (-anything except 0,NAN) is +0 + * 18. -INF ** (anything) = -0 ** (-anything) + * 19. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer) + * 20. (-anything except 0 and inf) ** (non-integer) is NAN * * Accuracy: * pow(x,y) returns x**y nearly rounded. In particular @@ -62,14 +58,7 @@ 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 -#else -static double -#endif bp[] = {1.0, 1.5,}, dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ @@ -102,22 +91,23 @@ ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ -#ifdef __STDC__ - double attribute_hidden __ieee754_pow(double x, double y) -#else - double attribute_hidden __ieee754_pow(x,y) - double x, y; -#endif +double __ieee754_pow(double x, double y) { double z,ax,z_h,z_l,p_h,p_l; - double y1,t1,t2,r,s,t,u,v,w; + double _y1,t1,t2,r,s,t,u,v,w; int32_t i,j,k,yisint,n; int32_t hx,hy,ix,iy; u_int32_t lx,ly; EXTRACT_WORDS(hx,lx,x); + /* x==1: 1**y = 1 (even if y is NaN) */ + if (hx==0x3ff00000 && lx==0) { + return x; + } + ix = hx&0x7fffffff; + EXTRACT_WORDS(hy,ly,y); - ix = hx&0x7fffffff; iy = hy&0x7fffffff; + iy = hy&0x7fffffff; /* y==zero: x**0 = 1 */ if((iy|ly)==0) return one; @@ -149,13 +139,13 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ /* special value of y */ if(ly==0) { - if (iy==0x7ff00000) { /* y is +-inf */ - if(((ix-0x3ff00000)|lx)==0) - return y - y; /* inf**+-1 is NaN */ - else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */ - return (hy>=0)? y: zero; - else /* (|x|<1)**-,+inf = inf,0 */ - return (hy<0)?-y: zero; + if (iy==0x7ff00000) { /* y is +-inf */ + if (((ix-0x3ff00000)|lx)==0) + return one; /* +-1**+-inf is 1 (yes, weird rule) */ + if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */ + return (hy>=0) ? y : zero; + /* (|x|<1)**-,+inf = inf,0 */ + return (hy<0) ? -y : zero; } if(iy==0x3ff00000) { /* y is +-1 */ if(hy<0) return one/x; else return x; @@ -163,7 +153,7 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ if(hy==0x40000000) return x*x; /* y is 2 */ if(hy==0x3fe00000) { /* y is 0.5 */ if(hx>=0) /* x >= +0 */ - return __ieee754_sqrt(x); + return __ieee754_sqrt(x); } } @@ -259,10 +249,10 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ s = -one;/* (-ve)**(odd int) */ /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */ - y1 = y; - SET_LOW_WORD(y1,0); - p_l = (y-y1)*t1+y*t2; - p_h = y1*t1; + _y1 = y; + SET_LOW_WORD(_y1,0); + p_l = (y-_y1)*t1+y*t2; + p_h = _y1*t1; z = p_l+p_h; EXTRACT_WORDS(j,i,z); if (j>=0x40900000) { /* z >= 1024 */ @@ -309,3 +299,6 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ else SET_HIGH_WORD(z,j); return s*z; } + +strong_alias(__ieee754_pow, pow) +libm_hidden_def(pow) diff --git a/libm/e_rem_pio2.c b/libm/e_rem_pio2.c index 97ce7bab1..3bbcd0072 100644 --- a/libm/e_rem_pio2.c +++ b/libm/e_rem_pio2.c @@ -1,4 +1,3 @@ -/* @(#)e_rem_pio2.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_rem_pio2.c,v 1.8 1995/05/10 20:46:02 jtc Exp $"; -#endif - /* __ieee754_rem_pio2(x,y) * * return the remainder of x rem pi/2 in y[0]+y[1] @@ -23,16 +18,10 @@ 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 */ -#ifdef __STDC__ static const int32_t two_over_pi[] = { -#else -static int32_t two_over_pi[] = { -#endif 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, @@ -46,11 +35,7 @@ static int32_t two_over_pi[] = { 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, }; -#ifdef __STDC__ static const int32_t npio2_hw[] = { -#else -static int32_t npio2_hw[] = { -#endif 0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, 0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, 0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, @@ -69,11 +54,7 @@ static int32_t npio2_hw[] = { * pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3) */ -#ifdef __STDC__ static const double -#else -static double -#endif zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */ half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ @@ -85,12 +66,7 @@ pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ -#ifdef __STDC__ - int32_t attribute_hidden __ieee754_rem_pio2(double x, double *y) -#else - int32_t attribute_hidden __ieee754_rem_pio2(x,y) - double x,y[]; -#endif +int32_t __ieee754_rem_pio2(double x, double *y) { double z=0.0,w,t,r,fn; double tx[3]; diff --git a/libm/e_remainder.c b/libm/e_remainder.c index 17047b385..8a00ff24f 100644 --- a/libm/e_remainder.c +++ b/libm/e_remainder.c @@ -1,4 +1,3 @@ -/* @(#)e_remainder.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_remainder.c,v 1.8 1995/05/10 20:46:05 jtc Exp $"; -#endif - /* __ieee754_remainder(x,p) * Return : * returns x REM p = x - [x/p]*p as if in infinite @@ -26,21 +21,9 @@ 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; -#else -static double zero = 0.0; -#endif - -#ifdef __STDC__ - double attribute_hidden __ieee754_remainder(double x, double p) -#else - double attribute_hidden __ieee754_remainder(x,p) - double x,p; -#endif +double __ieee754_remainder(double x, double p) { int32_t hx,hp; u_int32_t sx,lx,lp; @@ -80,3 +63,7 @@ static double zero = 0.0; SET_HIGH_WORD(x,hx^sx); return x; } + +strong_alias(__ieee754_remainder, remainder) +strong_alias(__ieee754_remainder, drem) +libm_hidden_def(remainder) diff --git a/libm/e_scalb.c b/libm/e_scalb.c index 772d95523..cc85b48d3 100644 --- a/libm/e_scalb.c +++ b/libm/e_scalb.c @@ -1,4 +1,3 @@ -/* @(#)e_scalb.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,45 +9,20 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $"; -#endif - /* - * __ieee754_scalb(x, fn) is provide for - * passing various standard test suite. One - * should use scalbn() instead. + * __ieee754_scalb(x, fn) is provided for + * passing various standard test suites. + * One should use scalbn() instead. */ #include "math.h" #include "math_private.h" +#include <errno.h> -libm_hidden_proto(scalbn) -libm_hidden_proto(finite) -libm_hidden_proto(rint) -libm_hidden_proto(__isnan) - -#ifdef _SCALB_INT -#ifdef __STDC__ - double attribute_hidden __ieee754_scalb(double x, int fn) -#else - double attribute_hidden __ieee754_scalb(x,fn) - double x; int fn; -#endif -#else -#ifdef __STDC__ - double attribute_hidden __ieee754_scalb(double x, double fn) -#else - double attribute_hidden __ieee754_scalb(x,fn) - double x, fn; -#endif -#endif +double __ieee754_scalb(double x, double fn) { -#ifdef _SCALB_INT - return scalbn(x,fn); -#else if (isnan(x)||isnan(fn)) return x*fn; - if (!finite(fn)) { + if (!isfinite(fn)) { if(fn>0.0) return x*fn; else return x/(-fn); } @@ -56,5 +30,9 @@ libm_hidden_proto(__isnan) if ( fn > 65000.0) return scalbn(x, 65000); if (-fn > 65000.0) return scalbn(x,-65000); return scalbn(x,(int)fn); -#endif } + +#if defined __UCLIBC_SUSV3_LEGACY__ +strong_alias(__ieee754_scalb, scalb) +libm_hidden_def(scalb) +#endif /* UCLIBC_SUSV3_LEGACY */ diff --git a/libm/e_sinh.c b/libm/e_sinh.c index e8452c287..52b33d5d1 100644 --- a/libm/e_sinh.c +++ b/libm/e_sinh.c @@ -1,4 +1,3 @@ -/* @(#)e_sinh.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $"; -#endif - /* __ieee754_sinh(x) * Method : * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 @@ -35,21 +30,9 @@ 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; -#else -static double one = 1.0, shuge = 1.0e307; -#endif -#ifdef __STDC__ - double attribute_hidden __ieee754_sinh(double x) -#else - double attribute_hidden __ieee754_sinh(x) - double x; -#endif +double __ieee754_sinh(double x) { double t,w,h; int32_t ix,jx; @@ -87,3 +70,6 @@ static double one = 1.0, shuge = 1.0e307; /* |x| > overflowthresold, sinh(x) overflow */ return x*shuge; } + +strong_alias(__ieee754_sinh, sinh) +libm_hidden_def(sinh) diff --git a/libm/e_sqrt.c b/libm/e_sqrt.c index c8385d673..a5b2049bc 100644 --- a/libm/e_sqrt.c +++ b/libm/e_sqrt.c @@ -1,4 +1,3 @@ -/* @(#)e_sqrt.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: e_sqrt.c,v 1.8 1995/05/10 20:46:17 jtc Exp $"; -#endif - /* __ieee754_sqrt(x) * Return correctly rounded sqrt. * ------------------------------------------ @@ -87,18 +82,9 @@ static char rcsid[] = "$NetBSD: e_sqrt.c,v 1.8 1995/05/10 20:46:17 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ -static const double one = 1.0, tiny=1.0e-300; -#else -static double one = 1.0, tiny=1.0e-300; -#endif - -#ifdef __STDC__ - double attribute_hidden __ieee754_sqrt(double x) -#else - double attribute_hidden __ieee754_sqrt(x) - double x; -#endif +static const double one = 1.0, tiny = 1.0e-300; + +double __ieee754_sqrt(double x) { double z; int32_t sign = (int)0x80000000; @@ -194,6 +180,10 @@ static double one = 1.0, tiny=1.0e-300; return z; } +strong_alias(__ieee754_sqrt, sqrt) +libm_hidden_def(sqrt) + + /* Other methods (use floating-point arithmetic) ------------- @@ -450,4 +440,3 @@ B. sqrt(x) by Reciproot Iteration (4) Special cases (see (4) of Section A). */ - diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c index cd0ae1832..105486e46 100644 --- a/libm/float_wrappers.c +++ b/libm/float_wrappers.c @@ -10,22 +10,42 @@ * GNU Lesser General Public License version 2.1 or later. */ +#include <features.h> +/* Prevent math.h from defining colliding inlines */ +#undef __USE_EXTERN_INLINES #include <math.h> #include <complex.h> -/* For the time being, do _NOT_ implement these functions - * that are defined by SuSv3 */ -#undef L_exp2f /*float exp2f(float);*/ -#undef L_fdimf /*float fdimf(float, float);*/ -#undef L_fmaf /*float fmaf(float, float, float);*/ -#undef L_fmaxf /*float fmaxf(float, float);*/ -#undef L_fminf /*float fminf(float, float);*/ -#undef L_log2f /*float log2f(float);*/ -#undef L_nearbyintf /*float nearbyintf(float);*/ -#undef L_nexttowardf /*float nexttowardf(float, long double);*/ -#undef L_remquof /*float remquof(float, float, int *);*/ -#undef L_scalblnf /*float scalblnf(float, long);*/ -#undef L_tgammaf /*float tgammaf(float);*/ + +#define WRAPPER1(func) \ +float func##f (float x) \ +{ \ + return (float) func((double)x); \ +} +#define int_WRAPPER1(func) \ +int func##f (float x) \ +{ \ + return func((double)x); \ +} +#define long_WRAPPER1(func) \ +long func##f (float x) \ +{ \ + return func((double)x); \ +} +#define long_long_WRAPPER1(func) \ +long long func##f (float x) \ +{ \ + return func((double)x); \ +} + +#ifndef __DO_XSI_MATH__ +# undef L_j0f /* float j0f(float x); */ +# undef L_j1f /* float j1f(float x); */ +# undef L_jnf /* float jnf(int n, float x); */ +# undef L_y0f /* float y0f(float x); */ +# undef L_y1f /* float y1f(float x); */ +# undef L_ynf /* float ynf(int n, float x); */ +#endif /* Implement the following, as defined by SuSv3 */ #if 0 @@ -36,6 +56,7 @@ float asinhf(float); float atan2f(float, float); float atanf(float); float atanhf(float); +float cargf(float complex); float cbrtf(float); float ceilf(float); float copysignf(float, float); @@ -43,6 +64,7 @@ float cosf(float); float coshf(float); float erfcf(float); float erff(float); +float exp2f(float); float expf(float); float expm1f(float); float fabsf(float); @@ -56,11 +78,11 @@ float lgammaf(float); long long llroundf(float); float log10f(float); float log1pf(float); +float log2f(float); float logbf(float); float logf(float); long lroundf(float); float modff(float, float *); -float nextafterf(float, float); float powf(float, float); float remainderf(float, float); float rintf(float); @@ -73,519 +95,330 @@ float tanf(float); float tanhf(float); #endif - #ifdef L_acosf -libm_hidden_proto(acos) -float acosf (float x) -{ - return (float) acos( (double)x ); -} +WRAPPER1(acos) #endif - #ifdef L_acoshf -libm_hidden_proto(acosh) -float acoshf (float x) -{ - return (float) acosh( (double)x ); -} +WRAPPER1(acosh) #endif - #ifdef L_asinf -libm_hidden_proto(asin) -float asinf (float x) -{ - return (float) asin( (double)x ); -} +WRAPPER1(asin) #endif - #ifdef L_asinhf -libm_hidden_proto(asinh) -float asinhf (float x) -{ - return (float) asinh( (double)x ); -} +WRAPPER1(asinh) #endif - #ifdef L_atan2f -libm_hidden_proto(atan2) float atan2f (float x, float y) { return (float) atan2( (double)x, (double)y ); } #endif - #ifdef L_atanf -libm_hidden_proto(atan) -float atanf (float x) -{ - return (float) atan( (double)x ); -} +WRAPPER1(atan) #endif - #ifdef L_atanhf -libm_hidden_proto(atanh) -float atanhf (float x) -{ - return (float) atanh( (double)x ); -} +WRAPPER1(atanh) #endif - #ifdef L_cargf -libm_hidden_proto(carg) float cargf (float complex x) { - return (float) carg( (double)x ); + return (float) carg( (double complex)x ); } #endif - #ifdef L_cbrtf -libm_hidden_proto(cbrt) -float cbrtf (float x) -{ - return (float) cbrt( (double)x ); -} +WRAPPER1(cbrt) #endif - #ifdef L_ceilf -libm_hidden_proto(ceil) -float ceilf (float x) -{ - return (float) ceil( (double)x ); -} +WRAPPER1(ceil) #endif - #ifdef L_copysignf -libm_hidden_proto(copysign) float copysignf (float x, float y) { return (float) copysign( (double)x, (double)y ); } #endif - #ifdef L_cosf -libm_hidden_proto(cos) -float cosf (float x) -{ - return (float) cos( (double)x ); -} +WRAPPER1(cos) +libm_hidden_def(cosf) #endif - #ifdef L_coshf -libm_hidden_proto(cosh) -float coshf (float x) -{ - return (float) cosh( (double)x ); -} +WRAPPER1(cosh) #endif - #ifdef L_erfcf -libm_hidden_proto(erfc) -float erfcf (float x) -{ - return (float) erfc( (double)x ); -} +WRAPPER1(erfc) #endif - #ifdef L_erff -libm_hidden_proto(erf) -float erff (float x) -{ - return (float) erf( (double)x ); -} +WRAPPER1(erf) #endif - #ifdef L_exp2f -libm_hidden_proto(exp2) -float exp2f (float x) -{ - return (float) exp2( (double)x ); -} +WRAPPER1(exp2) #endif - #ifdef L_expf -libm_hidden_proto(exp) -float expf (float x) -{ - return (float) exp( (double)x ); -} +WRAPPER1(exp) #endif - #ifdef L_expm1f -libm_hidden_proto(expm1) -float expm1f (float x) -{ - return (float) expm1( (double)x ); -} +WRAPPER1(expm1) #endif - #ifdef L_fabsf -libm_hidden_proto(fabs) -float fabsf (float x) -{ - return (float) fabs( (double)x ); -} +WRAPPER1(fabs) #endif - #ifdef L_fdimf -libm_hidden_proto(fdim) float fdimf (float x, float y) { return (float) fdim( (double)x, (double)y ); } #endif - #ifdef L_floorf -libm_hidden_proto(floor) -float floorf (float x) -{ - return (float) floor( (double)x ); -} +WRAPPER1(floor) #endif - #ifdef L_fmaf -libm_hidden_proto(fma) float fmaf (float x, float y, float z) { return (float) fma( (double)x, (double)y, (double)z ); } #endif - #ifdef L_fmaxf -libm_hidden_proto(fmax) float fmaxf (float x, float y) { return (float) fmax( (double)x, (double)y ); } #endif - #ifdef L_fminf -libm_hidden_proto(fmin) float fminf (float x, float y) { return (float) fmin( (double)x, (double)y ); } #endif - #ifdef L_fmodf -libm_hidden_proto(fmod) float fmodf (float x, float y) { return (float) fmod( (double)x, (double)y ); } #endif - #ifdef L_frexpf -libm_hidden_proto(frexp) float frexpf (float x, int *_exp) { return (float) frexp( (double)x, _exp ); } #endif - #ifdef L_hypotf -libm_hidden_proto(hypot) float hypotf (float x, float y) { return (float) hypot( (double)x, (double)y ); } #endif - #ifdef L_ilogbf -libm_hidden_proto(ilogb) -int ilogbf (float x) +int_WRAPPER1(ilogb) +#endif + +#ifdef L_j0f +WRAPPER1(j0) +#endif + +#ifdef L_j1f +WRAPPER1(j1) +#endif + +#ifdef L_jnf +float jnf(int n, float x) { - return (int) ilogb( (double)x ); + return (float) jn(n, (double)x); } #endif - #ifdef L_ldexpf -libm_hidden_proto(ldexp) float ldexpf (float x, int _exp) { return (float) ldexp( (double)x, _exp ); } #endif - #ifdef L_lgammaf -libm_hidden_proto(lgamma) -float lgammaf (float x) -{ - return (float) lgamma( (double)x ); -} +WRAPPER1(lgamma) #endif - #ifdef L_llrintf -libm_hidden_proto(llrint) -long long llrintf (float x) -{ - return (long long) llrint( (double)x ); -} +long_long_WRAPPER1(llrint) #endif - #ifdef L_llroundf -libm_hidden_proto(llround) -long long llroundf (float x) -{ - return (long long) llround( (double)x ); -} +long_long_WRAPPER1(llround) #endif - #ifdef L_log10f -libm_hidden_proto(log10) -float log10f (float x) -{ - return (float) log10( (double)x ); -} +WRAPPER1(log10) #endif - #ifdef L_log1pf -libm_hidden_proto(log1p) -float log1pf (float x) -{ - return (float) log1p( (double)x ); -} +WRAPPER1(log1p) #endif - #ifdef L_log2f -libm_hidden_proto(log2) -float log2f (float x) -{ - return (float) log2( (double)x ); -} +WRAPPER1(log2) #endif - #ifdef L_logbf -libm_hidden_proto(logb) -float logbf (float x) -{ - return (float) logb( (double)x ); -} +WRAPPER1(logb) #endif - #ifdef L_logf -libm_hidden_proto(log) -float logf (float x) -{ - return (float) log( (double)x ); -} +WRAPPER1(log) #endif - #ifdef L_lrintf -libm_hidden_proto(lrint) -long lrintf (float x) -{ - return (long) lrint( (double)x ); -} +long_WRAPPER1(lrint) #endif - #ifdef L_lroundf -libm_hidden_proto(lround) -long lroundf (float x) -{ - return (long) lround( (double)x ); -} +long_WRAPPER1(lround) #endif - #ifdef L_modff -libm_hidden_proto(modf) float modff (float x, float *iptr) { double y, result; - result = modf ( x, &y ); + result = modf( x, &y ); *iptr = (float)y; return (float) result; - } #endif - #ifdef L_nearbyintf -libm_hidden_proto(nearbyint) -float nearbyintf (float x) -{ - return (float) nearbyint( (double)x ); -} +WRAPPER1(nearbyint) #endif - -#ifdef L_nextafterf -libm_hidden_proto(nextafter) -float nextafterf (float x, float y) -{ - return (float) nextafter( (double)x, (double)y ); -} -#endif - - #ifdef L_nexttowardf -libm_hidden_proto(nexttoward) float nexttowardf (float x, long double y) { - return (float) nexttoward( (double)x, (double)y ); + return (float) nexttoward( (double)x, (long double)y ); } #endif - #ifdef L_powf -libm_hidden_proto(pow) float powf (float x, float y) { return (float) pow( (double)x, (double)y ); } #endif - #ifdef L_remainderf -libm_hidden_proto(remainder) float remainderf (float x, float y) { return (float) remainder( (double)x, (double)y ); } #endif - #ifdef L_remquof -libm_hidden_proto(remquo) float remquof (float x, float y, int *quo) { return (float) remquo( (double)x, (double)y, quo ); } #endif - #ifdef L_rintf -libm_hidden_proto(rint) -float rintf (float x) -{ - return (float) rint( (double)x ); -} +WRAPPER1(rint) #endif - #ifdef L_roundf -libm_hidden_proto(round) -float roundf (float x) -{ - return (float) round( (double)x ); -} +WRAPPER1(round) #endif - #ifdef L_scalblnf -libm_hidden_proto(scalbln) float scalblnf (float x, long _exp) { return (float) scalbln( (double)x, _exp ); } #endif - #ifdef L_scalbnf -libm_hidden_proto(scalbn) float scalbnf (float x, int _exp) { return (float) scalbn( (double)x, _exp ); } #endif - #ifdef L_sinf -libm_hidden_proto(sin) -float sinf (float x) -{ - return (float) sin( (double)x ); -} +WRAPPER1(sin) +libm_hidden_def(sinf) #endif - #ifdef L_sinhf -libm_hidden_proto(sinh) -float sinhf (float x) -{ - return (float) sinh( (double)x ); -} +WRAPPER1(sinh) #endif - #ifdef L_sqrtf -libm_hidden_proto(sqrt) -float sqrtf (float x) -{ - return (float) sqrt( (double)x ); -} +WRAPPER1(sqrt) #endif - #ifdef L_tanf -libm_hidden_proto(tan) -float tanf (float x) -{ - return (float) tan( (double)x ); -} +WRAPPER1(tan) #endif - #ifdef L_tanhf -libm_hidden_proto(tanh) -float tanhf (float x) -{ - return (float) tanh( (double)x ); -} +WRAPPER1(tanh) #endif - #ifdef L_tgammaf -libm_hidden_proto(tgamma) -float tgammaf (float x) +WRAPPER1(tgamma) +#endif + +#ifdef L_truncf +WRAPPER1(trunc) +#endif + +#if defined L_scalbf && defined __UCLIBC_SUSV3_LEGACY__ +float scalbf (float x, float y) { - return (float) tgamma( (double)x ); + return (float) scalb( (double)x, (double)y ); } #endif +#ifdef L_gammaf +WRAPPER1(gamma) +#endif -#ifdef L_truncf -libm_hidden_proto(trunc) -float truncf (float x) +#ifdef L_significandf +WRAPPER1(significand) +#endif + +#ifdef L_y0f +WRAPPER1(y0) +#endif + +#ifdef L_y1f +WRAPPER1(y1) +#endif + +#ifdef L_ynf +float ynf(int n, float x) { - return (float) trunc( (double)x ); + return (float) yn(n, (double)x); } #endif 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/i386/fclrexcpt.c b/libm/i386/fclrexcpt.c index a34060ce8..f8e89d76c 100644 --- a/libm/i386/fclrexcpt.c +++ b/libm/i386/fclrexcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/i386/fedisblxcpt.c b/libm/i386/fedisblxcpt.c index 75dc17897..6f378c9bd 100644 --- a/libm/i386/fedisblxcpt.c +++ b/libm/i386/fedisblxcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/i386/feenablxcpt.c b/libm/i386/feenablxcpt.c index 174f9f1ad..f4f04ba60 100644 --- a/libm/i386/feenablxcpt.c +++ b/libm/i386/feenablxcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/i386/fegetenv.c b/libm/i386/fegetenv.c index abbf179e0..1ff819802 100644 --- a/libm/i386/fegetenv.c +++ b/libm/i386/fegetenv.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> diff --git a/libm/i386/fegetexcept.c b/libm/i386/fegetexcept.c index 71bac788b..e5da558f9 100644 --- a/libm/i386/fegetexcept.c +++ b/libm/i386/fegetexcept.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> diff --git a/libm/i386/fegetround.c b/libm/i386/fegetround.c index 8ae0c3aff..c71f52804 100644 --- a/libm/i386/fegetround.c +++ b/libm/i386/fegetround.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> diff --git a/libm/i386/feholdexcpt.c b/libm/i386/feholdexcpt.c index d283e9e44..c0204e677 100644 --- a/libm/i386/feholdexcpt.c +++ b/libm/i386/feholdexcpt.c @@ -15,9 +15,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/i386/fesetenv.c b/libm/i386/fesetenv.c index fdb4fcc92..c71c7716d 100644 --- a/libm/i386/fesetenv.c +++ b/libm/i386/fesetenv.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <assert.h> diff --git a/libm/i386/fesetround.c b/libm/i386/fesetround.c index e1ba16975..66e3d1a33 100644 --- a/libm/i386/fesetround.c +++ b/libm/i386/fesetround.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/i386/feupdateenv.c b/libm/i386/feupdateenv.c index 91b535dc6..250b47aac 100644 --- a/libm/i386/feupdateenv.c +++ b/libm/i386/feupdateenv.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/i386/fgetexcptflg.c b/libm/i386/fgetexcptflg.c index f99122610..a68587d6c 100644 --- a/libm/i386/fgetexcptflg.c +++ b/libm/i386/fgetexcptflg.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> diff --git a/libm/i386/fraiseexcpt.c b/libm/i386/fraiseexcpt.c index fcb3d0e84..d8effab54 100644 --- a/libm/i386/fraiseexcpt.c +++ b/libm/i386/fraiseexcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <math.h> diff --git a/libm/i386/fsetexcptflg.c b/libm/i386/fsetexcptflg.c index bdd1dcca0..81793ead4 100644 --- a/libm/i386/fsetexcptflg.c +++ b/libm/i386/fsetexcptflg.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <math.h> diff --git a/libm/i386/ftestexcept.c b/libm/i386/ftestexcept.c index f45beced9..4cac50d00 100644 --- a/libm/i386/ftestexcept.c +++ b/libm/i386/ftestexcept.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <unistd.h> diff --git a/libm/k_cos.c b/libm/k_cos.c index b2bbca0ca..f95cc077f 100644 --- a/libm/k_cos.c +++ b/libm/k_cos.c @@ -1,4 +1,3 @@ -/* @(#)k_cos.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: k_cos.c,v 1.8 1995/05/10 20:46:22 jtc Exp $"; -#endif - /* * __kernel_cos( x, y ) * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 @@ -52,11 +47,7 @@ static char rcsid[] = "$NetBSD: k_cos.c,v 1.8 1995/05/10 20:46:22 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */ C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */ @@ -65,12 +56,7 @@ C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */ C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ -#ifdef __STDC__ - double attribute_hidden __kernel_cos(double x, double y) -#else - double attribute_hidden __kernel_cos(x, y) - double x,y; -#endif +double __kernel_cos(double x, double y) { double a,hz,z,r,qx; int32_t ix; diff --git a/libm/k_rem_pio2.c b/libm/k_rem_pio2.c index e3b9bc195..17ea9386c 100644 --- a/libm/k_rem_pio2.c +++ b/libm/k_rem_pio2.c @@ -1,4 +1,3 @@ -/* @(#)k_rem_pio2.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: k_rem_pio2.c,v 1.7 1995/05/10 20:46:25 jtc Exp $"; -#endif - /* * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) * double x[],y[]; int e0,nx,prec; int ipio2[]; @@ -133,20 +128,9 @@ 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 */ -#else -static int init_jk[] = {2,3,4,6}; -#endif -#ifdef __STDC__ static const double PIo2[] = { -#else -static double PIo2[] = { -#endif 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ @@ -157,22 +141,13 @@ static double PIo2[] = { 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ }; -#ifdef __STDC__ static const double -#else -static double -#endif zero = 0.0, one = 1.0, two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */ twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */ -#ifdef __STDC__ - int attribute_hidden __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) -#else - int attribute_hidden __kernel_rem_pio2(x,y,e0,nx,prec,ipio2) - double x[], y[]; int e0,nx,prec; int32_t ipio2[]; -#endif +int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2) { int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih; double z,fw,f[20],fq[20],q[20]; diff --git a/libm/k_sin.c b/libm/k_sin.c index 153f37ece..b670be324 100644 --- a/libm/k_sin.c +++ b/libm/k_sin.c @@ -1,4 +1,3 @@ -/* @(#)k_sin.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: k_sin.c,v 1.8 1995/05/10 20:46:31 jtc Exp $"; -#endif - /* __kernel_sin( x, y, iy) * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 * Input x is assumed to be bounded by ~pi/4 in magnitude. @@ -45,11 +40,7 @@ static char rcsid[] = "$NetBSD: k_sin.c,v 1.8 1995/05/10 20:46:31 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */ S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */ @@ -58,12 +49,7 @@ S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */ S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */ S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ -#ifdef __STDC__ - double attribute_hidden __kernel_sin(double x, double y, int iy) -#else - double attribute_hidden __kernel_sin(x, y, iy) - double x,y; int iy; /* iy=0 if y is zero */ -#endif +double __kernel_sin(double x, double y, int iy) { double z,r,v; int32_t ix; diff --git a/libm/k_standard.c b/libm/k_standard.c deleted file mode 100644 index 4df189853..000000000 --- a/libm/k_standard.c +++ /dev/null @@ -1,789 +0,0 @@ -/* @(#)k_standard.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: k_standard.c,v 1.6 1995/05/10 20:46:35 jtc Exp $"; -#endif - -#include <math.h> -#include "math_private.h" -#include <errno.h> - -#ifndef _IEEE_LIBM - -libm_hidden_proto(copysign) -libm_hidden_proto(matherr) -libm_hidden_proto(rint) - -#ifndef _USE_WRITE -#include <stdio.h> /* fputs(), stderr */ -#define WRITE2(u,v) fputs(u, stderr) -#else /* !defined(_USE_WRITE) */ -#include <unistd.h> /* write */ -#define WRITE2(u,v) write(2, u, v) -#undef fflush -#endif /* !defined(_USE_WRITE) */ - -#ifdef __STDC__ -static const double zero = 0.0; /* used as const */ -#else -static double zero = 0.0; /* used as const */ -#endif - -/* - * Standard conformance (non-IEEE) on exception cases. - * Mapping: - * 1 -- acos(|x|>1) - * 2 -- asin(|x|>1) - * 3 -- atan2(+-0,+-0) - * 4 -- hypot overflow - * 5 -- cosh overflow - * 6 -- exp overflow - * 7 -- exp underflow - * 8 -- y0(0) - * 9 -- y0(-ve) - * 10-- y1(0) - * 11-- y1(-ve) - * 12-- yn(0) - * 13-- yn(-ve) - * 14-- lgamma(finite) overflow - * 15-- lgamma(-integer) - * 16-- log(0) - * 17-- log(x<0) - * 18-- log10(0) - * 19-- log10(x<0) - * 20-- pow(0.0,0.0) - * 21-- pow(x,y) overflow - * 22-- pow(x,y) underflow - * 23-- pow(0,negative) - * 24-- pow(neg,non-integral) - * 25-- sinh(finite) overflow - * 26-- sqrt(negative) - * 27-- fmod(x,0) - * 28-- remainder(x,0) - * 29-- acosh(x<1) - * 30-- atanh(|x|>1) - * 31-- atanh(|x|=1) - * 32-- scalb overflow - * 33-- scalb underflow - * 34-- j0(|x|>X_TLOSS) - * 35-- y0(x>X_TLOSS) - * 36-- j1(|x|>X_TLOSS) - * 37-- y1(x>X_TLOSS) - * 38-- jn(|x|>X_TLOSS, n) - * 39-- yn(x>X_TLOSS, n) - * 40-- gamma(finite) overflow - * 41-- gamma(-integer) - * 42-- pow(NaN,0.0) - */ - - -#ifdef __STDC__ - double __kernel_standard(double x, double y, int type) -#else - double __kernel_standard(x,y,type) - double x,y; int type; -#endif -{ - struct exception exc; -#ifndef HUGE_VAL /* this is the only routine that uses HUGE_VAL */ -#define HUGE_VAL inf - double inf = 0.0; - - SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */ -#endif - -#ifdef _USE_WRITE - (void) fflush(stdout); -#endif - exc.arg1 = x; - exc.arg2 = y; - switch(type) { - case 1: - case 101: - /* acos(|x|>1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "acos" : "acosf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if(_LIB_VERSION == _SVID_) { - (void) WRITE2("acos: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 2: - case 102: - /* asin(|x|>1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "asin" : "asinf"; - exc.retval = zero; - if(_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if(_LIB_VERSION == _SVID_) { - (void) WRITE2("asin: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 3: - case 103: - /* atan2(+-0,+-0) */ - exc.arg1 = y; - exc.arg2 = x; - exc.type = DOMAIN; - exc.name = type < 100 ? "atan2" : "atan2f"; - exc.retval = zero; - if(_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if(_LIB_VERSION == _SVID_) { - (void) WRITE2("atan2: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 4: - case 104: - /* hypot(finite,finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "hypot" : "hypotf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 5: - case 105: - /* cosh(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "cosh" : "coshf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 6: - case 106: - /* exp(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "exp" : "expf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 7: - case 107: - /* exp(finite) underflow */ - exc.type = UNDERFLOW; - exc.name = type < 100 ? "exp" : "expf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 8: - case 108: - /* y0(0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "y0" : "y0f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y0: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 9: - case 109: - /* y0(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = type < 100 ? "y0" : "y0f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y0: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 10: - case 110: - /* y1(0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "y1" : "y1f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y1: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 11: - case 111: - /* y1(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = type < 100 ? "y1" : "y1f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("y1: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 12: - case 112: - /* yn(n,0) = -inf */ - exc.type = DOMAIN; /* should be SING for IEEE */ - exc.name = type < 100 ? "yn" : "ynf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("yn: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 13: - case 113: - /* yn(x<0) = NaN */ - exc.type = DOMAIN; - exc.name = type < 100 ? "yn" : "ynf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("yn: DOMAIN error\n", 17); - } - errno = EDOM; - } - break; - case 14: - case 114: - /* lgamma(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "lgamma" : "lgammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 15: - case 115: - /* lgamma(-integer) or lgamma(0) */ - exc.type = SING; - exc.name = type < 100 ? "lgamma" : "lgammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("lgamma: SING error\n", 19); - } - errno = EDOM; - } - break; - case 16: - case 116: - /* log(0) */ - exc.type = SING; - exc.name = type < 100 ? "log" : "logf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log: SING error\n", 16); - } - errno = EDOM; - } - break; - case 17: - case 117: - /* log(x<0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "log" : "logf"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log: DOMAIN error\n", 18); - } - errno = EDOM; - } - break; - case 18: - case 118: - /* log10(0) */ - exc.type = SING; - exc.name = type < 100 ? "log10" : "log10f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log10: SING error\n", 18); - } - errno = EDOM; - } - break; - case 19: - case 119: - /* log10(x<0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "log10" : "log10f"; - if (_LIB_VERSION == _SVID_) - exc.retval = -HUGE; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("log10: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 20: - case 120: - /* pow(0.0,0.0) */ - /* error only if _LIB_VERSION == _SVID_ */ - exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - exc.retval = zero; - if (_LIB_VERSION != _SVID_) exc.retval = 1.0; - else if (!matherr(&exc)) { - (void) WRITE2("pow(0,0): DOMAIN error\n", 23); - errno = EDOM; - } - break; - case 21: - case 121: - /* pow(x,y) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "pow" : "powf"; - if (_LIB_VERSION == _SVID_) { - exc.retval = HUGE; - y *= 0.5; - if(x<zero&&rint(y)!=y) exc.retval = -HUGE; - } else { - exc.retval = HUGE_VAL; - y *= 0.5; - if(x<zero&&rint(y)!=y) exc.retval = -HUGE_VAL; - } - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 22: - case 122: - /* pow(x,y) underflow */ - exc.type = UNDERFLOW; - exc.name = type < 100 ? "pow" : "powf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 23: - case 123: - /* 0**neg */ - exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - if (_LIB_VERSION == _SVID_) - exc.retval = zero; - else - exc.retval = -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("pow(0,neg): DOMAIN error\n", 25); - } - errno = EDOM; - } - break; - case 24: - case 124: - /* neg**non-integral */ - exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - if (_LIB_VERSION == _SVID_) - exc.retval = zero; - else - exc.retval = zero/zero; /* X/Open allow NaN */ - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("neg**non-integral: DOMAIN error\n", 32); - } - errno = EDOM; - } - break; - case 25: - case 125: - /* sinh(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "sinh" : "sinhf"; - if (_LIB_VERSION == _SVID_) - exc.retval = ( (x>zero) ? HUGE : -HUGE); - else - exc.retval = ( (x>zero) ? HUGE_VAL : -HUGE_VAL); - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 26: - case 126: - /* sqrt(x<0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "sqrt" : "sqrtf"; - if (_LIB_VERSION == _SVID_) - exc.retval = zero; - else - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("sqrt: DOMAIN error\n", 19); - } - errno = EDOM; - } - break; - case 27: - case 127: - /* fmod(x,0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "fmod" : "fmodf"; - if (_LIB_VERSION == _SVID_) - exc.retval = x; - else - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("fmod: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 28: - case 128: - /* remainder(x,0) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "remainder" : "remainderf"; - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("remainder: DOMAIN error\n", 24); - } - errno = EDOM; - } - break; - case 29: - case 129: - /* acosh(x<1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "acosh" : "acoshf"; - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("acosh: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 30: - case 130: - /* atanh(|x|>1) */ - exc.type = DOMAIN; - exc.name = type < 100 ? "atanh" : "atanhf"; - exc.retval = zero/zero; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("atanh: DOMAIN error\n", 20); - } - errno = EDOM; - } - break; - case 31: - case 131: - /* atanh(|x|=1) */ - exc.type = SING; - exc.name = type < 100 ? "atanh" : "atanhf"; - exc.retval = x/zero; /* sign(x)*inf */ - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("atanh: SING error\n", 18); - } - errno = EDOM; - } - break; - case 32: - case 132: - /* scalb overflow; SVID also returns +-HUGE_VAL */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "scalb" : "scalbf"; - exc.retval = x > zero ? HUGE_VAL : -HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 33: - case 133: - /* scalb underflow */ - exc.type = UNDERFLOW; - exc.name = type < 100 ? "scalb" : "scalbf"; - exc.retval = copysign(zero,x); - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 34: - case 134: - /* j0(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "j0" : "j0f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 35: - case 135: - /* y0(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "y0" : "y0f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 36: - case 136: - /* j1(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "j1" : "j1f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 37: - case 137: - /* y1(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "y1" : "y1f"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 38: - case 138: - /* jn(|x|>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "jn" : "jnf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 39: - case 139: - /* yn(x>X_TLOSS) */ - exc.type = TLOSS; - exc.name = type < 100 ? "yn" : "ynf"; - exc.retval = zero; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2(exc.name, 2); - (void) WRITE2(": TLOSS error\n", 14); - } - errno = ERANGE; - } - break; - case 40: - case 140: - /* gamma(finite) overflow */ - exc.type = OVERFLOW; - exc.name = type < 100 ? "gamma" : "gammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = ERANGE; - else if (!matherr(&exc)) { - errno = ERANGE; - } - break; - case 41: - case 141: - /* gamma(-integer) or gamma(0) */ - exc.type = SING; - exc.name = type < 100 ? "gamma" : "gammaf"; - if (_LIB_VERSION == _SVID_) - exc.retval = HUGE; - else - exc.retval = HUGE_VAL; - if (_LIB_VERSION == _POSIX_) - errno = EDOM; - else if (!matherr(&exc)) { - if (_LIB_VERSION == _SVID_) { - (void) WRITE2("gamma: SING error\n", 18); - } - errno = EDOM; - } - break; - case 42: - case 142: - /* pow(NaN,0.0) */ - /* error only if _LIB_VERSION == _SVID_ & _XOPEN_ */ - exc.type = DOMAIN; - exc.name = type < 100 ? "pow" : "powf"; - exc.retval = x; - if (_LIB_VERSION == _IEEE_ || - _LIB_VERSION == _POSIX_) exc.retval = 1.0; - else if (!matherr(&exc)) { - errno = EDOM; - } - break; - } - return exc.retval; -} -#endif /* _IEEE_LIBM */ diff --git a/libm/k_tan.c b/libm/k_tan.c index 2ba464421..65cb4a6c4 100644 --- a/libm/k_tan.c +++ b/libm/k_tan.c @@ -1,4 +1,3 @@ -/* @(#)k_tan.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: k_tan.c,v 1.8 1995/05/10 20:46:37 jtc Exp $"; -#endif - /* __kernel_tan( x, y, k ) * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 * Input x is assumed to be bounded by ~pi/4 in magnitude. @@ -51,13 +46,7 @@ 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 -#else -static double -#endif one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */ pio4lo= 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */ @@ -77,12 +66,7 @@ T[] = { 2.59073051863633712884e-05, /* 0x3EFB2A70, 0x74BF7AD4 */ }; -#ifdef __STDC__ - double attribute_hidden __kernel_tan(double x, double y, int iy) -#else - double attribute_hidden __kernel_tan(x, y, iy) - double x,y; int iy; -#endif +double __kernel_tan(double x, double y, int iy) { double z,r,v,w,s; int32_t ix,hx; diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c new file mode 100644 index 000000000..840293fe6 --- /dev/null +++ b/libm/ldouble_wrappers.c @@ -0,0 +1,453 @@ +/* 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 <features.h> +/* Prevent math.h from defining colliding inlines */ +#undef __USE_EXTERN_INLINES +#include "math.h" +#include <complex.h> + +#if !defined __NO_LONG_DOUBLE_MATH +# define WRAPPER1(func) \ +long double func##l(long double x) \ +{ \ + return (long double) func((double) x); \ +} +# define WRAPPER2(func) \ +long double func##l(long double x, long double y) \ +{ \ + return (long double) func((double) x, (double) y); \ +} +# define int_WRAPPER1(func) \ +int func##l(long double x) \ +{ \ + return func((double) x); \ +} +# define long_WRAPPER1(func) \ +long func##l(long double x) \ +{ \ + return func((double) x); \ +} +# define long_long_WRAPPER1(func) \ +long long func##l(long double x) \ +{ \ + return func((double) x); \ +} + +#ifndef __DO_XSI_MATH__ +# undef L_j0l /* long double j0l(long double x); */ +# undef L_j1l /* long double j1l(long double x); */ +# undef L_jnl /* long double jnl(int n, long double x); */ +# undef L_y0l /* long double y0l(long double x); */ +# undef L_y1l /* long double y1l(long double x); */ +# undef L_ynl /* long double ynl(int n, long double x); */ +#endif + +/* 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 cargl(long double complex); +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 +WRAPPER1(acosh) +#endif + +#ifdef L_acosl +WRAPPER1(acos) +#endif + +#ifdef L_asinhl +WRAPPER1(asinh) +#endif + +#ifdef L_asinl +WRAPPER1(asin) +#endif + +#ifdef L_atan2l +WRAPPER2(atan2) +#endif + +#ifdef L_atanhl +WRAPPER1(atanh) +#endif + +#ifdef L_atanl +WRAPPER1(atan) +#endif + +#ifdef L_cargl +long double cargl (long double complex x) +{ + return (long double) carg( (double complex)x ); +} +#endif + +#ifdef L_cbrtl +WRAPPER1(cbrt) +#endif + +#ifdef L_ceill +WRAPPER1(ceil) +#endif + +#ifdef L_copysignl +WRAPPER2(copysign) +#endif + +#ifdef L_coshl +WRAPPER1(cosh) +#endif + +#ifdef L_cosl +WRAPPER1(cos) +libm_hidden_def(cosl) +#endif + +#ifdef L_erfcl +WRAPPER1(erfc) +#endif + +#ifdef L_erfl +WRAPPER1(erf) +#endif + +#ifdef L_exp2l +WRAPPER1(exp2) +#endif + +#ifdef L_expl +WRAPPER1(exp) +libm_hidden_def(expl) +#endif + +#ifdef L_expm1l +WRAPPER1(expm1) +#endif + +#ifdef L_fabsl +WRAPPER1(fabs) +#endif + +#ifdef L_fdiml +WRAPPER2(fdim) +#endif + +#ifdef L_floorl +WRAPPER1(floor) +#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 +WRAPPER2(fmax) +#endif + +#ifdef L_fminl +WRAPPER2(fmin) +#endif + +#ifdef L_fmodl +WRAPPER2(fmod) +#endif + +#ifdef L_frexpl +long double frexpl (long double x, int *ex) +{ + return (long double) frexp( (double)x, ex ); +} +#endif + +#ifdef L_gammal +WRAPPER1(gamma) +#endif + +#ifdef L_hypotl +WRAPPER2(hypot) +libm_hidden_def(hypotl) +#endif + +#ifdef L_ilogbl +int_WRAPPER1(ilogb) +#endif + +#ifdef L_j0l + WRAPPER1(j0) +#endif + +#ifdef L_j1l + WRAPPER1(j1) +#endif + +#ifdef L_jnl +long double jnl(int n, long double x) +{ + return (long double) jn(n, (double)x); +} +#endif + +#ifdef L_ldexpl +long double ldexpl (long double x, int ex) +{ + return (long double) ldexp( (double)x, ex ); +} +#endif + +#ifdef L_lgammal +WRAPPER1(lgamma) +#endif + +#ifdef L_llrintl +long_long_WRAPPER1(llrint) +#endif + +#ifdef L_llroundl +long_long_WRAPPER1(llround) +#endif + +#ifdef L_log10l +WRAPPER1(log10) +#endif + +#ifdef L_log1pl +WRAPPER1(log1p) +#endif + +#ifdef L_log2l +WRAPPER1(log2) +#endif + +#ifdef L_logbl +WRAPPER1(logb) +#endif + +#ifdef L_logl +WRAPPER1(log) +#endif + +#ifdef L_lrintl +long_WRAPPER1(lrint) +#endif + +#ifdef L_lroundl +long_WRAPPER1(lround) +#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 +WRAPPER1(nearbyint) +#endif + +#ifdef L_nextafterl +WRAPPER2(nextafter) +libm_hidden_def(nextafterl) +#endif + +#ifdef L_nexttowardl +# if 0 /* TODO */ +strong_alias(nextafterl, nexttowardl) +# else +long double nexttowardl(long double x, long double y) +{ + return nextafterl(x, y); +} +#endif +#endif + +#ifdef L_powl +WRAPPER2(pow) +#endif + +#ifdef L_remainderl +WRAPPER2(remainder) +#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 +WRAPPER1(rint) +#endif + +#ifdef L_roundl +WRAPPER1(round) +#endif + +#ifdef L_scalblnl +long double scalblnl (long double x, long ex) +{ + return (long double) scalbln( (double)x, ex ); +} +#endif + +#ifdef L_scalbnl +long double scalbnl (long double x, int ex) +{ + return (long double) scalbn( (double)x, ex ); +} +#endif + +/* scalb is an obsolete function */ + +#ifdef L_sinhl +WRAPPER1(sinh) +#endif + +#ifdef L_sinl +WRAPPER1(sin) +libm_hidden_def(sinl) +#endif + +#ifdef L_sqrtl +WRAPPER1(sqrt) +#endif + +#ifdef L_tanhl +WRAPPER1(tanh) +#endif + +#ifdef L_tanl +WRAPPER1(tan) +#endif + +#ifdef L_tgammal +WRAPPER1(tgamma) +#endif + +#ifdef L_truncl +WRAPPER1(trunc) +#endif + +#ifdef L_significandl +WRAPPER1(significand) +#endif + +#ifdef L_y0l +WRAPPER1(y0) +#endif + +#ifdef L_y1l +WRAPPER1(y1) +#endif + +#ifdef L_ynl +long double ynl(int n, long double x) +{ + return (long double) yn(n, (double)x); +} +#endif + + +#if defined __DO_C99_MATH__ && !defined __NO_LONG_DOUBLE_MATH + +# ifdef L___fpclassifyl +int_WRAPPER1(__fpclassify) +libm_hidden_def(__fpclassifyl) +# endif + +# ifdef L___finitel +int_WRAPPER1(__finite) +libm_hidden_def(__finitel) +# endif + +# ifdef L___signbitl +int_WRAPPER1(__signbit) +libm_hidden_def(__signbitl) +# endif + +# ifdef L___isnanl +int_WRAPPER1(__isnan) +libm_hidden_def(__isnanl) +# endif + +# ifdef L___isinfl +int_WRAPPER1(__isinf) +libm_hidden_def(__isinfl) +# endif + +#endif /* __DO_C99_MATH__ */ + +#endif /* __NO_LONG_DOUBLE_MATH */ diff --git a/libm/math_private.h b/libm/math_private.h index b0d948c07..620ce9a44 100644 --- a/libm/math_private.h +++ b/libm/math_private.h @@ -9,11 +9,6 @@ * ==================================================== */ -/* - * from: @(#)fdlibm.h 5.1 93/09/24 - * $Id: math_private.h,v 1.3 2004/02/09 07:10:38 andersen Exp $ - */ - #ifndef _MATH_PRIVATE_H_ #define _MATH_PRIVATE_H_ @@ -158,17 +153,19 @@ 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; extern double __ieee754_exp (double) attribute_hidden; +extern double __ieee754_exp10 (double) attribute_hidden; extern double __ieee754_cosh (double) attribute_hidden; extern double __ieee754_fmod (double,double) attribute_hidden; extern double __ieee754_pow (double,double) attribute_hidden; extern double __ieee754_lgamma_r (double,int *) attribute_hidden; -extern double __ieee754_gamma_r (double,int *) attribute_hidden; +/*extern double __ieee754_gamma_r (double,int *) attribute_hidden;*/ extern double __ieee754_lgamma (double) attribute_hidden; -extern double __ieee754_gamma (double) attribute_hidden; +/*extern double __ieee754_gamma (double) attribute_hidden;*/ extern double __ieee754_log10 (double) attribute_hidden; extern double __ieee754_sinh (double) attribute_hidden; extern double __ieee754_hypot (double,double) attribute_hidden; @@ -180,19 +177,81 @@ extern double __ieee754_jn (int,double) attribute_hidden; extern double __ieee754_yn (int,double) attribute_hidden; extern double __ieee754_remainder (double,double) attribute_hidden; extern int __ieee754_rem_pio2 (double,double*) attribute_hidden; -#if defined(_SCALB_INT) -extern double __ieee754_scalb (double,int) attribute_hidden; -#else extern double __ieee754_scalb (double,double) attribute_hidden; -#endif /* fdlibm kernel function */ -#ifndef _IEEE_LIBM -extern double __kernel_standard (double,double,int) attribute_hidden; -#endif extern double __kernel_sin (double,double,int) attribute_hidden; extern double __kernel_cos (double,double) attribute_hidden; extern double __kernel_tan (double,double,int) attribute_hidden; extern int __kernel_rem_pio2 (double*,double*,int,int,int,const int*) attribute_hidden; +/* + * math_opt_barrier(x): safely load x, even if it was manipulated + * by non-floationg point operations. This macro returns the value of x. + * This ensures compiler does not (ab)use its knowledge about x value + * and don't optimize future operations. Example: + * float x; + * SET_FLOAT_WORD(x, 0x80000001); // sets a bit pattern + * y = math_opt_barrier(x); // "compiler, do not cheat!" + * y = y * y; // compiler can't optimize, must use real multiply insn + * + * math_force_eval(x): force expression x to be evaluated. + * Useful if otherwise compiler may eliminate the expression + * as unused. This macro returns no value. + * Example: "void fn(float f) { f = f * f; }" + * versus "void fn(float f) { f = f * f; math_force_eval(f); }" + * + * Currently, math_force_eval(x) stores x into + * a floating point register or memory *of the appropriate size*. + * There is no guarantee this will not change. + */ +#if defined(__i386__) +#define math_opt_barrier(x) ({ \ + __typeof(x) __x = (x); \ + /* "t": load x into top-of-stack fpreg */ \ + __asm__ ("" : "=t" (__x) : "0" (__x)); \ + __x; \ +}) +#define math_force_eval(x) do { \ + __typeof(x) __x = (x); \ + if (sizeof(__x) <= sizeof(double)) \ + /* "m": store x into a memory location */ \ + __asm__ __volatile__ ("" : : "m" (__x)); \ + else /* long double */ \ + /* "f": load x into (any) fpreg */ \ + __asm__ __volatile__ ("" : : "f" (__x)); \ +} while (0) +#endif + +#if defined(__x86_64__) +#define math_opt_barrier(x) ({ \ + __typeof(x) __x = (x); \ + if (sizeof(__x) <= sizeof(double)) \ + /* "x": load into XMM SSE register */ \ + __asm__ ("" : "=x" (__x) : "0" (__x)); \ + else /* long double */ \ + /* "t": load x into top-of-stack fpreg */ \ + __asm__ ("" : "=t" (__x) : "0" (__x)); \ + __x; \ +}) +#define math_force_eval(x) do { \ + __typeof(x) __x = (x); \ + if (sizeof(__x) <= sizeof(double)) \ + /* "x": load into XMM SSE register */ \ + __asm__ __volatile__ ("" : : "x" (__x)); \ + else /* long double */ \ + /* "f": load x into (any) fpreg */ \ + __asm__ __volatile__ ("" : : "f" (__x)); \ +} while (0) +#endif + +/* Default implementations force store to a memory location */ +#ifndef math_opt_barrier +#define math_opt_barrier(x) ({ __typeof(x) __x = (x); __asm__ ("" : "+m" (__x)); __x; }) +#endif +#ifndef math_force_eval +#define math_force_eval(x) do { __typeof(x) __x = (x); __asm__ __volatile__ ("" : : "m" (__x)); } while (0) +#endif + + #endif /* _MATH_PRIVATE_H_ */ diff --git a/libm/metag/Makefile.arch b/libm/metag/Makefile.arch new file mode 100644 index 000000000..bcae0e27a --- /dev/null +++ b/libm/metag/Makefile.arch @@ -0,0 +1,23 @@ +# Makefile for uClibc +# +# Copyright (c) 2013 Imagination Technologies Ltd. +# +# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. +# + +ifeq ($(UCLIBC_HAS_FENV),y) +ifeq ($(CONFIG_META_2_1),y) +libm_ARCH_SRC:=$(wildcard $(libm_ARCH_DIR)/*.c) +libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_DIR)/%.c,$(libm_ARCH_OUT)/%.o,$(libm_ARCH_SRC)) +CFLAGS-y-libm/metag := -Wa,-mfpu=metac21 +endif +endif + +libm_ARCH_OBJS:=$(libm_ARCH_OBJ) + +ifeq ($(DOPIC),y) +libm-a-y+=$(libm_ARCH_OBJS:.o=.os) +else +libm-a-y+=$(libm_ARCH_OBJS) +endif +libm-so-y+=$(libm_ARCH_OBJS:.o=.os) diff --git a/libm/metag/fclrexcpt.c b/libm/metag/fclrexcpt.c new file mode 100644 index 000000000..10bdc870b --- /dev/null +++ b/libm/metag/fclrexcpt.c @@ -0,0 +1,44 @@ +/* Clear given exceptions in current floating-point environment. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +#include "internal.h" + +int +feclearexcept (int excepts) +{ + unsigned int temp; + + /* Get the current exceptions. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (temp)); + + /* Mask out unsupported bits/exceptions. */ + excepts &= FE_ALL_EXCEPT; + + excepts <<= 16; + + temp &= ~excepts; + + metag_set_fpu_flags(temp); + + /* Success. */ + return 0; +} diff --git a/libm/metag/fedisblxcpt.c b/libm/metag/fedisblxcpt.c new file mode 100644 index 000000000..07313fa9b --- /dev/null +++ b/libm/metag/fedisblxcpt.c @@ -0,0 +1,40 @@ +/* Disable floating-point exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +#include "internal.h" + +int +fedisableexcept (int excepts) +{ + unsigned int old_exc; + + /* Get the current control word. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (old_exc)); + + old_exc &= FE_ALL_EXCEPT; + + excepts = old_exc & ~excepts; + + metag_set_fpu_flags(excepts); + + return old_exc; +} diff --git a/libm/metag/feenablxcpt.c b/libm/metag/feenablxcpt.c new file mode 100644 index 000000000..8feb9641c --- /dev/null +++ b/libm/metag/feenablxcpt.c @@ -0,0 +1,40 @@ +/* Enable floating-point exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +#include "internal.h" + +int +feenableexcept (int excepts) +{ + unsigned int old_exc; + + /* Get the current control word. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (old_exc)); + + old_exc &= FE_ALL_EXCEPT; + + excepts |= old_exc; + + metag_set_fpu_flags(excepts); + + return old_exc; +} diff --git a/libm/metag/fegetenv.c b/libm/metag/fegetenv.c new file mode 100644 index 000000000..c932514c2 --- /dev/null +++ b/libm/metag/fegetenv.c @@ -0,0 +1,36 @@ +/* Store current floating-point environment. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> + +int +fegetenv (fenv_t *envp) +{ + unsigned int txdefr; + unsigned int txmode; + + __asm__ ("MOV %0,TXDEFR" : "=r" (txdefr)); + __asm__ ("MOV %0,TXMODE" : "=r" (txmode)); + + envp->txdefr = txdefr; + envp->txmode = txmode; + + /* Success. */ + return 0; +} diff --git a/libm/metag/fegetexcept.c b/libm/metag/fegetexcept.c new file mode 100644 index 000000000..8021f6c78 --- /dev/null +++ b/libm/metag/fegetexcept.c @@ -0,0 +1,31 @@ +/* Get enabled floating-point exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> + +int +fegetexcept (void) +{ + unsigned int exc; + + /* Get the current control word. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (exc)); + + return exc & FE_ALL_EXCEPT; +} diff --git a/libm/metag/fegetround.c b/libm/metag/fegetround.c new file mode 100644 index 000000000..1fb5ce2b1 --- /dev/null +++ b/libm/metag/fegetround.c @@ -0,0 +1,30 @@ +/* Return current rounding direction. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> + +int +fegetround (void) +{ + unsigned int txmode; + + __asm__ ("MOV %0,TXMODE" : "=r" (txmode)); + + return (txmode >> 16) & 0x3; +} diff --git a/libm/metag/feholdexcpt.c b/libm/metag/feholdexcpt.c new file mode 100644 index 000000000..98ef4d097 --- /dev/null +++ b/libm/metag/feholdexcpt.c @@ -0,0 +1,41 @@ +/* Store current floating-point environment and clear exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +#include "internal.h" + +int +feholdexcept (fenv_t *envp) +{ + unsigned int txdefr; + unsigned int txmode; + + __asm__ ("MOV %0,TXDEFR" : "=r" (txdefr)); + __asm__ ("MOV %0,TXMODE" : "=r" (txmode)); + + envp->txdefr = txdefr; + envp->txmode = txmode; + + metag_set_fpu_flags(0); + + return 0; +} diff --git a/libm/metag/fesetenv.c b/libm/metag/fesetenv.c new file mode 100644 index 000000000..7295492b8 --- /dev/null +++ b/libm/metag/fesetenv.c @@ -0,0 +1,60 @@ +/* Install given floating-point environment. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <assert.h> + +#include "internal.h" + +libm_hidden_proto(fesetenv) + +int +fesetenv (const fenv_t *envp) +{ + unsigned int exc; + unsigned int txmode; + + __asm__ ("MOV %0,TXMODE" : "=r" (txmode)); + + /* Clear rounding mode bits (round to nearest). */ + txmode &= ~(0x3 << 16); + + if (envp == FE_DFL_ENV) + { + exc = 0; + } + else if (envp == FE_NOMASK_ENV) + { + exc = 0x1f; + } + else + { + exc = envp->txdefr & (FE_ALL_EXCEPT | (FE_ALL_EXCEPT << 16)); + /* Write rounding mode and guard bit. */ + txmode |= (0x1 << 18 ) | (envp->txmode & (0x3 << 16)); + } + + __asm__ ("MOV TXMODE,%0" : : "r" (txmode)); + + metag_set_fpu_flags(exc); + + /* Success. */ + return 0; +} +libm_hidden_def(fesetenv) diff --git a/libm/metag/fesetround.c b/libm/metag/fesetround.c new file mode 100644 index 000000000..2d5b2526f --- /dev/null +++ b/libm/metag/fesetround.c @@ -0,0 +1,41 @@ +/* Set current rounding direction. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +int +fesetround (int round) +{ + unsigned int txmode; + + if ((round & ~0x3) != 0) + /* ROUND is no valid rounding mode. */ + return 1; + + __asm__ ("MOV %0,TXMODE" : "=r" (txmode)); + + txmode &= ~(0x3 << 16); + /* Write rounding mode and guard bit. */ + txmode |= (0x1 << 18 ) | (round << 16); + + __asm__ ("MOV TXMODE,%0" : : "r" (txmode)); + + return 0; +} diff --git a/libm/metag/feupdateenv.c b/libm/metag/feupdateenv.c new file mode 100644 index 000000000..f2fc69f54 --- /dev/null +++ b/libm/metag/feupdateenv.c @@ -0,0 +1,45 @@ +/* Install given floating-point environment and raise exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +libm_hidden_proto(fesetenv) +libm_hidden_proto(feraiseexcept) + +int +feupdateenv (const fenv_t *envp) +{ + unsigned int temp; + + /* Save current exceptions. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (temp)); + + temp >>= 16; + temp &= FE_ALL_EXCEPT; + + /* Install new environment. */ + fesetenv (envp); + + /* Raise the saved exception. */ + feraiseexcept ((int) temp); + + /* Success. */ + return 0; +} diff --git a/libm/metag/fgetexcptflg.c b/libm/metag/fgetexcptflg.c new file mode 100644 index 000000000..e1a4bdfaa --- /dev/null +++ b/libm/metag/fgetexcptflg.c @@ -0,0 +1,34 @@ +/* Store current representation for exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> + +int +fegetexceptflag (fexcept_t *flagp, int excepts) +{ + unsigned int temp; + + /* Get the current exceptions. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (temp)); + + *flagp = temp & excepts & FE_ALL_EXCEPT; + + /* Success. */ + return 0; +} diff --git a/libm/metag/fraiseexcpt.c b/libm/metag/fraiseexcpt.c new file mode 100644 index 000000000..9ab39bbf6 --- /dev/null +++ b/libm/metag/fraiseexcpt.c @@ -0,0 +1,92 @@ +/* Raise given exceptions. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <math.h> + +libm_hidden_proto(feraiseexcept) + +int +feraiseexcept (int excepts) +{ + /* Raise exceptions represented by EXPECTS. But we must raise only + one signal at a time. It is important that if the overflow/underflow + exception and the inexact exception are given at the same time, + the overflow/underflow exception follows the inexact exception. */ + + /* First: invalid exception. */ + if ((FE_INVALID & excepts) != 0) + { + /* Reciprocal square root of a negative number is invalid. */ + __asm__ volatile( + "F MOV FX.0,#0xc000 ! -2\n" + "F RSQ FX.1,FX.0\n" + ); + } + + /* Next: division by zero. */ + if ((FE_DIVBYZERO & excepts) != 0) + { + __asm__ volatile( + "F MOV FX.0,#0\n" + "F RCP FX.1,FX.0\n" + ); + } + + /* Next: overflow. */ + if ((FE_OVERFLOW & excepts) != 0) + { + /* Adding a large number in single precision can cause overflow. */ + __asm__ volatile( + " MOVT D0.0,#0x7f7f\n" + " ADD D0.0,D0.0,#0xffff\n" + "F MOV FX.0,D0.0\n" + "F ADD FX.1,FX.0,FX.0\n" + ); + } + + /* Next: underflow. */ + if ((FE_UNDERFLOW & excepts) != 0) + { + /* Multiplying a small value by 0.5 will cause an underflow. */ + __asm__ volatile( + " MOV D0.0,#1\n" + "F MOV FX.0,D0.0\n" + " MOVT D0.0,#0x3f00\n" + "F MOV FX.1,D0.0\n" + "F MUL FX.2,FX.1,FX.0\n" + ); + } + + /* Last: inexact. */ + if ((FE_INEXACT & excepts) != 0) + { + /* Converting a small single precision value to half precision + can cause an inexact exception. */ + __asm__ volatile( + " MOV D0.0,#0x0001\n" + "F MOV FX.0,D0.0\n" + "F FTOH FX.1,FX.0\n" + ); + } + + /* Success. */ + return 0; +} +libm_hidden_def(feraiseexcept) diff --git a/libm/metag/fsetexcptflg.c b/libm/metag/fsetexcptflg.c new file mode 100644 index 000000000..11ae917e5 --- /dev/null +++ b/libm/metag/fsetexcptflg.c @@ -0,0 +1,44 @@ +/* Set floating-point environment exception handling. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <math.h> +#include <unistd.h> + +#include "internal.h" + +int +fesetexceptflag (const fexcept_t *flagp, int excepts) +{ + unsigned int temp; + + /* Get the current exceptions. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (temp)); + + excepts &= FE_ALL_EXCEPT; + excepts <<= 16; + + temp &= ~excepts; + temp |= *flagp & excepts; + + metag_set_fpu_flags(temp); + + /* Success. */ + return 0; +} diff --git a/libm/metag/ftestexcept.c b/libm/metag/ftestexcept.c new file mode 100644 index 000000000..898630d14 --- /dev/null +++ b/libm/metag/ftestexcept.c @@ -0,0 +1,32 @@ +/* Test exception in current environment. + Copyright (C) 2013 Imagination Technologies Ltd. + This file is part of the GNU C Library. + + 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 <fenv.h> +#include <unistd.h> + +int +fetestexcept (int excepts) +{ + unsigned int temp; + + /* Get the current exceptions. */ + __asm__ ("MOV %0,TXDEFR" : "=r" (temp)); + + return (temp >> 16) & excepts & FE_ALL_EXCEPT; +} diff --git a/libm/metag/internal.h b/libm/metag/internal.h new file mode 100644 index 000000000..77297727b --- /dev/null +++ b/libm/metag/internal.h @@ -0,0 +1,7 @@ +/* + * Copyright (C) 2013 Imagination Technologies Ltd. + * + * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball. + */ + +void metag_set_fpu_flags(unsigned int flags); diff --git a/libm/nan.c b/libm/nan.c index 16e5c1772..eee3b1cc4 100644 --- a/libm/nan.c +++ b/libm/nan.c @@ -31,7 +31,9 @@ double nan (const char *tagp) } return NAN; } +libm_hidden_def(nan) +libm_hidden_proto(nanf) float nanf (const char *tagp) { if (tagp[0] != '\0') { @@ -41,8 +43,10 @@ float nanf (const char *tagp) } return NAN; } +libm_hidden_def(nanf) -#if 0 +#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH +libm_hidden_proto(nanl) long double nanl (const char *tagp) { if (tagp[0] != '\0') { @@ -52,4 +56,5 @@ long double nanl (const char *tagp) } return NAN; } +libm_hidden_def(nanl) #endif diff --git a/libm/powerpc/classic/Makefile.arch b/libm/powerpc/classic/Makefile.arch index 7c7600f80..53c6d2cac 100644 --- a/libm/powerpc/classic/Makefile.arch +++ b/libm/powerpc/classic/Makefile.arch @@ -5,8 +5,8 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -libm_ARCH_SRC:=$(wildcard $(libm_ARCH_DIR)/*.c) -libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_DIR)/%.c,$(libm_ARCH_OUT)/%.o,$(libm_ARCH_SRC)) +libm_ARCH_SRC:=$(wildcard $(libm_SUBARCH_DIR)/*.c) +libm_ARCH_OBJ:=$(patsubst $(libm_SUBARCH_DIR)/%.c,$(libm_SUBARCH_OUT)/%.o,$(libm_ARCH_SRC)) libm_ARCH_OBJS:=$(libm_ARCH_OBJ) 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/powerpc/e500/Makefile.arch b/libm/powerpc/e500/Makefile.arch index bec21caef..febde67be 100644 --- a/libm/powerpc/e500/Makefile.arch +++ b/libm/powerpc/e500/Makefile.arch @@ -5,5 +5,7 @@ # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # +libm_ARCH_fpu_DIR := $(libm_SUBARCH_DIR)/fpu +libm_ARCH_fpu_OUT := $(libm_SUBARCH_OUT)/fpu -include $(libm_ARCH_fpu_DIR)/Makefile.arch diff --git a/libm/powerpc/e500/fpu/Makefile.arch b/libm/powerpc/e500/fpu/Makefile.arch index 8f00e0916..904561e91 100644 --- a/libm/powerpc/e500/fpu/Makefile.arch +++ b/libm/powerpc/e500/fpu/Makefile.arch @@ -6,8 +6,10 @@ # +ifeq ($(UCLIBC_HAS_FENV),y) libm_ARCH_SRC:=$(wildcard $(libm_ARCH_fpu_DIR)/*.c) libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_fpu_DIR)/%.c,$(libm_ARCH_fpu_OUT)/%.o,$(libm_ARCH_SRC)) +endif libm_ARCH_OBJS:=$(libm_ARCH_OBJ) diff --git a/libm/powerpc/e500/fpu/fclrexcpt.c b/libm/powerpc/e500/fpu/fclrexcpt.c index 42e8b6bab..805aaa487 100644 --- a/libm/powerpc/e500/fpu/fclrexcpt.c +++ b/libm/powerpc/e500/fpu/fclrexcpt.c @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #undef feclearexcept diff --git a/libm/powerpc/e500/fpu/fe_nomask.c b/libm/powerpc/e500/fpu/fe_nomask.c index ad7b324c0..d5915165c 100644 --- a/libm/powerpc/e500/fpu/fe_nomask.c +++ b/libm/powerpc/e500/fpu/fe_nomask.c @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <fenv.h> #include <errno.h> diff --git a/libm/powerpc/e500/fpu/fedisblxcpt.c b/libm/powerpc/e500/fpu/fedisblxcpt.c index aeca87bc6..0700f4577 100644 --- a/libm/powerpc/e500/fpu/fedisblxcpt.c +++ b/libm/powerpc/e500/fpu/fedisblxcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #include <syscall.h> diff --git a/libm/powerpc/e500/fpu/feenablxcpt.c b/libm/powerpc/e500/fpu/feenablxcpt.c index 999fdd734..9f03181f4 100644 --- a/libm/powerpc/e500/fpu/feenablxcpt.c +++ b/libm/powerpc/e500/fpu/feenablxcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #include <syscall.h> diff --git a/libm/powerpc/e500/fpu/fegetenv.c b/libm/powerpc/e500/fpu/fegetenv.c index fbafdc208..c1a914dc3 100644 --- a/libm/powerpc/e500/fpu/fegetenv.c +++ b/libm/powerpc/e500/fpu/fegetenv.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #include <syscall.h> diff --git a/libm/powerpc/e500/fpu/fegetexcept.c b/libm/powerpc/e500/fpu/fegetexcept.c index c0398461c..bf0215d62 100644 --- a/libm/powerpc/e500/fpu/fegetexcept.c +++ b/libm/powerpc/e500/fpu/fegetexcept.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/fpu/fegetround.c b/libm/powerpc/e500/fpu/fegetround.c index 6e568fa23..f501c6ce8 100644 --- a/libm/powerpc/e500/fpu/fegetround.c +++ b/libm/powerpc/e500/fpu/fegetround.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/fpu/feholdexcpt.c b/libm/powerpc/e500/fpu/feholdexcpt.c index eccde4217..edeb2cf81 100644 --- a/libm/powerpc/e500/fpu/feholdexcpt.c +++ b/libm/powerpc/e500/fpu/feholdexcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #include <syscall.h> diff --git a/libm/powerpc/e500/fpu/fenv_const.c b/libm/powerpc/e500/fpu/fenv_const.c index 073fc9277..3c9f5578a 100644 --- a/libm/powerpc/e500/fpu/fenv_const.c +++ b/libm/powerpc/e500/fpu/fenv_const.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ /* If the default argument is used we use this value. */ const unsigned long long __fe_dfl_env __attribute__ ((aligned (8))) = diff --git a/libm/powerpc/e500/fpu/fenv_libc.h b/libm/powerpc/e500/fpu/fenv_libc.h index 22c3f1452..0926fca37 100644 --- a/libm/powerpc/e500/fpu/fenv_libc.h +++ b/libm/powerpc/e500/fpu/fenv_libc.h @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #ifndef _FENV_LIBC_H #define _FENV_LIBC_H 1 diff --git a/libm/powerpc/e500/fpu/fesetenv.c b/libm/powerpc/e500/fpu/fesetenv.c index cc0cc18be..392e0c0bf 100644 --- a/libm/powerpc/e500/fpu/fesetenv.c +++ b/libm/powerpc/e500/fpu/fesetenv.c @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #include <syscall.h> diff --git a/libm/powerpc/e500/fpu/fesetround.c b/libm/powerpc/e500/fpu/fesetround.c index 0f29a91a6..783541d5b 100644 --- a/libm/powerpc/e500/fpu/fesetround.c +++ b/libm/powerpc/e500/fpu/fesetround.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/fpu/feupdateenv.c b/libm/powerpc/e500/fpu/feupdateenv.c index 03f3af8d9..47f316318 100644 --- a/libm/powerpc/e500/fpu/feupdateenv.c +++ b/libm/powerpc/e500/fpu/feupdateenv.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" #include <syscall.h> diff --git a/libm/powerpc/e500/fpu/fgetexcptflg.c b/libm/powerpc/e500/fpu/fgetexcptflg.c index 62d7f2c32..d27356574 100644 --- a/libm/powerpc/e500/fpu/fgetexcptflg.c +++ b/libm/powerpc/e500/fpu/fgetexcptflg.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/fpu/fraiseexcpt.c b/libm/powerpc/e500/fpu/fraiseexcpt.c index 39caf79d3..0c92b2868 100644 --- a/libm/powerpc/e500/fpu/fraiseexcpt.c +++ b/libm/powerpc/e500/fpu/fraiseexcpt.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/fpu/fsetexcptflg.c b/libm/powerpc/e500/fpu/fsetexcptflg.c index 8e4bb895d..11ea89f16 100644 --- a/libm/powerpc/e500/fpu/fsetexcptflg.c +++ b/libm/powerpc/e500/fpu/fsetexcptflg.c @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/fpu/ftestexcept.c b/libm/powerpc/e500/fpu/ftestexcept.c index 971c51965..55f752b25 100644 --- a/libm/powerpc/e500/fpu/ftestexcept.c +++ b/libm/powerpc/e500/fpu/ftestexcept.c @@ -14,9 +14,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fenv_libc.h" diff --git a/libm/powerpc/e500/spe-raise.c b/libm/powerpc/e500/spe-raise.c index b83087fd0..42b1598bd 100644 --- a/libm/powerpc/e500/spe-raise.c +++ b/libm/powerpc/e500/spe-raise.c @@ -13,9 +13,8 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include "fpu/fenv_libc.h" diff --git a/libm/s_asinh.c b/libm/s_asinh.c index 9e9a05660..7c79d6828 100644 --- a/libm/s_asinh.c +++ b/libm/s_asinh.c @@ -1,4 +1,3 @@ -/* @(#)s_asinh.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_asinh.c,v 1.9 1995/05/12 04:57:37 jtc Exp $"; -#endif - /* asinh(x) * Method : * Based on @@ -28,25 +23,12 @@ 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 -#else -static double -#endif 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 - double asinh(x) - double x; -#endif +double asinh(double x) { double t,w; int32_t hx,ix; diff --git a/libm/s_atan.c b/libm/s_atan.c index 9c8035569..08cfb08e8 100644 --- a/libm/s_atan.c +++ b/libm/s_atan.c @@ -1,4 +1,3 @@ -/* @(#)s_atan.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_atan.c,v 1.8 1995/05/10 20:46:45 jtc Exp $"; -#endif - /* atan(x) * Method * 1. Reduce x to positive by atan(x) = -atan(-x). @@ -37,35 +32,21 @@ 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[] = { -#else -static double atanhi[] = { -#endif 4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */ 7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */ 9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */ 1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */ }; -#ifdef __STDC__ static const double atanlo[] = { -#else -static double atanlo[] = { -#endif 2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */ 3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */ 1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */ 6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */ }; -#ifdef __STDC__ static const double aT[] = { -#else -static double aT[] = { -#endif 3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */ -1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */ 1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */ @@ -79,21 +60,11 @@ static double aT[] = { 1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */ }; -libm_hidden_proto(atan) -#ifdef __STDC__ - static const double -#else - static double -#endif +static const double one = 1.0, huge = 1.0e300; -#ifdef __STDC__ - double atan(double x) -#else - double atan(x) - double x; -#endif +double atan(double x) { double w,s1,s2,z; int32_t ix,hx,id; diff --git a/libm/s_cbrt.c b/libm/s_cbrt.c index f4635874c..14e8ab02f 100644 --- a/libm/s_cbrt.c +++ b/libm/s_cbrt.c @@ -1,4 +1,3 @@ -/* @(#)s_cbrt.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,42 +9,24 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_cbrt.c,v 1.8 1995/05/10 20:46:49 jtc Exp $"; -#endif - #include "math.h" #include "math_private.h" /* cbrt(x) * Return cube root of x */ -#ifdef __STDC__ static const u_int32_t -#else -static u_int32_t -#endif B1 = 715094163, /* B1 = (682-0.03306235651)*2**20 */ B2 = 696219795; /* B2 = (664-0.03306235651)*2**20 */ -#ifdef __STDC__ static const double -#else -static double -#endif C = 5.42857142857142815906e-01, /* 19/35 = 0x3FE15F15, 0xF15F15F1 */ D = -7.05306122448979611050e-01, /* -864/1225 = 0xBFE691DE, 0x2532C834 */ 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 - double cbrt(x) - double x; -#endif +double cbrt(double x) { int32_t hx; double r,s,t=0.0,w; diff --git a/libm/s_ceil.c b/libm/s_ceil.c index 46839410e..edbf9346f 100644 --- a/libm/s_ceil.c +++ b/libm/s_ceil.c @@ -1,4 +1,3 @@ -/* @(#)s_ceil.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_ceil.c,v 1.8 1995/05/10 20:46:53 jtc Exp $"; -#endif - /* * ceil(x) * Return x rounded toward -inf to integral value @@ -23,52 +18,45 @@ static char rcsid[] = "$NetBSD: s_ceil.c,v 1.8 1995/05/10 20:46:53 jtc Exp $"; * Inexact flag raised if x not equal to ceil(x). */ +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double huge = 1.0e300; -#else -static double huge = 1.0e300; -#endif -libm_hidden_proto(ceil) -#ifdef __STDC__ - double ceil(double x) -#else - double ceil(x) - double x; -#endif +double ceil(double x) { - int32_t i0,i1,j0; + int32_t i0,i1,_j0; u_int32_t i,j; EXTRACT_WORDS(i0,i1,x); - j0 = ((i0>>20)&0x7ff)-0x3ff; - if(j0<20) { - if(j0<0) { /* raise inexact if x != 0 */ + _j0 = ((i0>>20)&0x7ff)-0x3ff; + if(_j0<20) { + if(_j0<0) { /* raise inexact if x != 0 */ if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ if(i0<0) {i0=0x80000000;i1=0;} else if((i0|i1)!=0) { i0=0x3ff00000;i1=0;} } } else { - i = (0x000fffff)>>j0; + i = (0x000fffff)>>_j0; if(((i0&i)|i1)==0) return x; /* x is integral */ if(huge+x>0.0) { /* raise inexact flag */ - if(i0>0) i0 += (0x00100000)>>j0; + if(i0>0) i0 += (0x00100000)>>_j0; i0 &= (~i); i1=0; } } - } else if (j0>51) { - if(j0==0x400) return x+x; /* inf or NaN */ + } else if (_j0>51) { + if(_j0==0x400) return x+x; /* inf or NaN */ else return x; /* x is integral */ } else { - i = ((u_int32_t)(0xffffffff))>>(j0-20); + i = ((u_int32_t)(0xffffffff))>>(_j0-20); if((i1&i)==0) return x; /* x is integral */ if(huge+x>0.0) { /* raise inexact flag */ if(i0>0) { - if(j0==20) i0+=1; + if(_j0==20) i0+=1; else { - j = i1 + (1<<(52-j0)); + j = i1 + (1<<(52-_j0)); if(j<i1) i0+=1; /* got a carry */ i1 = j; } diff --git a/libm/s_copysign.c b/libm/s_copysign.c index 145a26cc1..33e153167 100644 --- a/libm/s_copysign.c +++ b/libm/s_copysign.c @@ -1,4 +1,3 @@ -/* @(#)s_copysign.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $"; -#endif - /* * copysign(double x, double y) * copysign(x,y) returns a value with the magnitude of x and @@ -23,13 +18,7 @@ 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 - double copysign(x,y) - double x,y; -#endif +double copysign(double x, double y) { u_int32_t hx,hy; GET_HIGH_WORD(hx,x); diff --git a/libm/s_cos.c b/libm/s_cos.c index f05a8a53b..c4b1f8643 100644 --- a/libm/s_cos.c +++ b/libm/s_cos.c @@ -1,4 +1,3 @@ -/* @(#)s_cos.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_cos.c,v 1.7 1995/05/10 20:47:02 jtc Exp $"; -#endif - /* cos(x) * Return cosine function of x. * @@ -48,13 +43,7 @@ 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 - double cos(x) - double x; -#endif +double cos(double x) { double y[2],z=0.0; int32_t n, ix; diff --git a/libm/s_erf.c b/libm/s_erf.c index 0d24e2174..27083d240 100644 --- a/libm/s_erf.c +++ b/libm/s_erf.c @@ -1,4 +1,3 @@ -/* @(#)s_erf.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $"; -#endif - /* double erf(double x) * double erfc(double x) * x @@ -108,17 +103,10 @@ static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $"; * erfc/erf(NaN) is NaN */ - #include "math.h" #include "math_private.h" -libm_hidden_proto(fabs) - -#ifdef __STDC__ static const double -#else -static double -#endif tiny = 1e-300, half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */ one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ @@ -193,13 +181,7 @@ 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 - double erf(x) - double x; -#endif +double erf(double x) { int32_t hx,ix,i; double R,S,P,Q,s,y,z,r; @@ -251,13 +233,7 @@ libm_hidden_proto(erf) } libm_hidden_def(erf) -libm_hidden_proto(erfc) -#ifdef __STDC__ - double erfc(double x) -#else - double erfc(x) - double x; -#endif +double erfc(double x) { int32_t hx,ix; double R,S,P,Q,s,y,z,r; diff --git a/libm/s_expm1.c b/libm/s_expm1.c index 2adeead0b..8e51ae748 100644 --- a/libm/s_expm1.c +++ b/libm/s_expm1.c @@ -1,4 +1,3 @@ -/* @(#)s_expm1.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $"; -#endif - /* expm1(x) * Returns exp(x)-1, the exponential of x minus 1. * @@ -112,11 +107,7 @@ static char rcsid[] = "$NetBSD: s_expm1.c,v 1.8 1995/05/10 20:47:09 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif one = 1.0, huge = 1.0e+300, tiny = 1.0e-300, @@ -131,13 +122,7 @@ 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 - double expm1(x) - double x; -#endif +double expm1(double x) { double y,hi,lo,c=0.0,t,e,hxs,hfx,r1; int32_t k,xsb; diff --git a/libm/s_fabs.c b/libm/s_fabs.c index c1538ca9e..d2c647ff3 100644 --- a/libm/s_fabs.c +++ b/libm/s_fabs.c @@ -1,4 +1,3 @@ -/* @(#)s_fabs.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,24 +9,17 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_fabs.c,v 1.7 1995/05/10 20:47:13 jtc Exp $"; -#endif - /* * fabs(x) returns the absolute value of x. */ +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES #include "math.h" #include "math_private.h" -libm_hidden_proto(fabs) -#ifdef __STDC__ - double fabs(double x) -#else - double fabs(x) - double x; -#endif +double fabs(double x) { u_int32_t high; GET_HIGH_WORD(high,x); diff --git a/libm/s_fdim.c b/libm/s_fdim.c new file mode 100644 index 000000000..6ed695c3d --- /dev/null +++ b/libm/s_fdim.c @@ -0,0 +1,27 @@ +/* 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" +#include <errno.h> + +double fdim(double x, double y) +{ + int cx = __fpclassify(x); /* need both NAN and INF */ + int cy = __fpclassify(y); /* need both NAN and INF */ + if (cx == FP_NAN || cy == NAN) + return x - y; + + if (x <= y) + return .0; + + double z = x - y; + if (isinf(z) && cx != FP_INFINITE && cy != FP_INFINITE) + __set_errno(ERANGE); + + return z; +} +libm_hidden_def(fdim) diff --git a/libm/s_finite.c b/libm/s_finite.c index 70b9aadc4..9bbc00286 100644 --- a/libm/s_finite.c +++ b/libm/s_finite.c @@ -1,4 +1,3 @@ -/* @(#)s_finite.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,29 +9,24 @@ * ==================================================== */ -#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! */ +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES #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); + u_int32_t hx; + + GET_HIGH_WORD(hx, x); + /* Finite numbers have at least one zero bit in exponent. */ + /* All other numbers will result in 0xffffffff after OR: */ + return (hx | 0x800fffff) != 0xffffffff; } -libm_hidden_proto(finite) -strong_alias(__finite,finite) -libm_hidden_def(finite) +libm_hidden_def(__finite) diff --git a/libm/s_finitef.c b/libm/s_finitef.c new file mode 100644 index 000000000..b427ea691 --- /dev/null +++ b/libm/s_finitef.c @@ -0,0 +1,33 @@ +/* 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" + +int __finitef(float x) +{ + u_int32_t ix; + + GET_FLOAT_WORD(ix, x); + /* Finite numbers have at least one zero bit in exponent. */ + /* All other numbers will result in 0xffffffff after OR: */ + return (ix | 0x807fffff) != 0xffffffff; +} +libm_hidden_def(__finitef) diff --git a/libm/s_floor.c b/libm/s_floor.c index 39b24c05b..21d9821e4 100644 --- a/libm/s_floor.c +++ b/libm/s_floor.c @@ -1,4 +1,3 @@ -/* @(#)s_floor.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_floor.c,v 1.8 1995/05/10 20:47:20 jtc Exp $"; -#endif - /* * floor(x) * Return x rounded toward -inf to integral value @@ -23,53 +18,46 @@ static char rcsid[] = "$NetBSD: s_floor.c,v 1.8 1995/05/10 20:47:20 jtc Exp $"; * Inexact flag raised if x not equal to floor(x). */ +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double huge = 1.0e300; -#else -static double huge = 1.0e300; -#endif -libm_hidden_proto(floor) -#ifdef __STDC__ - double floor(double x) -#else - double floor(x) - double x; -#endif +double floor(double x) { - int32_t i0,i1,j0; + int32_t i0,i1,_j0; u_int32_t i,j; EXTRACT_WORDS(i0,i1,x); - j0 = ((i0>>20)&0x7ff)-0x3ff; - if(j0<20) { - if(j0<0) { /* raise inexact if x != 0 */ + _j0 = ((i0>>20)&0x7ff)-0x3ff; + if(_j0<20) { + if(_j0<0) { /* raise inexact if x != 0 */ if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */ if(i0>=0) {i0=i1=0;} else if(((i0&0x7fffffff)|i1)!=0) { i0=0xbff00000;i1=0;} } } else { - i = (0x000fffff)>>j0; + i = (0x000fffff)>>_j0; if(((i0&i)|i1)==0) return x; /* x is integral */ if(huge+x>0.0) { /* raise inexact flag */ - if(i0<0) i0 += (0x00100000)>>j0; + if(i0<0) i0 += (0x00100000)>>_j0; i0 &= (~i); i1=0; } } - } else if (j0>51) { - if(j0==0x400) return x+x; /* inf or NaN */ + } else if (_j0>51) { + if(_j0==0x400) return x+x; /* inf or NaN */ else return x; /* x is integral */ } else { - i = ((u_int32_t)(0xffffffff))>>(j0-20); + i = ((u_int32_t)(0xffffffff))>>(_j0-20); if((i1&i)==0) return x; /* x is integral */ if(huge+x>0.0) { /* raise inexact flag */ if(i0<0) { - if(j0==20) i0+=1; + if(_j0==20) i0+=1; else { - j = i1+(1<<(52-j0)); + j = i1+(1<<(52-_j0)); if(j<i1) i0 +=1 ; /* got a carry */ i1=j; } diff --git a/libm/s_fma.c b/libm/s_fma.c new file mode 100644 index 000000000..986dbeb3b --- /dev/null +++ b/libm/s_fma.c @@ -0,0 +1,27 @@ +/* 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> + +double +fma (double x, double y, double z) +{ + return (x * y) + z; +} +libm_hidden_def(fma) diff --git a/libm/s_fmax.c b/libm/s_fmax.c new file mode 100644 index 000000000..5f29ad8e3 --- /dev/null +++ b/libm/s_fmax.c @@ -0,0 +1,19 @@ +/* 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" + +double fmax(double x, double y) +{ + if (isnan(x)) + return y; + if (isnan(y)) + return x; + + 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..a549678ee --- /dev/null +++ b/libm/s_fmin.c @@ -0,0 +1,19 @@ +/* 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" + +double fmin(double x, double y) +{ + if (isnan(x)) + return y; + if (isnan(y)) + return x; + + 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..f810828ce --- /dev/null +++ b/libm/s_fpclassify.c @@ -0,0 +1,41 @@ +/* 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, see + <http://www.gnu.org/licenses/>. */ + +#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..65d34b2fa --- /dev/null +++ b/libm/s_fpclassifyf.c @@ -0,0 +1,39 @@ +/* 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, see + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include "math_private.h" + +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..212ec47af 100644 --- a/libm/s_frexp.c +++ b/libm/s_frexp.c @@ -1,4 +1,3 @@ -/* @(#)s_frexp.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $"; -#endif - /* * for non-zero x * x = frexp(arg,&exp); @@ -27,20 +22,10 @@ static char rcsid[] = "$NetBSD: s_frexp.c,v 1.9 1995/05/10 20:47:24 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ -libm_hidden_proto(frexp) -#ifdef __STDC__ - double frexp(double x, int *eptr) -#else - double frexp(x, eptr) - double x; int *eptr; -#endif +double frexp(double x, int *eptr) { int32_t hx, ix, lx; EXTRACT_WORDS(hx,lx,x); diff --git a/libm/s_ilogb.c b/libm/s_ilogb.c index db7c8553e..259ae7b55 100644 --- a/libm/s_ilogb.c +++ b/libm/s_ilogb.c @@ -1,4 +1,3 @@ -/* @(#)s_ilogb.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,44 +9,49 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_ilogb.c,v 1.9 1995/05/10 20:47:28 jtc Exp $"; -#endif - /* ilogb(double x) - * return the binary exponent of non-zero x - * ilogb(0) = 0x80000001 - * ilogb(inf/NaN) = 0x7fffffff (no signal is raised) + * return the binary exponent of x + * ilogb(+-0) = FP_ILOGB0 + * ilogb(+-inf) = INT_MAX + * ilogb(NaN) = FP_ILOGBNAN (no signal is raised) */ #include "math.h" #include "math_private.h" -libm_hidden_proto(ilogb) -#ifdef __STDC__ - int ilogb(double x) -#else - int ilogb(x) - double x; -#endif +int ilogb(double x) { int32_t hx,lx,ix; - GET_HIGH_WORD(hx,x); + GET_HIGH_WORD(hx, x); hx &= 0x7fffffff; - if(hx<0x00100000) { - GET_LOW_WORD(lx,x); - if((hx|lx)==0) - return 0x80000001; /* ilogb(0) = 0x80000001 */ - else /* subnormal x */ - if(hx==0) { - for (ix = -1043; lx>0; lx<<=1) ix -=1; - } else { - for (ix = -1022,hx<<=11; hx>0; hx<<=1) ix -=1; + + if (hx < 0x00100000) { + GET_LOW_WORD(lx, x); + if ((hx|lx)==0) /* +-0, ilogb(0) = FP_ILOGB0 */ + return FP_ILOGB0; + /* subnormal x */ + ix = -1043; + if (hx != 0) { + ix = -1022; + lx = (hx << 11); } - return ix; + /* each leading zero mantissa bit makes exponent smaller */ + for (; lx > 0; lx <<= 1) + ix--; + return ix; + } + + if (hx < 0x7ff00000) /* normal x */ + return (hx>>20) - 1023; + + if (FP_ILOGBNAN != (~0U >> 1)) { + GET_LOW_WORD(lx, x); + if (hx == 0x7ff00000 && lx == 0) /* +-inf */ + return ~0U >> 1; /* = INT_MAX */ } - else if (hx<0x7ff00000) return (hx>>20)-1023; - else return 0x7fffffff; + + /* NAN. ilogb(NAN) = FP_ILOGBNAN */ + return FP_ILOGBNAN; } libm_hidden_def(ilogb) diff --git a/libm/s_isinf.c b/libm/s_isinf.c new file mode 100644 index 000000000..62e5263bb --- /dev/null +++ b/libm/s_isinf.c @@ -0,0 +1,23 @@ +/* + * 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) diff --git a/libm/s_isinff.c b/libm/s_isinff.c new file mode 100644 index 000000000..6727f0464 --- /dev/null +++ b/libm/s_isinff.c @@ -0,0 +1,23 @@ +/* + * 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" + +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) diff --git a/libm/e_gamma.c b/libm/s_isnan.c index 296ebb8f3..1bc49cb02 100644 --- a/libm/e_gamma.c +++ b/libm/s_isnan.c @@ -1,5 +1,3 @@ - -/* @(#)e_gamma.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -9,27 +7,23 @@ * software is freely granted, provided that this notice * is preserved. * ==================================================== - * */ -/* __ieee754_gamma(x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_gamma_r +/* + * isnan(x) returns 1 is x is nan, else 0; + * no branching! */ -#include <math.h> +#include "math.h" #include "math_private.h" -libm_hidden_proto(signgam) - -#ifdef __STDC__ - //__private_extern__ - double attribute_hidden __ieee754_gamma(double x) -#else - double attribute_hidden __ieee754_gamma(x) - double x; -#endif +int __isnan(double x) { - return __ieee754_gamma_r(x,&signgam); + 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) diff --git a/libm/s_matherr.c b/libm/s_isnanf.c index 0c102e628..d868264f7 100644 --- a/libm/s_matherr.c +++ b/libm/s_isnanf.c @@ -1,4 +1,7 @@ -/* @(#)s_matherr.c 5.1 93/09/24 */ +/* 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. @@ -10,26 +13,20 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_matherr.c,v 1.6 1995/05/10 20:47:53 jtc Exp $"; -#endif +/* + * isnanf(x) returns 1 is x is nan, else 0; + * no branching! + */ #include "math.h" #include "math_private.h" -#ifndef _IEEE_LIBM - -libm_hidden_proto(matherr) -#ifdef __STDC__ - int matherr(struct exception *x) -#else - int matherr(x) - struct exception *x; -#endif +int __isnanf(float x) { - int n=0; - if(x->arg1!=x->arg1) return 0; - return n; + int32_t ix; + GET_FLOAT_WORD(ix,x); + ix &= 0x7fffffff; + ix = 0x7f800000 - ix; + return (int)(((u_int32_t)(ix))>>31); } -libm_hidden_def(matherr) -#endif +libm_hidden_def(__isnanf) diff --git a/libm/s_ldexp.c b/libm/s_ldexp.c index ffc268b52..bc0f08e99 100644 --- a/libm/s_ldexp.c +++ b/libm/s_ldexp.c @@ -1,4 +1,3 @@ -/* @(#)s_ldexp.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,28 +9,31 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $"; -#endif - #include "math.h" #include "math_private.h" #include <errno.h> -libm_hidden_proto(scalbn) -libm_hidden_proto(finite) +/* TODO: POSIX says: + * + * "If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, + * then errno shall be set to [ERANGE]. If the integer expression + * (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow + * floating-point exception shall be raised." + * + * *And it says the same about scalbn*! Thus these two functions + * are the same and can be just aliased. + * + * Currently, ldexp tries to be vaguely POSIX compliant while scalbn + * does not (it does not set ERRNO). + */ -libm_hidden_proto(ldexp) -#ifdef __STDC__ - double ldexp(double value, int exp) -#else - double ldexp(value, exp) - double value; int exp; -#endif +double ldexp(double value, int _exp) { - if(!finite(value)||value==0.0) return value; - value = scalbn(value,exp); - if(!finite(value)||value==0.0) errno = ERANGE; + if (!isfinite(value) || value == 0.0) + return value; + value = scalbn(value, _exp); + if (!isfinite(value) || value == 0.0) + errno = ERANGE; return value; } libm_hidden_def(ldexp) diff --git a/libm/s_lib_version.c b/libm/s_lib_version.c index fde8e3bf6..e3119423f 100644 --- a/libm/s_lib_version.c +++ b/libm/s_lib_version.c @@ -1,4 +1,3 @@ -/* @(#)s_lib_ver.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_lib_version.c,v 1.6 1995/05/10 20:47:44 jtc Exp $"; -#endif - /* * MACRO for standards */ diff --git a/libm/s_llrint.c b/libm/s_llrint.c index 047290ab8..d0c97422f 100644 --- a/libm/s_llrint.c +++ b/libm/s_llrint.c @@ -15,12 +15,13 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES #include <math.h> - #include "math_private.h" static const double two52[2] = @@ -29,12 +30,10 @@ static const double two52[2] = -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ }; -libm_hidden_proto(llrint) - long long int llrint (double x) { - int32_t j0; + int32_t _j0; u_int32_t i1, i0; long long int result; volatile double w; @@ -42,39 +41,39 @@ llrint (double x) int sx; EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; sx = i0 >> 31; i0 &= 0xfffff; i0 |= 0x100000; - if (j0 < 20) + if (_j0 < 20) { w = two52[sx] + x; t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; i0 &= 0xfffff; i0 |= 0x100000; - result = (j0 < 0 ? 0 : i0 >> (20 - j0)); + result = (_j0 < 0 ? 0 : i0 >> (20 - _j0)); } - else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1) + else if (_j0 < (int32_t) (8 * sizeof (long long int)) - 1) { - if (j0 >= 52) - result = (((long long int) i0 << 32) | i1) << (j0 - 52); + if (_j0 >= 52) + result = (((long long int) i0 << 32) | i1) << (_j0 - 52); else { w = two52[sx] + x; t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; i0 &= 0xfffff; i0 |= 0x100000; - if (j0 == 20) + if (_j0 == 20) result = (long long int) i0; else - result = ((long long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); + result = ((long long int) i0 << (_j0 - 20)) | (i1 >> (52 - _j0)); } } else diff --git a/libm/s_llround.c b/libm/s_llround.c index 1db0c2836..889e979bb 100644 --- a/libm/s_llround.c +++ b/libm/s_llround.c @@ -14,54 +14,51 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <math.h> - #include "math_private.h" -libm_hidden_proto(llround) long long int llround (double x) { - int32_t j0; + int32_t _j0; u_int32_t i1, i0; long long int result; int sign; EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; sign = (i0 & 0x80000000) != 0 ? -1 : 1; i0 &= 0xfffff; i0 |= 0x100000; - if (j0 < 20) + if (_j0 < 20) { - if (j0 < 0) - return j0 < -1 ? 0 : sign; + if (_j0 < 0) + return _j0 < -1 ? 0 : sign; else { - i0 += 0x80000 >> j0; + i0 += 0x80000 >> _j0; - result = i0 >> (20 - j0); + result = i0 >> (20 - _j0); } } - else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1) + else if (_j0 < (int32_t) (8 * sizeof (long long int)) - 1) { - if (j0 >= 52) - result = (((long long int) i0 << 32) | i1) << (j0 - 52); + if (_j0 >= 52) + result = (((long long int) i0 << 32) | i1) << (_j0 - 52); else { - u_int32_t j = i1 + (0x80000000 >> (j0 - 20)); + u_int32_t j = i1 + (0x80000000 >> (_j0 - 20)); if (j < i1) ++i0; - if (j0 == 20) + if (_j0 == 20) result = (long long int) i0; else - result = ((long long int) i0 << (j0 - 20)) | (j >> (52 - j0)); + result = ((long long int) i0 << (_j0 - 20)) | (j >> (52 - _j0)); } } else diff --git a/libm/s_log1p.c b/libm/s_log1p.c index 7acf6289b..454056300 100644 --- a/libm/s_log1p.c +++ b/libm/s_log1p.c @@ -1,4 +1,3 @@ -/* @(#)s_log1p.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_log1p.c,v 1.8 1995/05/10 20:47:46 jtc Exp $"; -#endif - /* double log1p(double x) * * Method : @@ -82,11 +77,7 @@ static char rcsid[] = "$NetBSD: s_log1p.c,v 1.8 1995/05/10 20:47:46 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ @@ -98,19 +89,9 @@ Lp5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ Lp6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ Lp7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ -#ifdef __STDC__ static const double zero = 0.0; -#else -static double zero = 0.0; -#endif -libm_hidden_proto(log1p) -#ifdef __STDC__ - double log1p(double x) -#else - double log1p(x) - double x; -#endif +double log1p(double x) { double hfsq,f=0,c=0,s,z,R,u; int32_t k,hx,hu=0,ax; diff --git a/libm/s_logb.c b/libm/s_logb.c index ff47ab476..9016b9721 100644 --- a/libm/s_logb.c +++ b/libm/s_logb.c @@ -1,4 +1,3 @@ -/* @(#)s_logb.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_logb.c,v 1.8 1995/05/10 20:47:50 jtc Exp $"; -#endif - /* * double logb(x) * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. @@ -23,15 +18,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 - double logb(x) - double x; -#endif +double logb(double x) { int32_t lx,ix; EXTRACT_WORDS(ix,lx,x); diff --git a/libm/s_lrint.c b/libm/s_lrint.c index 61c521240..09800d8de 100644 --- a/libm/s_lrint.c +++ b/libm/s_lrint.c @@ -15,12 +15,13 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES #include <math.h> - #include "math_private.h" static const double two52[2] = @@ -30,11 +31,10 @@ static const double two52[2] = }; -libm_hidden_proto(lrint) long int lrint (double x) { - int32_t j0; + int32_t _j0; u_int32_t i0,i1; volatile double w; double t; @@ -42,44 +42,44 @@ lrint (double x) int sx; EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; sx = i0 >> 31; i0 &= 0xfffff; i0 |= 0x100000; - if (j0 < 20) + if (_j0 < 20) { - if (j0 < -1) + if (_j0 < -1) return 0; else { w = two52[sx] + x; t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; i0 &= 0xfffff; i0 |= 0x100000; - result = i0 >> (20 - j0); + result = i0 >> (20 - _j0); } } - else if (j0 < (int32_t) (8 * sizeof (long int)) - 1) + else if (_j0 < (int32_t) (8 * sizeof (long int)) - 1) { - if (j0 >= 52) - result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52)); + if (_j0 >= 52) + result = ((long int) i0 << (_j0 - 20)) | (i1 << (_j0 - 52)); else { w = two52[sx] + x; t = w - two52[sx]; EXTRACT_WORDS (i0, i1, t); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; i0 &= 0xfffff; i0 |= 0x100000; - if (j0 == 20) + if (_j0 == 20) result = (long int) i0; else - result = ((long int) i0 << (j0 - 20)) | (i1 >> (52 - j0)); + result = ((long int) i0 << (_j0 - 20)) | (i1 >> (52 - _j0)); } } else diff --git a/libm/s_lround.c b/libm/s_lround.c index 604004f7f..7a9e1f9fd 100644 --- a/libm/s_lround.c +++ b/libm/s_lround.c @@ -14,54 +14,51 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <math.h> - #include "math_private.h" -libm_hidden_proto(lround) long int lround (double x) { - int32_t j0; + int32_t _j0; u_int32_t i1, i0; long int result; int sign; EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; sign = (i0 & 0x80000000) != 0 ? -1 : 1; i0 &= 0xfffff; i0 |= 0x100000; - if (j0 < 20) + if (_j0 < 20) { - if (j0 < 0) - return j0 < -1 ? 0 : sign; + if (_j0 < 0) + return _j0 < -1 ? 0 : sign; else { - i0 += 0x80000 >> j0; + i0 += 0x80000 >> _j0; - result = i0 >> (20 - j0); + result = i0 >> (20 - _j0); } } - else if (j0 < (int32_t) (8 * sizeof (long int)) - 1) + else if (_j0 < (int32_t) (8 * sizeof (long int)) - 1) { - if (j0 >= 52) - result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52)); + if (_j0 >= 52) + result = ((long int) i0 << (_j0 - 20)) | (i1 << (_j0 - 52)); else { - u_int32_t j = i1 + (0x80000000 >> (j0 - 20)); + u_int32_t j = i1 + (0x80000000 >> (_j0 - 20)); if (j < i1) ++i0; - if (j0 == 20) + if (_j0 == 20) result = (long int) i0; else - result = ((long int) i0 << (j0 - 20)) | (j >> (52 - j0)); + result = ((long int) i0 << (_j0 - 20)) | (j >> (52 - _j0)); } } else diff --git a/libm/s_modf.c b/libm/s_modf.c index 0cf0e8356..0a2026cea 100644 --- a/libm/s_modf.c +++ b/libm/s_modf.c @@ -1,4 +1,3 @@ -/* @(#)s_modf.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $"; -#endif - /* * modf(double x, double *iptr) * return fraction part of x, and return x's integral part in *iptr. @@ -27,54 +22,41 @@ static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double one = 1.0; -#else -static double one = 1.0; -#endif -libm_hidden_proto(modf) -#ifdef __STDC__ - double modf(double x, double *iptr) -#else - double modf(x, iptr) - double x,*iptr; -#endif +double modf(double x, double *iptr) { - int32_t i0,i1,j0; + int32_t i0,i1,_j0; u_int32_t i; EXTRACT_WORDS(i0,i1,x); - j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ - if(j0<20) { /* integer part in high x */ - if(j0<0) { /* |x|<1 */ + _j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ + if(_j0<20) { /* integer part in high x */ + if(_j0<0) { /* |x|<1 */ INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */ return x; } else { - i = (0x000fffff)>>j0; + i = (0x000fffff)>>_j0; if(((i0&i)|i1)==0) { /* x is integral */ - u_int32_t high; *iptr = x; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { INSERT_WORDS(*iptr,i0&(~i),0); return x - *iptr; } } - } else if (j0>51) { /* no fraction part */ - u_int32_t high; + } else if (_j0>51) { /* no fraction part */ *iptr = x*one; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + /* We must handle NaNs separately. */ + if (_j0 == 0x400 && ((i0 & 0xfffff) | i1)) + return x*one; + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { /* fraction part in low x */ - i = ((u_int32_t)(0xffffffff))>>(j0-20); + i = ((u_int32_t)(0xffffffff))>>(_j0-20); if((i1&i)==0) { /* x is integral */ - u_int32_t high; *iptr = x; - GET_HIGH_WORD(high,x); - INSERT_WORDS(x,high&0x80000000,0); /* return +-0 */ + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ return x; } else { INSERT_WORDS(*iptr,i0,i1&(~i)); diff --git a/libm/s_nextafter.c b/libm/s_nextafter.c index bdc6f3a61..73a8ab2be 100644 --- a/libm/s_nextafter.c +++ b/libm/s_nextafter.c @@ -1,4 +1,3 @@ -/* @(#)s_nextafter.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_nextafter.c,v 1.8 1995/05/10 20:47:58 jtc Exp $"; -#endif - /* IEEE functions * nextafter(x,y) * return the next machine floating-point number of x in the @@ -24,13 +19,7 @@ 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 - double nextafter(x,y) - double x,y; -#endif +double nextafter(double x, double y) { int32_t hx,hy,ix,iy; u_int32_t lx,ly; @@ -43,7 +32,7 @@ libm_hidden_proto(nextafter) if(((ix>=0x7ff00000)&&((ix-0x7ff00000)|lx)!=0) || /* x is nan */ ((iy>=0x7ff00000)&&((iy-0x7ff00000)|ly)!=0)) /* y is nan */ return x+y; - if(x==y) return x; /* x=y, return x */ + if(x==y) return y; /* x=y, return y */ if((ix|lx)==0) { /* x == 0 */ INSERT_WORDS(x,hy&0x80000000,1); /* return +-minsubnormal */ y = x*x; @@ -79,3 +68,5 @@ libm_hidden_proto(nextafter) return x; } libm_hidden_def(nextafter) +strong_alias_untyped(nextafter, nexttoward) +libm_hidden_def(nexttoward) diff --git a/libm/s_nextafterf.c b/libm/s_nextafterf.c new file mode 100644 index 000000000..e0cb81613 --- /dev/null +++ b/libm/s_nextafterf.c @@ -0,0 +1,96 @@ +/* s_nextafterf.c -- float version of s_nextafter.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. + * ==================================================== + */ + +#include "math.h" +#include "math_private.h" + +float nextafterf(float x, float y) +{ + int32_t hx, hy, ix, iy; + + GET_FLOAT_WORD(hx, x); + GET_FLOAT_WORD(hy, y); + ix = hx & 0x7fffffff; /* |x| */ + iy = hy & 0x7fffffff; /* |y| */ + + /* x is nan or y is nan? */ + if ((ix > 0x7f800000) || (iy > 0x7f800000)) + return x + y; + + if (x == y) + return y; + + if (ix == 0) { /* x == 0? */ +/* glibc 2.4 does not seem to set underflow? */ +/* float u; */ + /* return +-minsubnormal */ + SET_FLOAT_WORD(x, (hy & 0x80000000) | 1); +/* u = x * x; raise underflow flag */ +/* math_force_eval(u); */ + return x; + } + + if (hx >= 0) { /* x > 0 */ + if (hx > hy) { /* x > y: x -= ulp */ + hx -= 1; + } else { /* x < y: x += ulp */ + hx += 1; + } + } else { /* x < 0 */ + if (hy >= 0 || hx > hy) { /* x < y: x -= ulp */ + hx -= 1; + } else { /* x > y: x += ulp */ + hx += 1; + } + } + hy = hx & 0x7f800000; + if (hy >= 0x7f800000) { + x = x + x; /* overflow */ + return x; /* overflow */ + } + if (hy < 0x00800000) { + float u = x * x; /* underflow */ + math_force_eval(u); /* raise underflow flag */ + } + SET_FLOAT_WORD(x, hx); + return x; +} + +#if 0 +/* "testprog N a b" + * calculates a = nextafterf(a, b) and prints a as float + * and as raw bytes; repeats it N times. + */ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +int main(int argc, char **argv) +{ + int cnt, i; + float a, b; + cnt = atoi(argv[1]); + a = strtod(argv[2], NULL); + b = strtod(argv[3], NULL); + while (cnt-- > 0) { + for (i = 0; i < sizeof(a); i++) { + unsigned char c = ((char*)(&a))[i]; + printf("%x%x", (c >> 4), (c & 0xf)); + } + printf(" %f\n", a); + a = nextafterf(a, b); + } + return 0; +} +#endif diff --git a/libm/s_remquo.c b/libm/s_remquo.c new file mode 100644 index 000000000..f72c56f3f --- /dev/null +++ b/libm/s_remquo.c @@ -0,0 +1,31 @@ +/* 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" + +double remquo(double x, double y, int *quo) /* wrapper remquo */ +{ + 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..02ec404e6 100644 --- a/libm/s_rint.c +++ b/libm/s_rint.c @@ -1,4 +1,3 @@ -/* @(#)s_rint.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $"; -#endif - /* * rint(x) * Return x rounded to integral value according to the prevailing @@ -27,62 +22,71 @@ static char rcsid[] = "$NetBSD: s_rint.c,v 1.8 1995/05/10 20:48:04 jtc Exp $"; #include "math.h" #include "math_private.h" -#ifdef __STDC__ static const double -#else -static double -#endif TWO52[2]={ 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */ }; -libm_hidden_proto(rint) -#ifdef __STDC__ - double rint(double x) -#else - double rint(x) - double x; -#endif +double rint(double x) { - int32_t i0,j0,sx; + int32_t i0, _j0, sx; u_int32_t i,i1; - double w,t; + double t; + /* We use w = x + 2^52; t = w - 2^52; trick to round x to integer. + * This trick requires that compiler does not optimize it + * by keeping intermediate result w in a register wider than double. + * Declaring w volatile assures that value gets truncated to double + * (unfortunately, it also forces store+load): + */ + volatile double w; + EXTRACT_WORDS(i0,i1,x); - sx = (i0>>31)&1; - j0 = ((i0>>20)&0x7ff)-0x3ff; - if(j0<20) { - if(j0<0) { - if(((i0&0x7fffffff)|i1)==0) return x; + /* Unbiased exponent */ + _j0 = ((((u_int32_t)i0) >> 20)&0x7ff)-0x3ff; + + if (_j0 > 51) { + //Why bother? Just returning x works too + //if (_j0 == 0x400) /* inf or NaN */ + // return x+x; + return x; /* x is integral */ + } + + /* Sign */ + sx = ((u_int32_t)i0) >> 31; + + if (_j0<20) { + if (_j0<0) { /* |x| < 1 */ + if (((i0&0x7fffffff)|i1)==0) return x; i1 |= (i0&0x0fffff); i0 &= 0xfffe0000; i0 |= ((i1|-i1)>>12)&0x80000; SET_HIGH_WORD(x,i0); - w = TWO52[sx]+x; - t = w-TWO52[sx]; + w = TWO52[sx]+x; + t = w-TWO52[sx]; GET_HIGH_WORD(i0,t); SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31)); - return t; + return t; } else { - i = (0x000fffff)>>j0; - if(((i0&i)|i1)==0) return x; /* x is integral */ + i = (0x000fffff)>>_j0; + if (((i0&i)|i1)==0) return x; /* x is integral */ i>>=1; - if(((i0&i)|i1)!=0) { - if(j0==19) i1 = 0x40000000; else - i0 = (i0&(~i))|((0x20000)>>j0); + if (((i0&i)|i1)!=0) { + if (_j0==19) i1 = 0x40000000; + else i0 = (i0&(~i))|((0x20000)>>_j0); } } - } else if (j0>51) { - if(j0==0x400) return x+x; /* inf or NaN */ - else return x; /* x is integral */ } else { - i = ((u_int32_t)(0xffffffff))>>(j0-20); - if((i1&i)==0) return x; /* x is integral */ + i = ((u_int32_t)(0xffffffff))>>(_j0-20); + if ((i1&i)==0) return x; /* x is integral */ i>>=1; - if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20)); + if ((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(_j0-20)); } INSERT_WORDS(x,i0,i1); w = TWO52[sx]+x; return w-TWO52[sx]; } libm_hidden_def(rint) + +strong_alias(rint, nearbyint) +libm_hidden_def(nearbyint) diff --git a/libm/s_round.c b/libm/s_round.c index 03089482b..cf5d280e3 100644 --- a/libm/s_round.c +++ b/libm/s_round.c @@ -14,56 +14,52 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <math.h> - #include "math_private.h" - static const double huge = 1.0e300; -libm_hidden_proto(round) double round (double x) { - int32_t i0, j0; + int32_t i0, _j0; u_int32_t i1; EXTRACT_WORDS (i0, i1, x); - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 20) + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + if (_j0 < 20) { - if (j0 < 0) + if (_j0 < 0) { if (huge + x > 0.0) { i0 &= 0x80000000; - if (j0 == -1) + if (_j0 == -1) i0 |= 0x3ff00000; i1 = 0; } } else { - u_int32_t i = 0x000fffff >> j0; + u_int32_t i = 0x000fffff >> _j0; if (((i0 & i) | i1) == 0) /* X is integral. */ return x; if (huge + x > 0.0) { /* Raise inexact if x != 0. */ - i0 += 0x00080000 >> j0; + i0 += 0x00080000 >> _j0; i0 &= ~i; i1 = 0; } } } - else if (j0 > 51) + else if (_j0 > 51) { - if (j0 == 0x400) + if (_j0 == 0x400) /* Inf or NaN. */ return x + x; else @@ -71,7 +67,7 @@ round (double x) } else { - u_int32_t i = 0xffffffff >> (j0 - 20); + u_int32_t i = 0xffffffff >> (_j0 - 20); if ((i1 & i) == 0) /* X is integral. */ return x; @@ -79,7 +75,7 @@ round (double x) if (huge + x > 0.0) { /* Raise inexact if x != 0. */ - u_int32_t j = i1 + (1 << (51 - j0)); + u_int32_t j = i1 + (1 << (51 - _j0)); if (j < i1) i0 += 1; i1 = j; diff --git a/libm/s_scalbn.c b/libm/s_scalbn.c index 6a7452485..4d2005c72 100644 --- a/libm/s_scalbn.c +++ b/libm/s_scalbn.c @@ -1,4 +1,3 @@ -/* @(#)s_scalbn.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,62 +9,64 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_scalbn.c,v 1.8 1995/05/10 20:48:08 jtc Exp $"; -#endif - /* - * scalbn (double x, int n) - * scalbn(x,n) returns x* 2**n computed by exponent + * scalbln(double x, long n) + * scalbln(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" +#include <limits.h> -libm_hidden_proto(copysign) - -#ifdef __STDC__ static const double -#else -static double -#endif -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ +two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ +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 - double scalbn (x,n) - double x; int n; -#endif +double scalbln(double x, long n) { - 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 (n< -50000) return tiny*x; /*underflow*/ - } - if (k==0x7ff) return x+x; /* NaN or Inf */ - k = k+n; - if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ - if (k > 0) /* normal result */ - {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) { - if (n > 50000) /* in case integer overflow in n+k */ - return huge*copysign(huge,x); /*overflow*/ - else return tiny*copysign(tiny,x); /*underflow*/ + 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; } - k += 54; /* subnormal result */ - SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); - return x*twom54; + if (k == 0x7ff) + return x + x; /* NaN or Inf */ + k = k + n; + if (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) { + if (n > 50000) /* in case integer overflow in n+k */ + return huge * copysign(huge, x); /* overflow */ + 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) + +#if LONG_MAX == INT_MAX +strong_alias_untyped(scalbln,scalbn) +#else +double scalbn(double x, int n) +{ + return scalbln(x, n); +} +#endif libm_hidden_def(scalbn) diff --git a/libm/s_signbit.c b/libm/s_signbit.c new file mode 100644 index 000000000..398a5eecf --- /dev/null +++ b/libm/s_signbit.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, see + <http://www.gnu.org/licenses/>. */ + +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES +#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..b72fee677 --- /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, see + <http://www.gnu.org/licenses/>. */ + +#include <features.h> +/* Prevent math.h from defining a colliding inline */ +#undef __USE_EXTERN_INLINES +#include <math.h> +#include "math_private.h" + +int +__signbitf (float x) +{ + int32_t hx; + + GET_FLOAT_WORD (hx, x); + return hx & 0x80000000; +} +libm_hidden_def(__signbitf) diff --git a/libm/s_signgam.c b/libm/s_signgam.c index 13d2a1c34..d67d5918e 100644 --- a/libm/s_signgam.c +++ b/libm/s_signgam.c @@ -1,5 +1,3 @@ #include "math.h" #include "math_private.h" -libm_hidden_proto(signgam) int signgam = 0; -libm_hidden_def(signgam) diff --git a/libm/s_significand.c b/libm/s_significand.c index e47618cfc..2d681dcb1 100644 --- a/libm/s_significand.c +++ b/libm/s_significand.c @@ -1,4 +1,3 @@ -/* @(#)s_signif.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Exp $"; -#endif - /* * significand(x) computes just * scalb(x, (double) -ilogb(x)), @@ -23,14 +18,8 @@ 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) -#else - double significand(x) - double x; -#endif +double significand(double x) { 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..03867e773 100644 --- a/libm/s_sin.c +++ b/libm/s_sin.c @@ -1,4 +1,3 @@ -/* @(#)s_sin.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_sin.c,v 1.7 1995/05/10 20:48:15 jtc Exp $"; -#endif - /* sin(x) * Return sine function of x. * @@ -48,13 +43,7 @@ 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 - double sin(x) - double x; -#endif +double sin(double x) { double y[2],z=0.0; int32_t n, ix; diff --git a/libm/s_tan.c b/libm/s_tan.c index bab343c73..5a2bc930c 100644 --- a/libm/s_tan.c +++ b/libm/s_tan.c @@ -1,4 +1,3 @@ -/* @(#)s_tan.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_tan.c,v 1.7 1995/05/10 20:48:18 jtc Exp $"; -#endif - /* tan(x) * Return tangent function of x. * @@ -47,13 +42,7 @@ 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 - double tan(x) - double x; -#endif +double tan(double x) { double y[2],z=0.0; int32_t n, ix; diff --git a/libm/s_tanh.c b/libm/s_tanh.c index ecabbef98..89ee2718b 100644 --- a/libm/s_tanh.c +++ b/libm/s_tanh.c @@ -1,4 +1,3 @@ -/* @(#)s_tanh.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -10,10 +9,6 @@ * ==================================================== */ -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $"; -#endif - /* Tanh(x) * Return the Hyperbolic Tangent of x * @@ -41,22 +36,9 @@ 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; -#else -static double one=1.0, two=2.0, tiny = 1.0e-300; -#endif -libm_hidden_proto(tanh) -#ifdef __STDC__ - double tanh(double x) -#else - double tanh(x) - double x; -#endif +double tanh(double x) { double t,z; int32_t jx,ix; diff --git a/libm/s_trunc.c b/libm/s_trunc.c index 8a4f5ae05..693a442c0 100644 --- a/libm/s_trunc.c +++ b/libm/s_trunc.c @@ -14,43 +14,39 @@ 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. */ + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ #include <math.h> - #include "math_private.h" - -libm_hidden_proto(trunc) double trunc (double x) { - int32_t i0, j0; + int32_t i0, _j0; u_int32_t i1; int sx; EXTRACT_WORDS (i0, i1, x); sx = i0 & 0x80000000; - j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; - if (j0 < 20) + _j0 = ((i0 >> 20) & 0x7ff) - 0x3ff; + if (_j0 < 20) { - if (j0 < 0) + if (_j0 < 0) /* The magnitude of the number is < 1 so the result is +-0. */ INSERT_WORDS (x, sx, 0); else - INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> j0)), 0); + INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> _j0)), 0); } - else if (j0 > 51) + else if (_j0 > 51) { - if (j0 == 0x400) + if (_j0 == 0x400) /* x is inf or NaN. */ return x + x; } else { - INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20))); + INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (_j0 - 20))); } return x; diff --git a/libm/sh/sh4/Makefile.arch b/libm/sh/sh4/Makefile.arch new file mode 100644 index 000000000..e38e99c15 --- /dev/null +++ b/libm/sh/sh4/Makefile.arch @@ -0,0 +1,24 @@ +# Makefile for uClibc +# +# Copyright (c) 2007, 2010 STMicroelectronics Ltd +# +# Author(s): Carmelo Amoroso <carmelo.amoroso@st.com> +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +ifeq ($(UCLIBC_HAS_FENV),y) +libm_ARCH_CSRC:=$(wildcard $(libm_SUBARCH_DIR)/*.c) +libm_ARCH_COBJ:=$(patsubst $(libm_SUBARCH_DIR)/%.c,$(libm_SUBARCH_OUT)/%.o,$(libm_ARCH_SRC)) +libm_ARCH_SSRC:=$(wildcard $(libm_SUBARCH_DIR)/*.S) +libm_ARCH_SOBJ:=$(patsubst $(libm_SUBARCH_DIR)/%.S,$(libm_SUBARCH_OUT)/%.o,$(libm_ARCH_SSRC)) +endif + +libm_ARCH_OBJS:=$(libm_ARCH_COBJ) $(libm_ARCH_SOBJ) + +ifeq ($(DOPIC),y) +libm-a-y+=$(libm_ARCH_OBJS:.o=.os) +else +libm-a-y+=$(libm_ARCH_OBJS) +endif +libm-so-y+=$(libm_ARCH_OBJS:.o=.os) + diff --git a/libm/sh/sh4/feholdexcpt.c b/libm/sh/sh4/feholdexcpt.c new file mode 100644 index 000000000..70b51e8dd --- /dev/null +++ b/libm/sh/sh4/feholdexcpt.c @@ -0,0 +1,29 @@ +/* + * + * Copyright (c) 2007 STMicroelectronics Ltd + * Filippo Arcidiacono (filippo.arcidiacono@st.com) + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + * + * Taken from glibc 2.6 + * + */ + +#include <fenv.h> +#include <fpu_control.h> + +int +feholdexcept (fenv_t *envp) +{ + unsigned long int temp; + + /* Store the environment. */ + _FPU_GETCW (temp); + envp->__fpscr = temp; + + /* Now set all exceptions to non-stop. */ + temp &= ~FE_ALL_EXCEPT; + _FPU_SETCW (temp); + + return 1; +} diff --git a/libm/sh/sh4/fesetenv.c b/libm/sh/sh4/fesetenv.c new file mode 100644 index 000000000..c5cfc1d51 --- /dev/null +++ b/libm/sh/sh4/fesetenv.c @@ -0,0 +1,26 @@ +/* + * + * Copyright (c) 2007 STMicroelectronics Ltd + * Filippo Arcidiacono (filippo.arcidiacono@st.com) + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + * + * Taken from glibc 2.6 + * + */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fesetenv (const fenv_t *envp) +{ + if (envp == FE_DFL_ENV) + _FPU_SETCW (_FPU_DEFAULT); + else + { + unsigned long int temp = envp->__fpscr; + _FPU_SETCW (temp); + } + return 0; +} diff --git a/libm/sh/sh4/s_lrintf.S b/libm/sh/sh4/s_lrintf.S new file mode 100644 index 000000000..d8cec329c --- /dev/null +++ b/libm/sh/sh4/s_lrintf.S @@ -0,0 +1,52 @@ +/* Round argument to nearest integer value. SH4 version. + * According to ISO/IEC 9899:1999. This version doesn't handle range error. + * If arg is not finite or if the result cannot be represented into a long, + * return an unspecified value. No exception raised. + * + * Copyright (C) 2010 STMicroelectronics Ltd. + * + * Author: Christian Bruel <christian.bruel@st.com> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sysdep.h> + +ENTRY(lrintf) + mov #0,r0 + sts fpscr,r3 + lds r0,fpscr + flds fr5,fpul + mov.l LOCAL(mask),r1 + sts fpul,r2 + and r2,r1 + mov.l LOCAL(midway),r2 + or r1,r2 + lds r2,fpul + fsts fpul,fr2 + fadd fr2,fr5 + ftrc fr5,fpul + sts fpul,r0 + float fpul,fr2 + fcmp/eq fr5,fr2 + bf/s 0f + mov #1,r2 + tst r1,r1 + and r0,r2 + movt r1 + shal r1 + tst r2,r2 + add #-1,r1 + bt 0f + sub r1,r0 +0: + rts + lds r3,fpscr + + .align 2 +LOCAL(mask): + .long 0x80000000 +LOCAL(midway): + .long 1056964608 + +END(lrintf) diff --git a/libm/sh/sh4/s_lroundf.S b/libm/sh/sh4/s_lroundf.S new file mode 100644 index 000000000..fda3a4b91 --- /dev/null +++ b/libm/sh/sh4/s_lroundf.S @@ -0,0 +1,39 @@ +/* Round argument toward 0. SH4 version. + * According to ISO/IEC 9899:1999. This version doesn't handle range error. + * If arg is not finite or if the result cannot be represented into a long, + * return an unspecified value. No exception raised. + * + * Copyright (C) 2010 STMicroelectronics Ltd. + * + * Author: Christian Bruel <christian.bruel@st.com> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sysdep.h> + +ENTRY(lroundf) + mov #0,r0 + sts fpscr,r3 + lds r0,fpscr + flds fr5,fpul + mov.l LOCAL(mask),r1 + sts fpul,r2 + and r2,r1 + mov.l LOCAL(midway),r2 + or r1,r2 + lds r2,fpul + fsts fpul,fr2 + fadd fr2,fr5 + ftrc fr5,fpul + sts fpul,r0 + rts + lds r3,fpscr + + .align 2 +LOCAL(mask): + .long 0x80000000 +LOCAL(midway): + .long 1056964608 + +END(lroundf) diff --git a/libm/sincos.c b/libm/sincos.c new file mode 100644 index 000000000..df6b670f8 --- /dev/null +++ b/libm/sincos.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <features.h> +#include <math.h> + +libm_hidden_proto(sincos) +void sincos(double x, double *s, double *c) +{ + *s = sin(x); + *c = cos(x); +} +libm_hidden_def(sincos) + +libm_hidden_proto(sincosf) +void sincosf(float x, float *s, float *c) +{ + *s = sinf(x); + *c = cosf(x); +} +libm_hidden_def(sincosf) + +#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH +libm_hidden_proto(sincosl) +void sincosl(long double x, long double *s, long double *c) +{ + *s = sinl(x); + *c = cosl(x); +} +libm_hidden_def(sincosl) +#endif diff --git a/libm/w_acos.c b/libm/w_acos.c deleted file mode 100644 index ea00cf010..000000000 --- a/libm/w_acos.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_acos.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_acos.c,v 1.6 1995/05/10 20:48:26 jtc Exp $"; -#endif - -/* - * wrap_acos(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(acos) -#ifdef __STDC__ - double acos(double x) /* wrapper acos */ -#else - double acos(x) /* wrapper acos */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_acos(x); -#else - double z; - z = __ieee754_acos(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(fabs(x)>1.0) { - return __kernel_standard(x,x,1); /* acos(|x|>1) */ - } else - return z; -#endif -} -libm_hidden_def(acos) diff --git a/libm/w_acosh.c b/libm/w_acosh.c deleted file mode 100644 index e0efb8a63..000000000 --- a/libm/w_acosh.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_acosh.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_acosh.c,v 1.6 1995/05/10 20:48:31 jtc Exp $"; -#endif - -/* - * wrapper acosh(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(acosh) -#ifdef __STDC__ - double acosh(double x) /* wrapper acosh */ -#else - double acosh(x) /* wrapper acosh */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_acosh(x); -#else - double z; - z = __ieee754_acosh(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(x<1.0) { - return __kernel_standard(x,x,29); /* acosh(x<1) */ - } else - return z; -#endif -} -libm_hidden_def(acosh) diff --git a/libm/w_asin.c b/libm/w_asin.c deleted file mode 100644 index ad156ef05..000000000 --- a/libm/w_asin.c +++ /dev/null @@ -1,46 +0,0 @@ -/* @(#)w_asin.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_asin.c,v 1.6 1995/05/10 20:48:35 jtc Exp $"; -#endif - -/* - * wrapper asin(x) - */ - - -#include "math.h" -#include "math_private.h" - - -libm_hidden_proto(asin) -#ifdef __STDC__ - double asin(double x) /* wrapper asin */ -#else - double asin(x) /* wrapper asin */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_asin(x); -#else - double z; - z = __ieee754_asin(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(fabs(x)>1.0) { - return __kernel_standard(x,x,2); /* asin(|x|>1) */ - } else - return z; -#endif -} -libm_hidden_def(asin) diff --git a/libm/w_atan2.c b/libm/w_atan2.c deleted file mode 100644 index c2da4681c..000000000 --- a/libm/w_atan2.c +++ /dev/null @@ -1,43 +0,0 @@ -/* @(#)w_atan2.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_atan2.c,v 1.6 1995/05/10 20:48:39 jtc Exp $"; -#endif - -/* - * wrapper atan2(y,x) - */ -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(atan2) -#ifdef __STDC__ - double atan2(double y, double x) /* wrapper atan2 */ -#else - double atan2(y,x) /* wrapper atan2 */ - double y,x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_atan2(y,x); -#else - double z; - z = __ieee754_atan2(y,x); - if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z; - if(x==0.0&&y==0.0) { - return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ - } else - return z; -#endif -} -libm_hidden_def(atan2) diff --git a/libm/w_atanh.c b/libm/w_atanh.c deleted file mode 100644 index 18d0a4a80..000000000 --- a/libm/w_atanh.c +++ /dev/null @@ -1,48 +0,0 @@ -/* @(#)w_atanh.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_atanh.c,v 1.6 1995/05/10 20:48:43 jtc Exp $"; -#endif - -/* - * wrapper atanh(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(atanh) -#ifdef __STDC__ - double atanh(double x) /* wrapper atanh */ -#else - double atanh(x) /* wrapper atanh */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_atanh(x); -#else - double z,y; - z = __ieee754_atanh(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - y = fabs(x); - if(y>=1.0) { - if(y>1.0) - return __kernel_standard(x,x,30); /* atanh(|x|>1) */ - else - return __kernel_standard(x,x,31); /* atanh(|x|==1) */ - } else - return z; -#endif -} -libm_hidden_def(atanh) diff --git a/libm/w_cabs.c b/libm/w_cabs.c index 485e120db..b2592484c 100644 --- a/libm/w_cabs.c +++ b/libm/w_cabs.c @@ -8,9 +8,24 @@ #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) + +libm_hidden_proto(cabsf) +float cabsf(float _Complex z) +{ + return (float) hypot(__real__ z, __imag__ z); +} +libm_hidden_def(cabsf) + +#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH +libm_hidden_proto(cabsl) +long double cabsl(long double _Complex z) +{ + return hypotl(__real__ z, __imag__ z); +} +libm_hidden_def(cabsl) +#endif diff --git a/libm/w_cosh.c b/libm/w_cosh.c deleted file mode 100644 index c785af4b5..000000000 --- a/libm/w_cosh.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_cosh.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_cosh.c,v 1.6 1995/05/10 20:48:47 jtc Exp $"; -#endif - -/* - * wrapper cosh(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(cosh) -#ifdef __STDC__ - double cosh(double x) /* wrapper cosh */ -#else - double cosh(x) /* wrapper cosh */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_cosh(x); -#else - double z; - z = __ieee754_cosh(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(fabs(x)>7.10475860073943863426e+02) { - return __kernel_standard(x,x,5); /* cosh overflow */ - } else - return z; -#endif -} -libm_hidden_def(cosh) diff --git a/libm/w_drem.c b/libm/w_drem.c deleted file mode 100644 index 22e281761..000000000 --- a/libm/w_drem.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - * drem() wrapper for remainder(). - * - * Written by J.T. Conklin, <jtc@wimsey.com> - * Placed into the Public Domain, 1994. - */ - -#include <math.h> - -libm_hidden_proto(remainder) - -double drem(double x, double y) -{ - return remainder(x, y); -} diff --git a/libm/w_exp.c b/libm/w_exp.c deleted file mode 100644 index b9b7ccc26..000000000 --- a/libm/w_exp.c +++ /dev/null @@ -1,55 +0,0 @@ -/* @(#)w_exp.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_exp.c,v 1.6 1995/05/10 20:48:51 jtc Exp $"; -#endif - -/* - * wrapper exp(x) - */ - -#include "math.h" -#include "math_private.h" - -#ifdef __STDC__ -static const double -#else -static double -#endif -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 - double exp(x) /* wrapper exp */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_exp(x); -#else - double z; - z = __ieee754_exp(x); - if(_LIB_VERSION == _IEEE_) return z; - if(finite(x)) { - if(x>o_threshold) - return __kernel_standard(x,x,6); /* exp overflow */ - else if(x<u_threshold) - return __kernel_standard(x,x,7); /* exp underflow */ - } - return z; -#endif -} -libm_hidden_def(exp) diff --git a/libm/e_lgamma.c b/libm/w_exp2.c index 4dce71c80..e00277abf 100644 --- a/libm/e_lgamma.c +++ b/libm/w_exp2.c @@ -1,5 +1,3 @@ - -/* @(#)e_lgamma.c 5.1 93/09/24 */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -9,27 +7,13 @@ * software is freely granted, provided that this notice * is preserved. * ==================================================== - * - */ - -/* __ieee754_lgamma(x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_lgamma_r */ -#include <math.h> +#include "math.h" #include "math_private.h" -libm_hidden_proto(signgam) - -#ifdef __STDC__ - //__private_extern__ - double attribute_hidden __ieee754_lgamma(double x) -#else - double attribute_hidden __ieee754_lgamma(x) - double x; -#endif +double exp2(double x) { - return __ieee754_lgamma_r(x,&signgam); + return pow(2.0, x); } +libm_hidden_def(exp2) diff --git a/libm/w_fmod.c b/libm/w_fmod.c deleted file mode 100644 index eed38372b..000000000 --- a/libm/w_fmod.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_fmod.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_fmod.c,v 1.6 1995/05/10 20:48:55 jtc Exp $"; -#endif - -/* - * wrapper fmod(x,y) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(fmod) -#ifdef __STDC__ - double fmod(double x, double y) /* wrapper fmod */ -#else - double fmod(x,y) /* wrapper fmod */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_fmod(x,y); -#else - double z; - z = __ieee754_fmod(x,y); - if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z; - if(y==0.0) { - return __kernel_standard(x,y,27); /* fmod(x,0) */ - } else - return z; -#endif -} -libm_hidden_def(fmod) diff --git a/libm/w_gamma.c b/libm/w_gamma.c deleted file mode 100644 index 182dece3e..000000000 --- a/libm/w_gamma.c +++ /dev/null @@ -1,49 +0,0 @@ -/* @(#)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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_gamma.c,v 1.7 1995/11/20 22:06:43 jtc Exp $"; -#endif - -/* double gamma(double x) - * Return the logarithm of the Gamma function of x. - * - * Method: call gamma_r - */ - -#include <math.h> -#include "math_private.h" - -libm_hidden_proto(signgam) - -#ifdef __STDC__ - double gamma(double x) -#else - double gamma(x) - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_lgamma_r(x,&signgam); -#else - double y; - y = __ieee754_lgamma_r(x,&signgam); - if(_LIB_VERSION == _IEEE_) return y; - if(!finite(y)&&finite(x)) { - if(floor(x)==x&&x<=0.0) - return __kernel_standard(x,x,41); /* gamma pole */ - else - return __kernel_standard(x,x,40); /* gamma overflow */ - } else - return y; -#endif -} diff --git a/libm/w_gamma_r.c b/libm/w_gamma_r.c deleted file mode 100644 index 321e86480..000000000 --- a/libm/w_gamma_r.c +++ /dev/null @@ -1,47 +0,0 @@ -/* @(#)wr_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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_gamma_r.c,v 1.7 1995/11/20 22:06:45 jtc Exp $"; -#endif - -/* - * wrapper double gamma_r(double x, int *signgamp) - */ - -#include "math.h" -#include "math_private.h" - - -double gamma_r(double x, int *signgamp); -#ifdef __STDC__ - double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */ -#else - double gamma_r(x,signgamp) /* wrapper lgamma_r */ - double x; int *signgamp; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_lgamma_r(x,signgamp); -#else - double y; - y = __ieee754_lgamma_r(x,signgamp); - if(_LIB_VERSION == _IEEE_) return y; - if(!finite(y)&&finite(x)) { - if(floor(x)==x&&x<=0.0) - return __kernel_standard(x,x,41); /* gamma pole */ - else - return __kernel_standard(x,x,40); /* gamma overflow */ - } else - return y; -#endif -} diff --git a/libm/w_hypot.c b/libm/w_hypot.c deleted file mode 100644 index e4b299d5f..000000000 --- a/libm/w_hypot.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_hypot.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_hypot.c,v 1.6 1995/05/10 20:49:07 jtc Exp $"; -#endif - -/* - * wrapper hypot(x,y) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(hypot) -#ifdef __STDC__ - double hypot(double x, double y)/* wrapper hypot */ -#else - double hypot(x,y) /* wrapper hypot */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_hypot(x,y); -#else - double z; - z = __ieee754_hypot(x,y); - if(_LIB_VERSION == _IEEE_) return z; - if((!finite(z))&&finite(x)&&finite(y)) - return __kernel_standard(x,y,4); /* hypot overflow */ - else - return z; -#endif -} -libm_hidden_def(hypot) diff --git a/libm/w_j0.c b/libm/w_j0.c deleted file mode 100644 index 61f4f20fc..000000000 --- a/libm/w_j0.c +++ /dev/null @@ -1,69 +0,0 @@ -/* @(#)w_j0.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_j0.c,v 1.6 1995/05/10 20:49:11 jtc Exp $"; -#endif - -/* - * wrapper j0(double x), y0(double x) - */ - -#include "math.h" -#include "math_private.h" - -#ifdef __STDC__ - double j0(double x) /* wrapper j0 */ -#else - double j0(x) /* wrapper j0 */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_j0(x); -#else - double z = __ieee754_j0(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(fabs(x)>X_TLOSS) { - return __kernel_standard(x,x,34); /* j0(|x|>X_TLOSS) */ - } else - return z; -#endif -} - -#ifdef __STDC__ - double y0(double x) /* wrapper y0 */ -#else - double y0(x) /* wrapper y0 */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_y0(x); -#else - double z; - z = __ieee754_y0(x); - if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; - if(x <= 0.0){ - if(x==0.0) - /* d= -one/(x-x); */ - return __kernel_standard(x,x,8); - else - /* d = zero/(x-x); */ - return __kernel_standard(x,x,9); - } - if(x>X_TLOSS) { - return __kernel_standard(x,x,35); /* y0(x>X_TLOSS) */ - } else - return z; -#endif -} diff --git a/libm/w_j1.c b/libm/w_j1.c deleted file mode 100644 index 389dc156c..000000000 --- a/libm/w_j1.c +++ /dev/null @@ -1,70 +0,0 @@ -/* @(#)w_j1.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_j1.c,v 1.6 1995/05/10 20:49:15 jtc Exp $"; -#endif - -/* - * wrapper of j1,y1 - */ - -#include "math.h" -#include "math_private.h" - -#ifdef __STDC__ - double j1(double x) /* wrapper j1 */ -#else - double j1(x) /* wrapper j1 */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_j1(x); -#else - double z; - z = __ieee754_j1(x); - if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; - if(fabs(x)>X_TLOSS) { - return __kernel_standard(x,x,36); /* j1(|x|>X_TLOSS) */ - } else - return z; -#endif -} - -#ifdef __STDC__ - double y1(double x) /* wrapper y1 */ -#else - double y1(x) /* wrapper y1 */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_y1(x); -#else - double z; - z = __ieee754_y1(x); - if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; - if(x <= 0.0){ - if(x==0.0) - /* d= -one/(x-x); */ - return __kernel_standard(x,x,10); - else - /* d = zero/(x-x); */ - return __kernel_standard(x,x,11); - } - if(x>X_TLOSS) { - return __kernel_standard(x,x,37); /* y1(x>X_TLOSS) */ - } else - return z; -#endif -} diff --git a/libm/w_jn.c b/libm/w_jn.c deleted file mode 100644 index 173f6aa9e..000000000 --- a/libm/w_jn.c +++ /dev/null @@ -1,92 +0,0 @@ -/* @(#)w_jn.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_jn.c,v 1.6 1995/05/10 20:49:19 jtc Exp $"; -#endif - -/* - * wrapper jn(int n, double x), yn(int n, double x) - * floating point Bessel's function of the 1st and 2nd kind - * of order n - * - * Special cases: - * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; - * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. - * Note 2. About jn(n,x), yn(n,x) - * For n=0, j0(x) is called, - * for n=1, j1(x) is called, - * for n<x, forward recursion us used starting - * from values of j0(x) and j1(x). - * for n>x, a continued fraction approximation to - * j(n,x)/j(n-1,x) is evaluated and then backward - * recursion is used starting from a supposed value - * for j(n,x). The resulting value of j(0,x) is - * compared with the actual value to correct the - * supposed value of j(n,x). - * - * yn(n,x) is similar in all respects, except - * that forward recursion is used for all - * values of n>1. - * - */ - -#include "math.h" -#include "math_private.h" - -#ifdef __STDC__ - double jn(int n, double x) /* wrapper jn */ -#else - double jn(n,x) /* wrapper jn */ - double x; int n; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_jn(n,x); -#else - double z; - z = __ieee754_jn(n,x); - if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; - if(fabs(x)>X_TLOSS) { - return __kernel_standard((double)n,x,38); /* jn(|x|>X_TLOSS,n) */ - } else - return z; -#endif -} - -#ifdef __STDC__ - double yn(int n, double x) /* wrapper yn */ -#else - double yn(n,x) /* wrapper yn */ - double x; int n; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_yn(n,x); -#else - double z; - z = __ieee754_yn(n,x); - if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z; - if(x <= 0.0){ - if(x==0.0) - /* d= -one/(x-x); */ - return __kernel_standard((double)n,x,12); - else - /* d = zero/(x-x); */ - return __kernel_standard((double)n,x,13); - } - if(x>X_TLOSS) { - return __kernel_standard((double)n,x,39); /* yn(x>X_TLOSS,n) */ - } else - return z; -#endif -} diff --git a/libm/w_lgamma.c b/libm/w_lgamma.c deleted file mode 100644 index de0394b5e..000000000 --- a/libm/w_lgamma.c +++ /dev/null @@ -1,51 +0,0 @@ -/* @(#)w_lgamma.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_lgamma.c,v 1.6 1995/05/10 20:49:24 jtc Exp $"; -#endif - -/* double lgamma(double x) - * Return the logarithm of the Gamma function of x. - * - * Method: call __ieee754_lgamma_r - */ - -#include <math.h> -#include "math_private.h" - -libm_hidden_proto(signgam) - -libm_hidden_proto(lgamma) -#ifdef __STDC__ - double lgamma(double x) -#else - double lgamma(x) - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_lgamma_r(x,&signgam); -#else - double y; - y = __ieee754_lgamma_r(x,&signgam); - if(_LIB_VERSION == _IEEE_) return y; - if(!finite(y)&&finite(x)) { - if(floor(x)==x&&x<=0.0) - return __kernel_standard(x,x,15); /* lgamma pole */ - else - return __kernel_standard(x,x,14); /* lgamma overflow */ - } else - return y; -#endif -} -libm_hidden_def(lgamma) diff --git a/libm/w_lgamma_r.c b/libm/w_lgamma_r.c deleted file mode 100644 index 6ca56d6da..000000000 --- a/libm/w_lgamma_r.c +++ /dev/null @@ -1,46 +0,0 @@ -/* @(#)wr_lgamma.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_lgamma_r.c,v 1.6 1995/05/10 20:49:27 jtc Exp $"; -#endif - -/* - * wrapper double lgamma_r(double x, int *signgamp) - */ - -#include "math.h" -#include "math_private.h" - - -#ifdef __STDC__ - double lgamma_r(double x, int *signgamp) /* wrapper lgamma_r */ -#else - double lgamma_r(x,signgamp) /* wrapper lgamma_r */ - double x; int *signgamp; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_lgamma_r(x,signgamp); -#else - double y; - y = __ieee754_lgamma_r(x,signgamp); - if(_LIB_VERSION == _IEEE_) return y; - if(!finite(y)&&finite(x)) { - if(floor(x)==x&&x<=0.0) - return __kernel_standard(x,x,15); /* lgamma pole */ - else - return __kernel_standard(x,x,14); /* lgamma overflow */ - } else - return y; -#endif -} diff --git a/libm/w_log.c b/libm/w_log.c deleted file mode 100644 index 12c8282d5..000000000 --- a/libm/w_log.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_log.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_log.c,v 1.6 1995/05/10 20:49:33 jtc Exp $"; -#endif - -/* - * wrapper log(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(log) -#ifdef __STDC__ - double log(double x) /* wrapper log */ -#else - double log(x) /* wrapper log */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_log(x); -#else - double z; - z = __ieee754_log(x); - if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z; - if(x==0.0) - return __kernel_standard(x,x,16); /* log(0) */ - else - return __kernel_standard(x,x,17); /* log(x<0) */ -#endif -} -libm_hidden_def(log) diff --git a/libm/w_log10.c b/libm/w_log10.c deleted file mode 100644 index cf52f6e65..000000000 --- a/libm/w_log10.c +++ /dev/null @@ -1,47 +0,0 @@ -/* @(#)w_log10.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_log10.c,v 1.6 1995/05/10 20:49:35 jtc Exp $"; -#endif - -/* - * wrapper log10(X) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(log10) -#ifdef __STDC__ - double log10(double x) /* wrapper log10 */ -#else - double log10(x) /* wrapper log10 */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_log10(x); -#else - double z; - z = __ieee754_log10(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(x<=0.0) { - if(x==0.0) - return __kernel_standard(x,x,18); /* log10(0) */ - else - return __kernel_standard(x,x,19); /* log10(x<0) */ - } else - return z; -#endif -} -libm_hidden_def(log10) diff --git a/libm/w_pow.c b/libm/w_pow.c deleted file mode 100644 index 89cd08f73..000000000 --- a/libm/w_pow.c +++ /dev/null @@ -1,62 +0,0 @@ - - -/* @(#)w_pow.c 5.2 93/10/01 */ -/* - * ==================================================== - * 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. - * ==================================================== - */ - -/* - * wrapper pow(x,y) return x**y - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(pow) -#ifdef __STDC__ - double pow(double x, double y) /* wrapper pow */ -#else - double pow(x,y) /* wrapper pow */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_pow(x,y); -#else - double z; - z=__ieee754_pow(x,y); - if(_LIB_VERSION == _IEEE_|| isnan(y)) return z; - if(isnan(x)) { - if(y==0.0) - return __kernel_standard(x,y,42); /* pow(NaN,0.0) */ - else - return z; - } - if(x==0.0){ - if(y==0.0) - return __kernel_standard(x,y,20); /* pow(0.0,0.0) */ - if(finite(y)&&y<0.0) - return __kernel_standard(x,y,23); /* pow(0.0,negative) */ - return z; - } - if(!finite(z)) { - if(finite(x)&&finite(y)) { - if(isnan(z)) - return __kernel_standard(x,y,24); /* pow neg**non-int */ - else - return __kernel_standard(x,y,21); /* pow overflow */ - } - } - if(z==0.0&&finite(x)&&finite(y)) - return __kernel_standard(x,y,22); /* pow underflow */ - return z; -#endif -} -libm_hidden_def(pow) diff --git a/libm/w_remainder.c b/libm/w_remainder.c deleted file mode 100644 index be3dd02c9..000000000 --- a/libm/w_remainder.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_remainder.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_remainder.c,v 1.6 1995/05/10 20:49:44 jtc Exp $"; -#endif - -/* - * wrapper remainder(x,p) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(remainder) -#ifdef __STDC__ - double remainder(double x, double y) /* wrapper remainder */ -#else - double remainder(x,y) /* wrapper remainder */ - double x,y; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_remainder(x,y); -#else - double z; - z = __ieee754_remainder(x,y); - if(_LIB_VERSION == _IEEE_ || isnan(y)) return z; - if(y==0.0) - return __kernel_standard(x,y,28); /* remainder(x,0) */ - else - return z; -#endif -} -libm_hidden_def(remainder) diff --git a/libm/w_scalb.c b/libm/w_scalb.c deleted file mode 100644 index a5f88de39..000000000 --- a/libm/w_scalb.c +++ /dev/null @@ -1,60 +0,0 @@ -/* @(#)w_scalb.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_scalb.c,v 1.6 1995/05/10 20:49:48 jtc Exp $"; -#endif - -/* - * wrapper scalb(double x, double fn) is provide for - * passing various standard test suite. One - * should use scalbn() instead. - */ - -#include <math.h> -#include "math_private.h" - -#include <errno.h> - -#ifdef __STDC__ -#ifdef _SCALB_INT - double scalb(double x, int fn) /* wrapper scalb */ -#else - double scalb(double x, double fn) /* wrapper scalb */ -#endif -#else - double scalb(x,fn) /* wrapper scalb */ -#ifdef _SCALB_INT - double x; int fn; -#else - double x,fn; -#endif -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_scalb(x,fn); -#else - double z; - z = __ieee754_scalb(x,fn); - if(_LIB_VERSION == _IEEE_) return z; - if(!(finite(z)||isnan(z))&&finite(x)) { - return __kernel_standard(x,(double)fn,32); /* scalb overflow */ - } - if(z==0.0&&z!=x) { - return __kernel_standard(x,(double)fn,33); /* scalb underflow */ - } -#ifndef _SCALB_INT - if(!finite(fn)) errno = ERANGE; -#endif - return z; -#endif -} diff --git a/libm/w_sinh.c b/libm/w_sinh.c deleted file mode 100644 index bed9bb3f9..000000000 --- a/libm/w_sinh.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_sinh.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_sinh.c,v 1.6 1995/05/10 20:49:51 jtc Exp $"; -#endif - -/* - * wrapper sinh(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(sinh) -#ifdef __STDC__ - double sinh(double x) /* wrapper sinh */ -#else - double sinh(x) /* wrapper sinh */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_sinh(x); -#else - double z; - z = __ieee754_sinh(x); - if(_LIB_VERSION == _IEEE_) return z; - if(!finite(z)&&finite(x)) { - return __kernel_standard(x,x,25); /* sinh overflow */ - } else - return z; -#endif -} -libm_hidden_def(sinh) diff --git a/libm/w_sqrt.c b/libm/w_sqrt.c deleted file mode 100644 index 0a37249b1..000000000 --- a/libm/w_sqrt.c +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)w_sqrt.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. - * ==================================================== - */ - -#if defined(LIBM_SCCS) && !defined(lint) -static char rcsid[] = "$NetBSD: w_sqrt.c,v 1.6 1995/05/10 20:49:55 jtc Exp $"; -#endif - -/* - * wrapper sqrt(x) - */ - -#include "math.h" -#include "math_private.h" - -libm_hidden_proto(sqrt) -#ifdef __STDC__ - double sqrt(double x) /* wrapper sqrt */ -#else - double sqrt(x) /* wrapper sqrt */ - double x; -#endif -{ -#ifdef _IEEE_LIBM - return __ieee754_sqrt(x); -#else - double z; - z = __ieee754_sqrt(x); - if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; - if(x<0.0) { - return __kernel_standard(x,x,26); /* sqrt(negative) */ - } else - return z; -#endif -} -libm_hidden_def(sqrt) |
