summaryrefslogtreecommitdiff
path: root/regress/lib/libm
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-02-12 07:08:45 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-02-12 07:08:45 +0000
commit3fcaadbfdc44a89cb8252f012c3015b5af2d8cd4 (patch)
tree3abbe2223b2fe87174f0bc6e36324fb78a278d75 /regress/lib/libm
parent8b6bbf566520d8af90aa41966c34c07e023c931c (diff)
a double to int conversion test
Diffstat (limited to 'regress/lib/libm')
-rw-r--r--regress/lib/libm/Makefile4
-rw-r--r--regress/lib/libm/toint/Makefile5
-rw-r--r--regress/lib/libm/toint/toint.c42
3 files changed, 49 insertions, 2 deletions
diff --git a/regress/lib/libm/Makefile b/regress/lib/libm/Makefile
index b2364257ee2..0f6a15d65ec 100644
--- a/regress/lib/libm/Makefile
+++ b/regress/lib/libm/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.2 2003/02/12 07:05:34 mickey Exp $
+# $OpenBSD: Makefile,v 1.3 2003/02/12 07:08:44 mickey Exp $
-SUBDIR+= rint trivial1
+SUBDIR+= rint toint trivial1
install:
diff --git a/regress/lib/libm/toint/Makefile b/regress/lib/libm/toint/Makefile
new file mode 100644
index 00000000000..423fa436bb3
--- /dev/null
+++ b/regress/lib/libm/toint/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2003/02/12 07:08:44 mickey Exp $
+
+PROG=toint
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libm/toint/toint.c b/regress/lib/libm/toint/toint.c
new file mode 100644
index 00000000000..5b85ecb13e0
--- /dev/null
+++ b/regress/lib/libm/toint/toint.c
@@ -0,0 +1,42 @@
+/* $OpenBSD: toint.c,v 1.1 2003/02/12 07:08:44 mickey Exp $ */
+
+/* Copyright (c) 2003 Michael Shalayeff. Publci domain. */
+
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+
+void
+sigfpe(int sig, siginfo_t *si, void *v)
+{
+ char buf[132];
+
+ if (si) {
+ snprintf(buf, sizeof(buf), "sigfpe: addr=%p, code=%d\n",
+ si->si_addr, si->si_code);
+ write(1, buf, strlen(buf));
+ }
+ _exit(1);
+}
+
+int
+toint(double d)
+{
+ return (int)d;
+}
+
+int
+main()
+{
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = sigfpe;
+ sa.sa_flags = SA_SIGINFO;
+ sigaction(SIGFPE, &sa, NULL);
+
+ if (toint(8.6) != 8)
+ exit(1);
+
+ exit(0);
+}