diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-10-03 14:24:28 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-10-03 14:24:28 +0000 |
commit | feeb0301b31a5ad4ea0594b17e4720bbe3308a3b (patch) | |
tree | ae71a3f81309a3068335ec30f021333454bccbc6 /libm | |
parent | 2ba017a2d5af01cc3ef0dc554252a521e8d7c4f8 (diff) |
- add long double math wrappers (Ned Ludd)
Diffstat (limited to 'libm')
-rw-r--r-- | libm/Makefile.in | 30 | ||||
-rw-r--r-- | libm/ldouble_wrappers.c | 523 | ||||
-rw-r--r-- | libm/nan.c | 1 |
3 files changed, 552 insertions, 2 deletions
diff --git a/libm/Makefile.in b/libm/Makefile.in index 98e3aafe4..7e72d8add 100644 --- a/libm/Makefile.in +++ b/libm/Makefile.in @@ -52,6 +52,7 @@ endif endif FL_MSRC := float_wrappers.c +LD_MSRC := ldouble_wrappers.c ifeq ($(DO_C99_MATH),y) libm_CSRC := \ @@ -84,6 +85,15 @@ FL_MOBJ := \ nextafterf.o powf.o remainderf.o remquof.o rintf.o roundf.o \ scalblnf.o scalbnf.o sinf.o sinhf.o sqrtf.o tanf.o tanhf.o \ tgammaf.o truncf.o cargf.o llrintf.o + +LD_MOBJ := acoshl.o acosl.o asinhl.o asinl.o atan2l.o atanhl.o atanl.o cbrtl.o \ + ceill.o copysignl.o coshl.o cosl.o erfcl.o erfl.o exp2l.o expl.o \ + expm1l.o fabsl.o fdiml.o floorl.o fmal.o fmaxl.o fminl.o fmodl.o \ + frexpl.o gammal.o hypotl.o ilogbl.o ldexpl.o lgammal.o llrintl.o \ + llroundl.o log10l.o log1pl.o XXXlog2l.o logbl.o logl.o lrintl.o lroundl.o \ + modfl.o nearbyintl.o nextafterl.o XXXnexttowardl.o powl.o remainderl.o \ + remquol.o rintl.o roundl.o scalblnl.o scalbnl.o sinhl.o sinl.o sqrtl.o \ + tanhl.o tanl.o tgammal.o truncl.o else # This list of math functions was taken from POSIX/IEEE 1003.1b-1993 libm_CSRC := \ @@ -116,9 +126,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 @@ -126,14 +138,22 @@ endif libm_SRC := $(patsubst %.c,$(libm_DIR)/%.c,$(libm_CSRC)) libm_OBJ := $(patsubst $(libm_DIR)/%.c,$(libm_OUT)/%.o,$(libm_SRC)) +ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y) +libm_MSRC2 := $(libm_DIR)/$(LD_MSRC) +libm_MOBJ2 := $(patsubst %.o,$(libm_OUT)/%.o,$(LD_MOBJ)) +endif libm_MSRC := $(libm_DIR)/$(FL_MSRC) libm_MOBJ := $(patsubst %.o,$(libm_OUT)/%.o,$(FL_MOBJ)) + ifneq ($(DOMULTI),n) CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ)))) +ifeq ($(strip $(UCLIBC_HAS_LONG_DOUBLE_MATH)),y) +CFLAGS-libm += $(patsubst %,-DL_%,$(subst .o,,$(notdir $(libm_MOBJ2)))) +endif endif -libm_OBJS := $(libm_OBJ) $(libm_MOBJ) +libm_OBJS := $(libm_OBJ) $(libm_MOBJ) $(libm_MOBJ2) ifeq ($(DOPIC),y) libm-a-y += $(libm_OBJS:.o=.os) @@ -162,7 +182,7 @@ $(libm_OUT)/libm_so.a: $(libm-so-y) $(Q)$(RM) $@ $(do_ar) -$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC) $(libm_ARCH_SRC) +$(libm_OUT)/libm.oS: $(libm_SRC) $(libm_MSRC) $(libm_MSRC2) $(libm_ARCH_SRC) $(Q)$(RM) $@ $(compile-m) @@ -174,8 +194,14 @@ $(top_builddir)lib/libm.a: $(libm-a-y) $(libm_MOBJ): $(libm_MSRC) $(compile.m) +$(libm_MOBJ2): $(libm_MSRC2) + $(compile.m) + $(libm_MOBJ:.o=.os): $(libm_MSRC) $(compile.m) +$(libm_MOBJ2:.o=.os): $(libm_MSRC2) + $(compile.m) + libm_clean: $(RM) $(libm_OUT)/{,*/,*/*/}*.{o,os,oS,a} diff --git a/libm/ldouble_wrappers.c b/libm/ldouble_wrappers.c new file mode 100644 index 000000000..d82436da4 --- /dev/null +++ b/libm/ldouble_wrappers.c @@ -0,0 +1,523 @@ +/* vi: set sw=4 ts=4: */ +/* + * Wrapper functions implementing all the long double math functions + * defined by SuSv3 by actually calling the double version of + * each function and then casting the result back to a long double + * to return to the user. + * + * Copyright (C) 2005 by Erik Andersen <andersen@uclibc.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include "math.h" + +/* Implement the following, as defined by SuSv3 */ +#if 0 +long double acoshl(long double); +long double acosl(long double); +long double asinhl(long double); +long double asinl(long double); +long double atan2l(long double, long double); +long double atanhl(long double); +long double atanl(long double); +long double cbrtl(long double); +long double ceill(long double); +long double copysignl(long double, long double); +long double coshl(long double); +long double cosl(long double); +long double erfcl(long double); +long double erfl(long double); +long double exp2l(long double); +long double expl(long double); +long double expm1l(long double); +long double fabsl(long double); +long double fdiml(long double, long double); +long double floorl(long double); +long double fmal(long double, long double, long double); +long double fmaxl(long double, long double); +long double fminl(long double, long double); +long double fmodl(long double, long double); +long double frexpl(long double value, int *); +long double hypotl(long double, long double); +int ilogbl(long double); +long double ldexpl(long double, int); +long double lgammal(long double); +long long llrintl(long double); +long long llroundl(long double); +long double log10l(long double); +long double log1pl(long double); +long double log2l(long double); +long double logbl(long double); +long double logl(long double); +long lrintl(long double); +long lroundl(long double); +long double modfl(long double, long double *); +long double nearbyintl(long double); +long double nextafterl(long double, long double); +long double nexttowardl(long double, long double); +long double powl(long double, long double); +long double remainderl(long double, long double); +long double remquol(long double, long double, int *); +long double rintl(long double); +long double roundl(long double); +long double scalblnl(long double, long); +long double scalbnl(long double, int); +long double sinhl(long double); +long double sinl(long double); +long double sqrtl(long double); +long double tanhl(long double); +long double tanl(long double); +long double tgammal(long double); +long double truncl(long double); +#endif + +#ifdef L_acoshl +long double acoshl (long double x) +{ + return (long double) acosh( (double)x ); +} +#endif + + +#ifdef L_acosl +long double acosl (long double x) +{ + return (long double) acos( (double)x ); +} +#endif + + +#ifdef L_asinhl +long double asinhl (long double x) +{ + return (long double) asinh( (double)x ); +} +#endif + + +#ifdef L_asinl +long double asinl (long double x) +{ + return (long double) asin( (double)x ); +} +#endif + + +#ifdef L_atan2l +long double atan2l (long double x, long double y) +{ + return (long double) atan2( (double)x, (double)y ); +} +#endif + + +#ifdef L_atanhl +long double atanhl (long double x) +{ + return (long double) atanh( (double)x ); +} +#endif + + +#ifdef L_atanl +long double atanl (long double x) +{ + return (long double) atan( (double)x ); +} +#endif + + +#ifdef L_cbrtl +long double cbrtl (long double x) +{ + return (long double) cbrt( (double)x ); +} +#endif + + +#ifdef L_ceill +long double ceill (long double x) +{ + return (long double) ceil( (double)x ); +} +#endif + + +#ifdef L_copysignl +long double copysignl (long double x, long double y) +{ + return (long double) copysign( (double)x, (double)y ); +} +#endif + + +#ifdef L_coshl +long double coshl (long double x) +{ + return (long double) cosh( (double)x ); +} +#endif + + +#ifdef L_cosl +long double cosl (long double x) +{ + return (long double) cos( (double)x ); +} +#endif + + +#ifdef L_erfcl +long double erfcl (long double x) +{ + return (long double) erfc( (double)x ); +} +#endif + + +#ifdef L_erfl +long double erfl (long double x) +{ + return (long double) erf( (double)x ); +} +#endif + + +#ifdef L_exp2l +long double exp2l (long double x) +{ + return (long double) exp2( (double)x ); +} +#endif + + +#ifdef L_expl +long double expl (long double x) +{ + return (long double) exp( (double)x ); +} +#endif + + +#ifdef L_expm1l +long double expm1l (long double x) +{ + return (long double) expm1( (double)x ); +} +#endif + + +#ifdef L_fabsl +long double fabsl (long double x) +{ + return (long double) fabs( (double)x ); +} +#endif + + +#ifdef L_fdiml +long double fdiml (long double x, long double y) +{ + return (long double) fdim( (double)x, (double)y ); +} +#endif + + +#ifdef L_floorl +long double floorl (long double x) +{ + return (long double) floor( (double)x ); +} +#endif + + +#ifdef L_fmal +long double fmal (long double x, long double y, long double z) +{ + return (long double) fma( (double)x, (double)y, (double)z ); +} +#endif + + +#ifdef L_fmaxl +long double fmaxl (long double x, long double y) +{ + return (long double) fmax( (double)x, (double)y ); +} +#endif + + +#ifdef L_fminl +long double fminl (long double x, long double y) +{ + return (long double) fmin( (double)x, (double)y ); +} +#endif + + +#ifdef L_fmodl +long double fmodl (long double x, long double y) +{ + return (long double) fmod( (double)x, (double)y ); +} +#endif + + +#ifdef L_frexpl +long double frexpl (long double x, int *exp) +{ + return (long double) frexp( (double)x, exp ); +} +#endif + + +#ifdef L_hypotl +long double hypotl (long double x, long double y) +{ + return (long double) hypot( (double)x, (double)y ); +} +#endif + + +#ifdef L_ilogbl +int ilogbl (long double x) +{ + return (long double) ilogb( (double)x ); +} +#endif + + +#ifdef L_ldexpl +long double ldexpl (long double x, int exp) +{ + return (long double) ldexp( (double)x, exp ); +} +#endif + + +#ifdef L_lgammal +long double lgammal (long double x) +{ + return (long double) lgamma( (double)x ); +} +#endif + + +#ifdef L_llrintl +long long llrintl (long double x) +{ + return (long double) llrint( (double)x ); +} +#endif + + +#ifdef L_llroundl +long long llroundl (long double x) +{ + return (long double) llround( (double)x ); +} +#endif + +#ifdef L_log10l +long double log10l (long double x) +{ + return (long double) log10( (double)x ); +} +#endif + + +#ifdef L_log1pl +long double log1pl (long double x) +{ + return (long double) log1p( (double)x ); +} +#endif + + +#ifdef L_log2l +long double log2l (long double x) +{ + return (long double) log2( (double)x ); +} +#endif + + +#ifdef L_logbl +long double logbl (long double x) +{ + return (long double) logb( (double)x ); +} +#endif + + +#ifdef L_logl +long double logl (long double x) +{ + return (long double) log( (double)x ); +} +#endif + + +#ifdef L_lrintl +long lrintl (long double x) +{ + return (long double) lrint( (double)x ); +} +#endif + + +#ifdef L_lroundl +long lroundl (long double x) +{ + return (long double) lround( (double)x ); +} +#endif + + +#ifdef L_modfl +long double modfl (long double x, long double *iptr) +{ + double y, result; + result = modf ( x, &y ); + *iptr = (long double)y; + return (long double) result; + +} +#endif + + +#ifdef L_nearbyintl +long double nearbyintl (long double x) +{ + return (long double) nearbyint( (double)x ); +} +#endif + + +#ifdef L_nextafterl +long double nextafterl (long double x, long double y) +{ + return (long double) nextafter( (double)x, (double)y ); +} +#endif + + +#ifdef L_nexttowardl +long double nexttowardl (long double x, long double y) +{ + return (long double) nexttoward( (double)x, (double)y ); +} +#endif + + +#ifdef L_powl +long double powl (long double x, long double y) +{ + return (long double) pow( (double)x, (double)y ); +} +#endif + + +#ifdef L_remainderl +long double remainderl (long double x, long double y) +{ + return (long double) remainder( (double)x, (double)y ); +} +#endif + + +#ifdef L_remquol +long double remquol (long double x, long double y, int *quo) +{ + return (long double) remquo( (double)x, (double)y, quo ); +} +#endif + + +#ifdef L_rintl +long double rintl (long double x) +{ + return (long double) rint( (double)x ); +} +#endif + + +#ifdef L_roundl +long double roundl (long double x) +{ + return (long double) round( (double)x ); +} +#endif + + +#ifdef L_scalblnl +long double scalblnl (long double x, long exp) +{ + return (long double) scalbln( (double)x, exp ); +} +#endif + + +#ifdef L_scalbnl +long double scalbnl (long double x, int exp) +{ + return (long double) scalbn( (double)x, exp ); +} +#endif + + +#ifdef L_sinhl +long double sinhl (long double x) +{ + return (long double) sinh( (double)x ); +} +#endif + + +#ifdef L_sinl +long double sinl (long double x) +{ + return (long double) sin( (double)x ); +} +#endif + + +#ifdef L_sqrtl +long double sqrtl (long double x) +{ + return (long double) sqrt( (double)x ); +} +#endif + + +#ifdef L_tanhl +long double tanhl (long double x) +{ + return (long double) tanh( (double)x ); +} +#endif + + +#ifdef L_tanl +long double tanl (long double x) +{ + return (long double) tan( (double)x ); +} +#endif + + +#ifdef L_tgammal +long double tgammal (long double x) +{ + return (long double) tgamma( (double)x ); +} +#endif + + +#ifdef L_truncl +long double truncl (long double x) +{ + return (long double) trunc( (double)x ); +} +#endif diff --git a/libm/nan.c b/libm/nan.c index 662a25d33..ec221ea71 100644 --- a/libm/nan.c +++ b/libm/nan.c @@ -46,6 +46,7 @@ float nanf (const char *tagp) libm_hidden_def(nanf) #if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ +libm_hidden_proto(nanl) long double nanl (const char *tagp) { if (tagp[0] != '\0') { |