From a0ebeb988d63d94da086b72daf0691f67584724a Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Mon, 22 Dec 2008 11:31:12 +0000 Subject: - fix fpclassify, signbit, isfinite, isnan, isinf macros for long double math support - add rule to create preprocessor output for float- and long double math wrapper --- libm/Makefile.in | 39 ++++++++++++++++++++-------------- libm/e_scalb.c | 2 +- libm/float_wrappers.c | 10 ++++++++- libm/ldouble_wrappers.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ libm/s_finite.c | 2 -- libm/s_finitef.c | 2 -- libm/s_fma.c | 6 ++---- libm/s_fpclassify.c | 2 +- libm/s_fpclassifyf.c | 6 ++---- libm/s_isinf.c | 2 -- libm/s_isinff.c | 2 -- libm/s_isnan.c | 9 +------- libm/s_isnanf.c | 4 +--- libm/s_ldexp.c | 4 ++-- libm/s_signbitf.c | 1 - libm/s_significand.c | 1 - libm/w_drem.c | 1 - libm/w_exp.c | 2 +- libm/w_gamma.c | 3 +-- libm/w_gamma_r.c | 2 +- libm/w_hypot.c | 2 +- libm/w_j0.c | 2 -- libm/w_j1.c | 2 -- libm/w_jn.c | 2 -- libm/w_lgamma.c | 2 +- libm/w_lgamma_r.c | 3 +-- libm/w_log2.c | 1 - libm/w_pow.c | 8 +++---- libm/w_scalb.c | 5 ++--- libm/w_sinh.c | 2 +- libm/w_tgamma.c | 2 +- 31 files changed, 112 insertions(+), 75 deletions(-) (limited to 'libm') diff --git a/libm/Makefile.in b/libm/Makefile.in index 9ddd8c8a5..b490ec8bf 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -86,13 +86,13 @@ FL_MOBJ := \ scalblnf.o scalbnf.o sinf.o sinhf.o sqrtf.o tanf.o tanhf.o \ tgammaf.o truncf.o cargf.o llrintf.o -LD_MOBJ := acoshl.o acosl.o asinhl.o asinl.o atan2l.o atanhl.o atanl.o cbrtl.o \ +LD_MOBJ := 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 \ + expm1l.o fabsl.o finitel.o fdiml.o floorl.o fmal.o fmaxl.o fminl.o fmodl.o fpclassifyl.o \ + frexpl.o gammal.o hypotl.o ilogbl.o isinfl.o isnanl.o ldexpl.o lgammal.o llrintl.o \ llroundl.o log10l.o log1pl.o XXXlog2l.o logbl.o logl.o lrintl.o lroundl.o \ modfl.o nearbyintl.o nextafterl.o XXXnexttowardl.o powl.o remainderl.o \ - remquol.o rintl.o roundl.o scalblnl.o scalbnl.o sinhl.o sinl.o sqrtl.o \ + remquol.o rintl.o roundl.o scalblnl.o scalbnl.o signbitl.o sinhl.o sinl.o sqrtl.o \ tanhl.o tanl.o tgammal.o truncl.o else # This list of math functions was taken from POSIX/IEEE 1003.1b-1993 @@ -139,21 +139,21 @@ libm_SRC := $(patsubst %.c,$(libm_DIR)/%.c,$(libm_CSRC)) libm_OBJ := $(patsubst $(libm_DIR)/%.c,$(libm_OUT)/%.o,$(libm_SRC)) ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y) -libm_MSRC2 := $(libm_DIR)/$(LD_MSRC) -libm_MOBJ2 := $(patsubst %.o,$(libm_OUT)/%.o,$(LD_MOBJ)) +libm_MSRC_LD := $(libm_DIR)/$(LD_MSRC) +libm_MOBJ_LD := $(patsubst %.o,$(libm_OUT)/%.o,$(LD_MOBJ)) endif -libm_MSRC := $(libm_DIR)/$(FL_MSRC) -libm_MOBJ := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ)) +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_MOBJ2)))) +CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ_LD)))) endif endif -libm_OBJS := $(libm_OBJ) $(libm_MOBJ) $(libm_MOBJ2) +libm_OBJS := $(libm_OBJ) $(libm_MOBJ_FL) $(libm_MOBJ_LD) ifeq ($(DOPIC),y) libm-a-y += $(libm_OBJS:.o=.os) @@ -182,7 +182,7 @@ $(libm_OUT)/libm_so.a: $(libm-so-y) $(Q)$(RM) $@ $(do_ar) -$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC) $(libm_MSRC2) $(libm_ARCH_SRC) +$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC_FL) $(libm_MSRC_LD) $(libm_ARCH_SRC) $(Q)$(RM) $@ $(compile-m) @@ -191,17 +191,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_MOBJ2): $(libm_MSRC2) +$(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_MOBJ2:.o=.os): $(libm_MSRC2) +$(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) + libm_clean: $(do_rm) $(addprefix $(libm_OUT)/,$(foreach e, o os oS a,$(foreach d, *. */*. */*/*.,$(d)$(e)))) diff --git a/libm/e_scalb.c b/libm/e_scalb.c index 2f0dba14a..33eaeeac6 100644 --- a/libm/e_scalb.c +++ b/libm/e_scalb.c @@ -44,7 +44,7 @@ static char rcsid[] = "$NetBSD: e_scalb.c,v 1.6 1995/05/10 20:46:09 jtc Exp $"; 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); } diff --git a/libm/float_wrappers.c b/libm/float_wrappers.c index 26041d088..36efcfbea 100644 --- a/libm/float_wrappers.c +++ b/libm/float_wrappers.c @@ -39,6 +39,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); @@ -136,7 +137,7 @@ float atanhf (float x) #ifdef L_cargf float cargf (float complex x) { - return (float) carg( (double)x ); + return (float) carg( (double complex)x ); } #endif @@ -535,3 +536,10 @@ float truncf (float x) return (float) trunc( (double)x ); } #endif + +#ifdef L_fmaf +float fmaf (float x, float y, float z) +{ + return (float) fma( (double)x, (double)y, (double)z ); +} +#endif diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c index 62732bae9..a4f13f429 100644 --- a/libm/ldouble_wrappers.c +++ b/libm/ldouble_wrappers.c @@ -14,6 +14,8 @@ /* Prevent math.h from defining colliding inlines */ #undef __USE_EXTERN_INLINES #include "math.h" +#include + /* Implement the following, as defined by SuSv3 */ #if 0 @@ -24,6 +26,7 @@ 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); @@ -131,6 +134,14 @@ long double atanl (long double x) #endif +#ifdef L_cargl +long double cargl (long double complex x) +{ + return (long double) carg( (double complex)x ); +} +#endif + + #ifdef L_cbrtl long double cbrtl (long double x) { @@ -524,3 +535,48 @@ long double truncl (long double x) return (long double) trunc( (double)x ); } #endif + + +#ifdef __DO_C99_MATH__ + +#ifdef L_fpclassifyl +int __fpclassifyl (long double x) +{ + return __fpclassify ( (double) x ); +} +libm_hidden_def(__fpclassifyl) +#endif + +#ifdef L_finitel +int __finitel (long double x) +{ + return __finite ( (double)x ); +} +libm_hidden_def(__finitel) +#endif + +#ifdef L_signbitl +int __signbitl (long double x) +{ + return __signbitl ( (double)x ); +} +libm_hidden_def(__signbitl) +#endif + +#ifdef L_isnanl +int __isnanl (long double x) +{ + return __isnan ( (double)x ); +} +libm_hidden_def(__isnanl) +#endif + +#ifdef L_isinfl +int __isinfl (long double x) +{ + return __isinf ( (double)x ); +} +libm_hidden_def(__isinfl) +#endif + +#endif diff --git a/libm/s_finite.c b/libm/s_finite.c index 2235d0a42..357c3d4af 100644 --- a/libm/s_finite.c +++ b/libm/s_finite.c @@ -28,5 +28,3 @@ int __finite(double x) return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31); } libm_hidden_def(__finite) -weak_alias(__finite,finite) -libm_hidden_weak(finite) diff --git a/libm/s_finitef.c b/libm/s_finitef.c index 66eba8f98..b7c853d4a 100644 --- a/libm/s_finitef.c +++ b/libm/s_finitef.c @@ -21,7 +21,6 @@ #include "math.h" #include "math_private.h" -libm_hidden_proto(__finitef) int __finitef(float x) { int32_t ix; @@ -29,4 +28,3 @@ int __finitef(float x) return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31); } libm_hidden_def(__finitef) -strong_alias(__finitef,finitef) diff --git a/libm/s_fma.c b/libm/s_fma.c index f9e8cf974..7a87fbdd3 100644 --- a/libm/s_fma.c +++ b/libm/s_fma.c @@ -20,11 +20,9 @@ #include -libm_hidden_proto(__fma) double -__fma (double x, double y, double z) +fma (double x, double y, double z) { return (x * y) + z; } -libm_hidden_def(__fma) -strong_alias (__fma, fma) +libm_hidden_def(fma) diff --git a/libm/s_fpclassify.c b/libm/s_fpclassify.c index d2c4c8232..f2d6736e3 100644 --- a/libm/s_fpclassify.c +++ b/libm/s_fpclassify.c @@ -40,4 +40,4 @@ __fpclassify (double x) return retval; } -libm_hidden_def (__fpclassify) +libm_hidden_def(__fpclassify) diff --git a/libm/s_fpclassifyf.c b/libm/s_fpclassifyf.c index edc0db635..23ae59f18 100644 --- a/libm/s_fpclassifyf.c +++ b/libm/s_fpclassifyf.c @@ -21,9 +21,7 @@ #include #include "math_private.h" -libm_hidden_proto(__fpclassifyf) -int -__fpclassifyf (float x) +int __fpclassifyf (float x) { u_int32_t wx; int retval = FP_NORMAL; @@ -39,4 +37,4 @@ __fpclassifyf (float x) return retval; } -libm_hidden_def (__fpclassifyf) +libm_hidden_def(__fpclassifyf) diff --git a/libm/s_isinf.c b/libm/s_isinf.c index 99a1cdf18..b73aa6696 100644 --- a/libm/s_isinf.c +++ b/libm/s_isinf.c @@ -22,5 +22,3 @@ __isinf (double x) return ~(lx >> 31) & (hx >> 30); } libm_hidden_def(__isinf) -weak_alias (__isinf, isinf) -libm_hidden_weak(isinf) diff --git a/libm/s_isinff.c b/libm/s_isinff.c index 6827024af..e25912834 100644 --- a/libm/s_isinff.c +++ b/libm/s_isinff.c @@ -11,7 +11,6 @@ #include "math.h" #include "math_private.h" -libm_hidden_proto(__isinff) int __isinff (float x) { @@ -23,4 +22,3 @@ __isinff (float x) return ~(t >> 31) & (ix >> 30); } libm_hidden_def(__isinff) -strong_alias (__isinff, isinff) diff --git a/libm/s_isnan.c b/libm/s_isnan.c index 671c5cb2e..51ed94e04 100644 --- a/libm/s_isnan.c +++ b/libm/s_isnan.c @@ -18,12 +18,7 @@ #include "math.h" #include "math_private.h" -#ifdef __STDC__ - int __isnan(double x) -#else - int __isnan(x) - double x; -#endif +int __isnan(double x) { int32_t hx,lx; EXTRACT_WORDS(hx,lx,x); @@ -33,5 +28,3 @@ return (int)(((u_int32_t)hx)>>31); } libm_hidden_def(__isnan) -weak_alias(__isnan,isnan) -libm_hidden_weak(isnan) diff --git a/libm/s_isnanf.c b/libm/s_isnanf.c index 6afa5df06..d868264f7 100644 --- a/libm/s_isnanf.c +++ b/libm/s_isnanf.c @@ -21,7 +21,6 @@ #include "math.h" #include "math_private.h" -libm_hidden_proto(__isnanf) int __isnanf(float x) { int32_t ix; @@ -30,5 +29,4 @@ int __isnanf(float x) ix = 0x7f800000 - ix; return (int)(((u_int32_t)(ix))>>31); } -libm_hidden_def (__isnanf) -weak_alias (__isnanf, isnanf) +libm_hidden_def(__isnanf) diff --git a/libm/s_ldexp.c b/libm/s_ldexp.c index a065f5ada..02dae6fcf 100644 --- a/libm/s_ldexp.c +++ b/libm/s_ldexp.c @@ -26,9 +26,9 @@ static char rcsid[] = "$NetBSD: s_ldexp.c,v 1.6 1995/05/10 20:47:40 jtc Exp $"; double value; int exp; #endif { - if(!finite(value)||value==0.0) return value; + if(!isfinite(value)||value==0.0) return value; value = scalbn(value,exp); - if(!finite(value)||value==0.0) errno = ERANGE; + if(!isfinite(value)||value==0.0) errno = ERANGE; return value; } libm_hidden_def(ldexp) diff --git a/libm/s_signbitf.c b/libm/s_signbitf.c index 3a5cf0c2a..a15e26a09 100644 --- a/libm/s_signbitf.c +++ b/libm/s_signbitf.c @@ -24,7 +24,6 @@ #include #include "math_private.h" -libm_hidden_proto(__signbitf) int __signbitf (float x) { diff --git a/libm/s_significand.c b/libm/s_significand.c index 2a7980a44..100ac0889 100644 --- a/libm/s_significand.c +++ b/libm/s_significand.c @@ -33,4 +33,3 @@ static char rcsid[] = "$NetBSD: s_significand.c,v 1.6 1995/05/10 20:48:11 jtc Ex { return __ieee754_scalb(x,(double) -ilogb(x)); } -libm_hidden_def(significand) diff --git a/libm/w_drem.c b/libm/w_drem.c index 6b3dd3937..4f9127b1e 100644 --- a/libm/w_drem.c +++ b/libm/w_drem.c @@ -12,4 +12,3 @@ double drem(double x, double y) { return remainder(x, y); } -libm_hidden_def(drem) diff --git a/libm/w_exp.c b/libm/w_exp.c index e11222499..067279664 100644 --- a/libm/w_exp.c +++ b/libm/w_exp.c @@ -42,7 +42,7 @@ u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ double z; z = __ieee754_exp(x); if(_LIB_VERSION == _IEEE_) return z; - if(finite(x)) { + if(isfinite(x)) { if(x>o_threshold) return __kernel_standard(x,x,6); /* exp overflow */ else if(x