From ba16f5aa830b51c1e0147556991a2ec630aad009 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Fri, 11 Feb 2005 04:15:17 +0000 Subject: 2005-02-11 Gregory W. Chicares Danny Smith * include/math.h (expm1, expm1f, expmll): Add prototypes. * mingwex/Makefile.in (MATH_DISTFILES): Add expm1.c, expm1f.c, expm1l.c. (MATH_OBJS): Add expm1.o, expm1f.o, expm1l.o. * mingwex/math/expm1.c: New file. * mingwex/math/expm1f.c: New file. * mingwex/math/expm1l.c: New file. --- winsup/mingw/mingwex/Makefile.in | 6 ++++-- winsup/mingw/mingwex/math/expm1.c | 28 ++++++++++++++++++++++++++++ winsup/mingw/mingwex/math/expm1f.c | 29 +++++++++++++++++++++++++++++ winsup/mingw/mingwex/math/expm1l.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100755 winsup/mingw/mingwex/math/expm1.c create mode 100755 winsup/mingw/mingwex/math/expm1f.c create mode 100755 winsup/mingw/mingwex/math/expm1l.c (limited to 'winsup/mingw/mingwex') diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index e79df9acd..7dc0087f5 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -41,7 +41,8 @@ MATH_DISTFILES = \ atanf.c atanl.c cbrt.c cbrtf.c cbrtl.c ceilf.S ceill.S \ cephes_emath.h cephes_emath.c cephes_mconf.h \ copysign.S copysignf.S copysignl.S cosf.S coshf.c coshl.c cosl.S \ - exp2.S exp2f.S exp2l.S expf.c expl.c fabs.c fabsf.c fabsl.c \ + exp2.S exp2f.S exp2l.S expf.c expl.c expm1.c expm1l.c expm1f.c \ + fabs.c fabsf.c fabsl.c \ fdim.c fdimf.c fdiml.c floorf.S floorl.S fma.S fmaf.S fmal.c \ fmax.c fmaxf.c fmaxl.c fmin.c fminf.c fminl.c fmodf.c \ fmodl.c fp_consts.c fp_consts.h fp_constsf.c fp_constsl.c \ @@ -131,7 +132,8 @@ MATH_OBJS = \ atanf.o atanl.o cbrt.o cbrtf.o cbrtl.o ceilf.o ceill.o \ cephes_emath.o \ copysign.o copysignf.o copysignl.o cosf.o coshf.o coshl.o cosl.o \ - exp2.o exp2f.o exp2l.o expf.o expl.o fabs.o fabsf.o fabsl.o \ + exp2.o exp2f.o exp2l.o expf.o expl.o expm1.o expm1l.o expm1f.o \ + fabs.o fabsf.o fabsl.o \ fdim.o fdimf.o fdiml.o floorf.o floorl.o fma.o fmaf.o fmal.o \ fmax.o fmaxf.o fmaxl.o fmin.o fminf.o fminl.o fmodf.o \ fmodl.o fp_consts.o fp_constsf.o fp_constsl.o \ diff --git a/winsup/mingw/mingwex/math/expm1.c b/winsup/mingw/mingwex/math/expm1.c new file mode 100755 index 000000000..4b2f43939 --- /dev/null +++ b/winsup/mingw/mingwex/math/expm1.c @@ -0,0 +1,28 @@ +/* + * Written 2005 by Gregory W. Chicares . + * Adapted to double by Danny Smith . + * Public domain. + * + * F2XM1's input is constrained to (-1, +1), so the domain of + * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, + * delegating to exp() handles C99 7.12.6.3/2 range errors. + * + * Constants from moshier.net, file cephes/ldouble/constl.c, + * are used instead of M_LN2 and M_LOG2E, which would not be + * visible with 'gcc std=c99'. The use of these extended precision + * constants also allows gcc to replace them with x87 opcodes. + */ + +#include /* expl() */ +#include "cephes_mconf.h" +double expm1 (double x) +{ + if (fabs(x) < LOGE2L) + { + x *= LOG2EL; + __asm__("f2xm1" : "=t" (x) : "0" (x)); + return x; + } + else + return exp(x) - 1.0; +} diff --git a/winsup/mingw/mingwex/math/expm1f.c b/winsup/mingw/mingwex/math/expm1f.c new file mode 100755 index 000000000..e38665c48 --- /dev/null +++ b/winsup/mingw/mingwex/math/expm1f.c @@ -0,0 +1,29 @@ +/* + * Written 2005 by Gregory W. Chicares . + * Adapted to float by Danny Smith . + * Public domain. + * + * F2XM1's input is constrained to (-1, +1), so the domain of + * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, + * delegating to exp() handles C99 7.12.6.3/2 range errors. + * + * Constants from moshier.net, file cephes/ldouble/constl.c, + * are used instead of M_LN2 and M_LOG2E, which would not be + * visible with 'gcc std=c99'. The use of these extended precision + * constants also allows gcc to replace them with x87 opcodes. + */ + +#include /* expl() */ +#include "cephes_mconf.h" + +float expm1f (float x) +{ + if (fabsf(x) < LOGE2L) + { + x *= LOG2EL; + __asm__("f2xm1" : "=t" (x) : "0" (x)); + return x; + } + else + return expf(x) - 1.0F; +} diff --git a/winsup/mingw/mingwex/math/expm1l.c b/winsup/mingw/mingwex/math/expm1l.c new file mode 100755 index 000000000..69fe8e525 --- /dev/null +++ b/winsup/mingw/mingwex/math/expm1l.c @@ -0,0 +1,29 @@ +/* + * Written 2005 by Gregory W. Chicares with + * help from Danny Smith. dannysmith@users.sourceforge.net>. + * Public domain. + * + * F2XM1's input is constrained to (-1, +1), so the domain of + * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, + * delegating to expl() handles C99 7.12.6.3/2 range errors. + * + * Constants from moshier.net, file cephes/ldouble/constl.c, + * are used instead of M_LN2 and M_LOG2E, which would not be + * visible with 'gcc std=c99'. The use of these extended precision + * constants also allows gcc to replace them with x87 opcodes. + */ + +#include /* expl() */ +#include "cephes_mconf.h" + +long double expm1l (long double x) +{ + if (fabsl(x) < LOGE2L) + { + x *= LOG2EL; + __asm__("f2xm1" : "=t" (x) : "0" (x)); + return x; + } + else + return expl(x) - 1.0L; +} -- cgit v1.2.3