aboutsummaryrefslogtreecommitdiff
path: root/winsup/mingw
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2005-05-10 08:39:07 +0000
committerDanny Smith <dannysmith@users.sourceforge.net>2005-05-10 08:39:07 +0000
commit96c837f0ca50aa9e625fdbc5fb9ba088fc99405d (patch)
tree4a4945bfbfc3135bbb9cc10a8050eb9bb085891e /winsup/mingw
parent5b91f0a6efc120a2c7b26000347f4a2876577fa8 (diff)
downloadnewlib-96c837f0ca50aa9e625fdbc5fb9ba088fc99405d.zip
newlib-96c837f0ca50aa9e625fdbc5fb9ba088fc99405d.tar.gz
newlib-96c837f0ca50aa9e625fdbc5fb9ba088fc99405d.tar.bz2
* mingwex/math/nexttoward.c: New file.
* mingwex/math/nexttowardf.c: New file. * mingwex/math/nextafterl.c: Add nexttowardl aliaa. * mingwex/Makefile.in (MATH_DISTFILES): Add nexttoward.c, mexttowardf.c, (MATH_OBJS): Add nexttoward.o, mexttowardf.o, * include/math.h (nexttoward, nextowardf, nexttowardl): Add prototypes.
Diffstat (limited to 'winsup/mingw')
-rw-r--r--winsup/mingw/ChangeLog11
-rw-r--r--winsup/mingw/include/math.h5
-rw-r--r--winsup/mingw/mingwex/Makefile.in6
-rwxr-xr-xwinsup/mingw/mingwex/math/nextafterl.c4
-rwxr-xr-xwinsup/mingw/mingwex/math/nexttoward.c42
-rwxr-xr-xwinsup/mingw/mingwex/math/nexttowardf.c38
6 files changed, 103 insertions, 3 deletions
diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog
index 8c307a5..32a8f25 100644
--- a/winsup/mingw/ChangeLog
+++ b/winsup/mingw/ChangeLog
@@ -1,3 +1,14 @@
+2005-05-10 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * mingwex/math/nexttoward.c: New file.
+ * mingwex/math/nexttowardf.c: New file.
+ * mingwex/math/nextafterl.c: Add nexttowardl aliaa.
+ * mingwex/Makefile.in (MATH_DISTFILES): Add nexttoward.c,
+ mexttowardf.c,
+ (MATH_OBJS): Add nexttoward.o, mexttowardf.o,
+ * include/math.h (nexttoward, nextowardf, nexttowardl): Add
+ prototypes.
+
2005-05-09 Danny Smith <dannysmith@users.sourceforge.net>
* mingwex/math/nextafterf.c (nextafterf): Correct
diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h
index 9f1531d..2f39aeb 100644
--- a/winsup/mingw/include/math.h
+++ b/winsup/mingw/include/math.h
@@ -723,7 +723,10 @@ extern double __cdecl nextafter (double, double); /* in libmoldname.a */
extern float __cdecl nextafterf (float, float);
extern long double __cdecl nextafterl (long double, long double);
-/* 7.12.11.4 The nexttoward functions: TODO */
+/* 7.12.11.4 The nexttoward functions */
+extern double __cdecl nexttoward (double, long double);
+extern float __cdecl nexttowardf (float, long double);
+extern long double __cdecl nexttowardl (long double, long double);
/* 7.12.12.1 */
/* x > y ? (x - y) : 0.0 */
diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in
index 289a44c..feb9bd6 100644
--- a/winsup/mingw/mingwex/Makefile.in
+++ b/winsup/mingw/mingwex/Makefile.in
@@ -54,7 +54,8 @@ MATH_DISTFILES = \
log10f.S log10l.S log1p.S log1pf.S log1pl.S log2.S log2f.S \
log2l.S logb.c logbf.c logbl.c logf.S logl.S lrint.c lrintf.c \
lrintl.c lround.c lroundf.c lroundl.c modff.c modfl.c \
- nearbyint.S nearbyintf.S nearbyintl.S nextafterf.c nextafterl.c \
+ nearbyint.S nearbyintf.S nearbyintl.S \
+ nextafterf.c nextafterl.c nexttowardf.c nexttoward.c \
powf.c powi.c powif.c powil.c powl.c \
remainder.S remainderf.S remainderl.S remquo.S \
remquof.S remquol.S rint.c rintf.c rintl.c round.c roundf.c \
@@ -146,7 +147,8 @@ MATH_OBJS = \
log10f.o log10l.o log1p.o log1pf.o log1pl.o log2.o log2f.o \
log2l.o logb.o logbf.o logbl.o logf.o logl.o lrint.o lrintf.o \
lrintl.o lround.o lroundf.o lroundl.o modff.o modfl.o \
- nearbyint.o nearbyintf.o nearbyintl.o nextafterf.o nextafterl.o \
+ nearbyint.o nearbyintf.o nearbyintl.o \
+ nextafterf.o nextafterl.o nexttowardf.o nexttoward.o \
powf.o powi.o powif.o powil.o powl.o \
remainder.o remainderf.o remainderl.o remquo.o \
remquof.o remquol.o rint.o rintf.o rintl.o round.o roundf.o \
diff --git a/winsup/mingw/mingwex/math/nextafterl.c b/winsup/mingw/mingwex/math/nextafterl.c
index 84be44f..eaf6a3f 100755
--- a/winsup/mingw/mingwex/math/nextafterl.c
+++ b/winsup/mingw/mingwex/math/nextafterl.c
@@ -59,3 +59,7 @@ nextafterl (long double x, long double y)
return u.ld;
}
+
+/* nexttowardl is the same function with a different name. */
+long double
+nexttowardl (long double, long double) __attribute__ ((alias("nextafterl")));
diff --git a/winsup/mingw/mingwex/math/nexttoward.c b/winsup/mingw/mingwex/math/nexttoward.c
new file mode 100755
index 0000000..6a4c820
--- /dev/null
+++ b/winsup/mingw/mingwex/math/nexttoward.c
@@ -0,0 +1,42 @@
+/*
+ nexttoward.c
+ Contributed by Danny Smith <dannysmith@users.sourceforge.net>
+ No copyright claimed, absolutely no warranties.
+
+ 2005-05-10
+*/
+
+#include <math.h>
+
+double
+nexttoward (double x, long double y)
+{
+ union
+ {
+ double d;
+ unsigned long long ll;
+ } u;
+
+ long double xx = x;
+
+ if (isnan (y) || isnan (x))
+ return x + y;
+
+ if (xx == y)
+ /* nextafter (0.0, -O.0) should return -0.0. */
+ return y;
+ u.d = x;
+ if (x == 0.0)
+ {
+ u.ll = 1;
+ return y > 0.0L ? u.d : -u.d;
+ }
+
+ /* Non-extended encodings are lexicographically ordered,
+ with implicit "normal" bit. */
+ if (((x > 0.0) ^ (y > xx)) == 0)
+ u.ll++;
+ else
+ u.ll--;
+ return u.d;
+}
diff --git a/winsup/mingw/mingwex/math/nexttowardf.c b/winsup/mingw/mingwex/math/nexttowardf.c
new file mode 100755
index 0000000..80ac1a3
--- /dev/null
+++ b/winsup/mingw/mingwex/math/nexttowardf.c
@@ -0,0 +1,38 @@
+/*
+ nexttowardf.c
+ Contributed by Danny Smith <dannysmith@users.sourceforge.net>
+ No copyright claimed, absolutely no warranties.
+
+ 2005-05-10
+*/
+
+#include <math.h>
+
+float
+nexttowardf (float x, long double y)
+{
+ union
+ {
+ float f;
+ unsigned int i;
+ } u;
+
+ long double xx = x;
+
+ if (isnan (y) || isnan (x))
+ return x + y;
+ if (xx == y )
+ /* nextafter (0.0, -O.0) should return -0.0. */
+ return y;
+ u.f = x;
+ if (x == 0.0F)
+ {
+ u.i = 1;
+ return y > 0.0L ? u.f : -u.f;
+ }
+ if (((x > 0.0F) ^ (y > xx)) == 0)
+ u.i++;
+ else
+ u.i--;
+ return u.f;
+}