summaryrefslogtreecommitdiffstats
path: root/regress/lib/libc/modf/modf_test.c
diff options
context:
space:
mode:
authortobiasu <tobiasu@openbsd.org>2014-06-07 01:47:02 +0000
committertobiasu <tobiasu@openbsd.org>2014-06-07 01:47:02 +0000
commit99ab8ede38b75923478f38c07fe1cfe22933b157 (patch)
tree8cb4f6ca8cf59a77081e36d77940a075e011c859 /regress/lib/libc/modf/modf_test.c
parentAdd basic regression test for modf() issue. (diff)
downloadwireguard-openbsd-99ab8ede38b75923478f38c07fe1cfe22933b157.tar.xz
wireguard-openbsd-99ab8ede38b75923478f38c07fe1cfe22933b157.zip
Add basic regression test for modf() issue.
encouraged by deraadt and miod
Diffstat (limited to 'regress/lib/libc/modf/modf_test.c')
-rw-r--r--regress/lib/libc/modf/modf_test.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/regress/lib/libc/modf/modf_test.c b/regress/lib/libc/modf/modf_test.c
new file mode 100644
index 00000000000..f732533635a
--- /dev/null
+++ b/regress/lib/libc/modf/modf_test.c
@@ -0,0 +1,35 @@
+/* Public domain, 2014, Tobias Ulmer <tobiasu@tmux.org> */
+
+/* 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;
+}