summaryrefslogtreecommitdiff
path: root/regress/lib
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-02-12 07:05:35 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-02-12 07:05:35 +0000
commit8b6bbf566520d8af90aa41966c34c07e023c931c (patch)
treeb4aca0e81da42b12407daede2aa38420b715e4ff /regress/lib
parent072aa31968bf2b5e98ffb949a44a55f4a9919b2a (diff)
a very simple rint() test. helped figure out fpu emulation probs on hppa
Diffstat (limited to 'regress/lib')
-rw-r--r--regress/lib/libm/Makefile4
-rw-r--r--regress/lib/libm/rint/Makefile7
-rw-r--r--regress/lib/libm/rint/rint.c37
3 files changed, 46 insertions, 2 deletions
diff --git a/regress/lib/libm/Makefile b/regress/lib/libm/Makefile
index 8404e9159ef..b2364257ee2 100644
--- a/regress/lib/libm/Makefile
+++ b/regress/lib/libm/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.1 2002/06/08 08:36:39 jason Exp $
+# $OpenBSD: Makefile,v 1.2 2003/02/12 07:05:34 mickey Exp $
-SUBDIR+= trivial1
+SUBDIR+= rint trivial1
install:
diff --git a/regress/lib/libm/rint/Makefile b/regress/lib/libm/rint/Makefile
new file mode 100644
index 00000000000..0b3c1e76ea9
--- /dev/null
+++ b/regress/lib/libm/rint/Makefile
@@ -0,0 +1,7 @@
+# $OpenBSD: Makefile,v 1.1 2003/02/12 07:05:34 mickey Exp $
+
+PROG=rint
+LDADD=-lm
+DPADD=${LIBM}
+
+.include <bsd.regress.mk>
diff --git a/regress/lib/libm/rint/rint.c b/regress/lib/libm/rint/rint.c
new file mode 100644
index 00000000000..5a89861f442
--- /dev/null
+++ b/regress/lib/libm/rint/rint.c
@@ -0,0 +1,37 @@
+/* $OpenBSD: rint.c,v 1.1 2003/02/12 07:05:34 mickey Exp $ */
+
+/* Copyright (c) 2003 Michael Shalayeff. Public domain. */
+
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <math.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
+main()
+{
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = sigfpe;
+ sa.sa_flags = SA_SIGINFO;
+ sigaction(SIGFPE, &sa, NULL);
+
+ if (rint(8.6) != 9.)
+ exit(1);
+
+ exit(0);
+}