summaryrefslogtreecommitdiffstats
path: root/regress/lib/libc
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2004-01-15 18:53:23 +0000
committermiod <miod@openbsd.org>2004-01-15 18:53:23 +0000
commit97b76745e1f96243e43afac5d6d3041d40b319a7 (patch)
tree0f957a1df7c857954b24f91a41c98b67d4e5f2a0 /regress/lib/libc
parentupdate w/ more models; form weissmanndude (diff)
downloadwireguard-openbsd-97b76745e1f96243e43afac5d6d3041d40b319a7.tar.xz
wireguard-openbsd-97b76745e1f96243e43afac5d6d3041d40b319a7.zip
Add a new regression test, which checks that we handle fp overflow correctly,
and produce a correct infinity. Currently, this tests fails on 68060 (060sp is to blame) and 88100 processors, and maybe more.
Diffstat (limited to 'regress/lib/libc')
-rw-r--r--regress/lib/libc/ieeefp/Makefile4
-rw-r--r--regress/lib/libc/ieeefp/infinity/Makefile9
-rw-r--r--regress/lib/libc/ieeefp/infinity/infinity.c32
3 files changed, 43 insertions, 2 deletions
diff --git a/regress/lib/libc/ieeefp/Makefile b/regress/lib/libc/ieeefp/Makefile
index f9a6035fa95..89ff51a2e70 100644
--- a/regress/lib/libc/ieeefp/Makefile
+++ b/regress/lib/libc/ieeefp/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.5 2002/02/23 01:25:11 art Exp $
+# $OpenBSD: Makefile,v 1.6 2004/01/15 18:53:23 miod Exp $
# $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $
-SUBDIR+= except inf round
+SUBDIR+= except inf infinity round
install:
diff --git a/regress/lib/libc/ieeefp/infinity/Makefile b/regress/lib/libc/ieeefp/infinity/Makefile
new file mode 100644
index 00000000000..a593fcf37db
--- /dev/null
+++ b/regress/lib/libc/ieeefp/infinity/Makefile
@@ -0,0 +1,9 @@
+# $OpenBSD: Makefile,v 1.1 2004/01/15 18:53:24 miod Exp $
+
+PROG= infinity
+SRCS= infinity.c
+
+DPADD+= ${LIBM}
+LDADD+= -lm
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libc/ieeefp/infinity/infinity.c b/regress/lib/libc/ieeefp/infinity/infinity.c
new file mode 100644
index 00000000000..0f60b4762b8
--- /dev/null
+++ b/regress/lib/libc/ieeefp/infinity/infinity.c
@@ -0,0 +1,32 @@
+/* $OpenBSD: infinity.c,v 1.1 2004/01/15 18:53:24 miod Exp $ */
+/*
+ * Written by Miodrag Vallat, 2004 - Public Domain
+ * Inspired from Perl's t/op/arith test #134
+ */
+
+#include <math.h>
+#include <signal.h>
+
+void
+sigfpe(int signum)
+{
+ /* looks like we don't handle fp overflow correctly... */
+ _exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ double d, u;
+ int i;
+
+ signal(SIGFPE, sigfpe);
+
+ d = 1.0;
+ for (i = 2000; i != 0; i--) {
+ d = d * 2.0;
+ }
+
+ /* result should be _positive_ infinity */
+ return ((isinf(d) && copysign(1.0, d) > 0.0) ? 0 : 1);
+}