summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/ieeefp
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libc/ieeefp')
-rw-r--r--src/regress/lib/libc/ieeefp/Makefile8
-rw-r--r--src/regress/lib/libc/ieeefp/except/Makefile19
-rw-r--r--src/regress/lib/libc/ieeefp/except/except.c110
-rw-r--r--src/regress/lib/libc/ieeefp/inf/Makefile9
-rw-r--r--src/regress/lib/libc/ieeefp/inf/inf.c16
-rw-r--r--src/regress/lib/libc/ieeefp/infinity/Makefile22
-rw-r--r--src/regress/lib/libc/ieeefp/infinity/infinity.c77
-rw-r--r--src/regress/lib/libc/ieeefp/round/Makefile5
-rw-r--r--src/regress/lib/libc/ieeefp/round/round.c45
9 files changed, 0 insertions, 311 deletions
diff --git a/src/regress/lib/libc/ieeefp/Makefile b/src/regress/lib/libc/ieeefp/Makefile
deleted file mode 100644
index 89ff51a2e7..0000000000
--- a/src/regress/lib/libc/ieeefp/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1# $OpenBSD: Makefile,v 1.6 2004/01/15 18:53:23 miod Exp $
2# $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $
3
4SUBDIR+= except inf infinity round
5
6install:
7
8.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/ieeefp/except/Makefile b/src/regress/lib/libc/ieeefp/except/Makefile
deleted file mode 100644
index 205331548f..0000000000
--- a/src/regress/lib/libc/ieeefp/except/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
1# $OpenBSD: Makefile,v 1.5 2004/07/22 19:29:42 kettenis Exp $
2
3PROG=except
4
5REGRESS_TARGETS+= fltdiv fltinv fltovf fltund
6
7fltdiv: ${PROG}
8 ./${PROG} fltdiv
9
10fltinv: ${PROG}
11 ./${PROG} fltinv
12
13fltovf: ${PROG}
14 ./${PROG} fltovf
15
16fltund: ${PROG}
17 ./${PROG} fltund
18
19.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/ieeefp/except/except.c b/src/regress/lib/libc/ieeefp/except/except.c
deleted file mode 100644
index cc3dcf8e44..0000000000
--- a/src/regress/lib/libc/ieeefp/except/except.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/* $OpenBSD: except.c,v 1.12 2010/05/08 19:16:33 naddy Exp $ */
2
3#include <sys/types.h>
4#include <unistd.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8#include <signal.h>
9#include <assert.h>
10#include <ieeefp.h>
11#include <float.h>
12#include <err.h>
13
14volatile sig_atomic_t signal_status;
15
16volatile const double one = 1.0;
17volatile const double zero = 0.0;
18volatile const double huge = DBL_MAX;
19volatile const double tiny = DBL_MIN;
20
21void
22sigfpe(int sig, siginfo_t *si, void *v)
23{
24 char buf[132];
25
26 if (si) {
27 snprintf(buf, sizeof(buf), "sigfpe: addr=%p, code=%d\n",
28 si->si_addr, si->si_code);
29 write(1, buf, strlen(buf));
30 }
31 _exit(signal_status);
32}
33
34
35int
36main(int argc, char *argv[])
37{
38 struct sigaction sa;
39 volatile double x;
40
41 if (argc != 2) {
42 fprintf(stderr, "usage: %s condition\n", argv[0]);
43 exit(1);
44 }
45
46 /*
47 * check to make sure that all exceptions are masked and
48 * that the accumulated exception status is clear.
49 */
50 assert(fpgetmask() == 0);
51 assert(fpgetsticky() == 0);
52
53 memset(&sa, 0, sizeof(sa));
54 sa.sa_sigaction = sigfpe;
55 sa.sa_flags = SA_SIGINFO;
56 sigaction(SIGFPE, &sa, NULL);
57 signal_status = 1;
58
59 if (strcmp(argv[1], "fltdiv") == 0) {
60 /* trip divide by zero */
61 x = one / zero;
62 assert(fpgetsticky() & FP_X_DZ);
63 fpsetsticky(0);
64
65 /* and now unmask to get a signal */
66 signal_status = 0;
67 fpsetmask(FP_X_DZ);
68 x = one / zero;
69 } else if (strcmp(argv[1], "fltinv") == 0) {
70 /* trip invalid operation */
71 x = zero / zero;
72 assert(fpgetsticky() & FP_X_INV);
73 fpsetsticky(0);
74
75 /* and now unmask to get a signal */
76 signal_status = 0;
77 fpsetmask(FP_X_INV);
78 x = zero / zero;
79 } else if (strcmp(argv[1], "fltovf") == 0) {
80 /* trip overflow */
81 x = huge * huge;
82 assert(fpgetsticky() & FP_X_OFL);
83 fpsetsticky(0);
84
85 /* and now unmask to get a signal */
86 signal_status = 0;
87 fpsetmask(FP_X_OFL);
88 x = huge * huge;
89 } else if (strcmp(argv[1], "fltund") == 0) {
90 /* trip underflow */
91 x = tiny * tiny;
92 assert(fpgetsticky() & FP_X_UFL);
93 fpsetsticky(0);
94
95 /* and now unmask to get a signal */
96 signal_status = 0;
97 fpsetmask(FP_X_UFL);
98 x = tiny * tiny;
99 } else {
100 errx(1, "unrecognized condition %s", argv[1]);
101 }
102
103 /*
104 * attempt to trigger the exception on machines where
105 * floating-point exceptions are deferred.
106 */
107 x = one * one;
108
109 errx(1, "signal wasn't caught");
110}
diff --git a/src/regress/lib/libc/ieeefp/inf/Makefile b/src/regress/lib/libc/ieeefp/inf/Makefile
deleted file mode 100644
index b9a50e0ce6..0000000000
--- a/src/regress/lib/libc/ieeefp/inf/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1# $OpenBSD: Makefile,v 1.1 2002/02/16 17:22:16 pvalchev Exp $
2
3PROG= inf
4SRCS= inf.c
5
6LDADD+= -lm
7DPADD+= ${LIBM}
8
9.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/ieeefp/inf/inf.c b/src/regress/lib/libc/ieeefp/inf/inf.c
deleted file mode 100644
index a1956145a6..0000000000
--- a/src/regress/lib/libc/ieeefp/inf/inf.c
+++ /dev/null
@@ -1,16 +0,0 @@
1/* $OpenBSD: inf.c,v 1.3 2003/07/31 21:48:03 deraadt Exp $ */
2
3/*
4 * Peter Valchev <pvalchev@openbsd.org> Public Domain, 2002.
5 */
6
7#include <math.h>
8
9int
10main(int argc, char *argv[])
11{
12 if (isinf(HUGE_VAL))
13 return 0;
14
15 return 1;
16}
diff --git a/src/regress/lib/libc/ieeefp/infinity/Makefile b/src/regress/lib/libc/ieeefp/infinity/Makefile
deleted file mode 100644
index ac102d8a63..0000000000
--- a/src/regress/lib/libc/ieeefp/infinity/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1# $OpenBSD: Makefile,v 1.2 2004/01/16 19:34:37 miod Exp $
2
3PROG= infinity
4
5DPADD+= ${LIBM}
6LDADD+= -lm
7
8REGRESS_TARGETS+= add mult neg pumpkin
9
10add: ${PROG}
11 ./${PROG} -a
12
13mult: ${PROG}
14 ./${PROG} -m
15
16neg: ${PROG}
17 ./${PROG} -n
18
19pumpkin: ${PROG}
20 ./${PROG} -p
21
22.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/ieeefp/infinity/infinity.c b/src/regress/lib/libc/ieeefp/infinity/infinity.c
deleted file mode 100644
index 3b1b71ec90..0000000000
--- a/src/regress/lib/libc/ieeefp/infinity/infinity.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/* $OpenBSD: infinity.c,v 1.2 2004/01/16 19:34:37 miod Exp $ */
2/*
3 * Written by Miodrag Vallat, 2004 - Public Domain
4 * Inspired from Perl's t/op/arith test #134
5 */
6
7#include <math.h>
8#include <signal.h>
9#include <unistd.h>
10
11void
12sigfpe(int signum)
13{
14 /* looks like we don't handle fp overflow correctly... */
15 _exit(1);
16}
17
18int
19main(int argc, char *argv[])
20{
21 int opt;
22 double d, two;
23 int i;
24 char method = 'a';
25
26 while ((opt = getopt(argc, argv, "amnp")) != -1)
27 method = (char)opt;
28
29 signal(SIGFPE, sigfpe);
30
31 switch (method) {
32 case 'a':
33 /* try to produce +Inf through addition */
34 d = 1.0;
35 for (i = 2000; i != 0; i--) {
36 d = d + d;
37 }
38 /* result should be _positive_ infinity */
39 if (!isinf(d) || copysign(1.0, d) < 0.0)
40 return (1);
41 break;
42 case 'm':
43 /* try to produce +Inf through multiplication */
44 d = 1.0;
45 two = 2.0;
46 for (i = 2000; i != 0; i--) {
47 d = d * two;
48 }
49 /* result should be _positive_ infinity */
50 if (!isinf(d) || copysign(1.0, d) < 0.0)
51 return (1);
52 break;
53 case 'n':
54 /* try to produce -Inf through subtraction */
55 d = -1.0;
56 for (i = 2000; i != 0; i--) {
57 d = d + d;
58 }
59 /* result should be _negative_ infinity */
60 if (!isinf(d) || copysign(1.0, d) > 0.0)
61 return (1);
62 break;
63 case 'p':
64 /* try to produce -Inf through multiplication */
65 d = -1.0;
66 two = 2.0;
67 for (i = 2000; i != 0; i--) {
68 d = d * two;
69 }
70 /* result should be _negative_ infinity */
71 if (!isinf(d) || copysign(1.0, d) > 0.0)
72 return (1);
73 break;
74 }
75
76 return (0);
77}
diff --git a/src/regress/lib/libc/ieeefp/round/Makefile b/src/regress/lib/libc/ieeefp/round/Makefile
deleted file mode 100644
index 9ea6dd8c39..0000000000
--- a/src/regress/lib/libc/ieeefp/round/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1# $OpenBSD: Makefile,v 1.4 2002/02/18 11:25:34 art Exp $
2
3PROG= round
4
5.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/ieeefp/round/round.c b/src/regress/lib/libc/ieeefp/round/round.c
deleted file mode 100644
index 807941ea56..0000000000
--- a/src/regress/lib/libc/ieeefp/round/round.c
+++ /dev/null
@@ -1,45 +0,0 @@
1/* $OpenBSD: round.c,v 1.3 2003/07/31 21:48:03 deraadt Exp $ */
2/* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */
3
4/*
5 * Written by J.T. Conklin, Apr 18, 1995
6 * Public domain.
7 */
8
9#include <assert.h>
10#include <stdlib.h>
11#include <ieeefp.h>
12#include <float.h>
13
14int
15main(int argc, char *argv[])
16{
17 /*
18 * This test would be better if it actually performed some
19 * calculations to verify the selected rounding mode. But
20 * this is probably acceptable since the fp{get,set}round
21 * functions usually just get or set the processors fpu
22 * control word.
23 */
24
25 assert(fpgetround() == FP_RN);
26 assert(FLT_ROUNDS == 1);
27
28 assert(fpsetround(FP_RP) == FP_RN);
29 assert(fpgetround() == FP_RP);
30 assert(FLT_ROUNDS == 2);
31
32 assert(fpsetround(FP_RM) == FP_RP);
33 assert(fpgetround() == FP_RM);
34 assert(FLT_ROUNDS == 3);
35
36 assert(fpsetround(FP_RZ) == FP_RM);
37 assert(fpgetround() == FP_RZ);
38 assert(FLT_ROUNDS == 0);
39
40 assert(fpsetround(FP_RN) == FP_RZ);
41 assert(fpgetround() == FP_RN);
42 assert(FLT_ROUNDS == 1);
43
44 exit(0);
45}