Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2005-02-11 07:15:17 +0300
committerDanny Smith <dannysmith@users.sourceforge.net>2005-02-11 07:15:17 +0300
commitba16f5aa830b51c1e0147556991a2ec630aad009 (patch)
treeaa83c0d2f65a69740163c42d9f23d9b2d4ecf72e /winsup/mingw/mingwex
parentccf32128b3c601821771014e7beb4806fa30c523 (diff)
2005-02-11 Gregory W. Chicares <chicares at cox dot net>
Danny Smith <dannysmith@users at sourceforge dot net> * 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.
Diffstat (limited to 'winsup/mingw/mingwex')
-rw-r--r--winsup/mingw/mingwex/Makefile.in6
-rwxr-xr-xwinsup/mingw/mingwex/math/expm1.c28
-rwxr-xr-xwinsup/mingw/mingwex/math/expm1f.c29
-rwxr-xr-xwinsup/mingw/mingwex/math/expm1l.c29
4 files changed, 90 insertions, 2 deletions
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 <chicares@cox.net>.
+ * Adapted to double by 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 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 <math.h> /* 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 <chicares@cox.net>.
+ * Adapted to float by 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 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 <math.h> /* 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 <chicares@cox.net> 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 <math.h> /* 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;
+}