And here's a quick and dirty regression test.

Index: Makefile
===================================================================
RCS file: /home/vcs/cvs/openbsd/src/regress/lib/libc/Makefile,v
retrieving revision 1.38
diff -u -p -r1.38 Makefile
--- Makefile    29 Dec 2013 01:39:44 -0000      1.38
+++ Makefile    6 Jun 2014 21:05:00 -0000
@@ -2,7 +2,7 @@
 
 SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env
 SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob
-SUBDIR+= hsearch longjmp locale malloc mkstemp netdb open_memstream 
+SUBDIR+= hsearch longjmp locale malloc mkstemp modf netdb open_memstream
 SUBDIR+= orientation popen printf
 SUBDIR+= regex setjmp setjmp-signal sigreturn sigsetjmp sprintf
 SUBDIR+= stdio_threading stpncpy strerror strtod strtol strtonum
Index: modf/Makefile
===================================================================
RCS file: modf/Makefile
diff -N modf/Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modf/Makefile       6 Jun 2014 21:05:00 -0000
@@ -0,0 +1,3 @@
+PROG=modf_test
+
+.include <bsd.regress.mk>
Index: modf/modf_test.c
===================================================================
RCS file: modf/modf_test.c
diff -N modf/modf_test.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modf/modf_test.c    6 Jun 2014 21:05:00 -0000
@@ -0,0 +1,35 @@
+/* Public domain, 2014, Tobias Ulmer <[email protected]> */
+
+/* Test for bug introduced in 4.4BSD modf() on sparc */
+
+#include <math.h>
+
+#define BIGFLOAT (5e15) /* Number large enough to trigger the "big" case */
+
+int
+main(void)
+{
+       double f, i;
+
+       f = modf(BIGFLOAT, &i);
+       if (i != BIGFLOAT)
+               return 1;
+       if (f != 0.0)
+               return 1;
+
+       /* Repeat, maybe we were lucky */
+       f = modf(BIGFLOAT, &i);
+       if (i != BIGFLOAT)
+               return 1;
+       if (f != 0.0)
+               return 1;
+
+       /* With negative number, for good measure */
+       f = modf(-BIGFLOAT, &i);
+       if (i != -BIGFLOAT)
+               return 1;
+       if (f != 0.0)
+               return 1;
+
+       return 0;
+}

Reply via email to