diff options
Diffstat (limited to '')
-rw-r--r-- | src/regress/lib/libc/setjmp-fpu/Makefile | 26 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-fpu/_setjmp.c | 16 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-fpu/fpu.c | 53 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c | 65 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-fpu/setjmp.c | 16 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-fpu/sigsetjmp.c | 16 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-signal/Makefile | 5 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp-signal/setjmp-signal.c | 26 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp/Makefile | 9 | ||||
-rw-r--r-- | src/regress/lib/libc/setjmp/jmptest.c | 136 |
10 files changed, 0 insertions, 368 deletions
diff --git a/src/regress/lib/libc/setjmp-fpu/Makefile b/src/regress/lib/libc/setjmp-fpu/Makefile deleted file mode 100644 index 203613931a..0000000000 --- a/src/regress/lib/libc/setjmp-fpu/Makefile +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | # $OpenBSD: Makefile,v 1.6 2021/04/19 15:56:37 kettenis Exp $ | ||
2 | |||
3 | PROGS= fpu _setjmp setjmp sigsetjmp | ||
4 | |||
5 | LDADD= -lm | ||
6 | |||
7 | REGRESS_TARGETS = run-fpu | ||
8 | run-fpu: fpu | ||
9 | # check fpu functions without setjmp/longjmp before testing the latter | ||
10 | ./fpu | ||
11 | |||
12 | .for p in ${PROGS:M*jmp} | ||
13 | REGRESS_TARGETS += run-$p | ||
14 | run-$p: $p | ||
15 | ./$p | ||
16 | .endfor | ||
17 | |||
18 | .if ${MACHINE} == powerpc64 | ||
19 | # The powerpc64 ELFv2 ABI explicitly states that exception enable bits | ||
20 | # and rounding control bits are not restored by longjmp(3) | ||
21 | .for p in ${PROGS:M*jmp} | ||
22 | REGRESS_EXPECTED_FAILURES += run-$p | ||
23 | .endfor | ||
24 | .endif | ||
25 | |||
26 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/setjmp-fpu/_setjmp.c b/src/regress/lib/libc/setjmp-fpu/_setjmp.c deleted file mode 100644 index dba5d7259d..0000000000 --- a/src/regress/lib/libc/setjmp-fpu/_setjmp.c +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* $OpenBSD: _setjmp.c,v 1.4 2020/01/13 14:58:38 bluhm Exp $ */ | ||
2 | |||
3 | int test__setjmp(void); | ||
4 | |||
5 | int | ||
6 | main(int argc, char *argv[]) | ||
7 | { | ||
8 | return test__setjmp(); | ||
9 | } | ||
10 | |||
11 | #define SETJMP(env, savemask) _setjmp(env) | ||
12 | #define LONGJMP(env, val) _longjmp(env, val) | ||
13 | #define TEST_SETJMP test__setjmp | ||
14 | #define JMP_BUF jmp_buf | ||
15 | |||
16 | #include "setjmp-fpu.c" | ||
diff --git a/src/regress/lib/libc/setjmp-fpu/fpu.c b/src/regress/lib/libc/setjmp-fpu/fpu.c deleted file mode 100644 index e585702887..0000000000 --- a/src/regress/lib/libc/setjmp-fpu/fpu.c +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* $OpenBSD: fpu.c,v 1.3 2021/06/17 12:55:38 kettenis Exp $ */ | ||
2 | |||
3 | #include <err.h> | ||
4 | #include <fenv.h> | ||
5 | #include <stdlib.h> | ||
6 | |||
7 | int | ||
8 | main(int argc, char *argv[]) | ||
9 | { | ||
10 | fexcept_t flag; | ||
11 | int rv; | ||
12 | |||
13 | /* Set up the FPU control word register. */ | ||
14 | rv = fesetround(FE_UPWARD); | ||
15 | if (rv != 0) | ||
16 | errx(2, "fesetround FE_UPWARD returned %d", rv); | ||
17 | fedisableexcept(FE_ALL_EXCEPT); | ||
18 | feenableexcept(FE_DIVBYZERO); | ||
19 | |||
20 | /* Set the FPU exception flags. */ | ||
21 | flag = FE_OVERFLOW; | ||
22 | rv = fesetexceptflag(&flag, FE_ALL_EXCEPT); | ||
23 | if (rv != 0) | ||
24 | errx(2, "fesetexceptflag returned %d", rv); | ||
25 | |||
26 | /* Schedule another process, to check if kernel preserves state. */ | ||
27 | rv = system("true"); | ||
28 | if (rv == -1) | ||
29 | err(2, "system"); | ||
30 | if (rv != 0) | ||
31 | errx(2, "true: %d", rv); | ||
32 | |||
33 | /* Verify that the FPU control word is preserved. */ | ||
34 | rv = fegetround(); | ||
35 | if (rv != FE_UPWARD) | ||
36 | errx(1, "fegetround returned %d, not FE_UPWARD", rv); | ||
37 | #if !defined(__arm__) && !defined(__aarch64__) && !defined(__riscv) | ||
38 | rv = fegetexcept(); | ||
39 | if (rv != FE_DIVBYZERO) | ||
40 | errx(1, "fegetexcept returned %d, not FE_DIVBYZERO", | ||
41 | rv); | ||
42 | #endif | ||
43 | |||
44 | /* Verify that the FPU exception flags weren't clobbered. */ | ||
45 | flag = 0; | ||
46 | rv = fegetexceptflag(&flag, FE_ALL_EXCEPT); | ||
47 | if (rv != 0) | ||
48 | errx(2, "fegetexceptflag returned %d", rv); | ||
49 | if (flag != FE_OVERFLOW) | ||
50 | errx(1, "except flag is %d, no FE_OVERFLOW", rv); | ||
51 | |||
52 | return (0); | ||
53 | } | ||
diff --git a/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c b/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c deleted file mode 100644 index b5ffd8948e..0000000000 --- a/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | /* $OpenBSD: setjmp-fpu.c,v 1.7 2021/06/17 12:55:38 kettenis Exp $ */ | ||
2 | |||
3 | #include <err.h> | ||
4 | #include <fenv.h> | ||
5 | #include <setjmp.h> | ||
6 | |||
7 | int | ||
8 | TEST_SETJMP(void) | ||
9 | { | ||
10 | JMP_BUF env; | ||
11 | fexcept_t flag; | ||
12 | int rv; | ||
13 | |||
14 | /* Set up the FPU control word register. */ | ||
15 | rv = fesetround(FE_UPWARD); | ||
16 | if (rv != 0) | ||
17 | errx(2, "fesetround FE_UPWARD returned %d", rv); | ||
18 | fedisableexcept(FE_ALL_EXCEPT); | ||
19 | feenableexcept(FE_DIVBYZERO); | ||
20 | |||
21 | rv = SETJMP(env, 0); | ||
22 | |||
23 | switch(rv) { | ||
24 | case 0: { | ||
25 | /* Mess with the FPU control word. */ | ||
26 | rv = fesetround(FE_DOWNWARD); | ||
27 | if (rv != 0) | ||
28 | errx(2, "fesetround FE_DOWNWARD returned %d", rv); | ||
29 | fedisableexcept(FE_DIVBYZERO); | ||
30 | |||
31 | /* Set the FPU exception flags. */ | ||
32 | flag = FE_OVERFLOW; | ||
33 | rv = fesetexceptflag(&flag, FE_ALL_EXCEPT); | ||
34 | if (rv != 0) | ||
35 | errx(2, "fesetexceptflag returned %d", rv); | ||
36 | |||
37 | LONGJMP(env, 1); | ||
38 | errx(2, "longjmp returned"); | ||
39 | } | ||
40 | case 1: { | ||
41 | /* Verify that the FPU control word is preserved. */ | ||
42 | rv = fegetround(); | ||
43 | if (rv != FE_UPWARD) | ||
44 | errx(1, "fegetround returned %d, not FE_UPWARD", rv); | ||
45 | #if !defined(__arm__) && !defined(__aarch64__) && !defined(__riscv) | ||
46 | rv = fegetexcept(); | ||
47 | if (rv != FE_DIVBYZERO) | ||
48 | errx(1, "fegetexcept returned %d, not FE_DIVBYZERO", | ||
49 | rv); | ||
50 | #endif | ||
51 | |||
52 | /* Verify that the FPU exception flags weren't clobbered. */ | ||
53 | flag = 0; | ||
54 | rv = fegetexceptflag(&flag, FE_ALL_EXCEPT); | ||
55 | if (rv != 0) | ||
56 | errx(2, "fegetexceptflag returned %d", rv); | ||
57 | if (flag != FE_OVERFLOW) | ||
58 | errx(1, "except flag is %d, no FE_OVERFLOW", rv); | ||
59 | |||
60 | return (0); | ||
61 | } | ||
62 | default: | ||
63 | errx(2, "setjmp returned %d", rv); | ||
64 | } | ||
65 | } | ||
diff --git a/src/regress/lib/libc/setjmp-fpu/setjmp.c b/src/regress/lib/libc/setjmp-fpu/setjmp.c deleted file mode 100644 index e12731da37..0000000000 --- a/src/regress/lib/libc/setjmp-fpu/setjmp.c +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* $OpenBSD: setjmp.c,v 1.4 2020/01/13 14:58:38 bluhm Exp $ */ | ||
2 | |||
3 | int test_setjmp(void); | ||
4 | |||
5 | int | ||
6 | main(int argc, char *argv[]) | ||
7 | { | ||
8 | return test_setjmp(); | ||
9 | } | ||
10 | |||
11 | #define SETJMP(env, savemask) setjmp(env) | ||
12 | #define LONGJMP(env, val) longjmp(env, val) | ||
13 | #define TEST_SETJMP test_setjmp | ||
14 | #define JMP_BUF jmp_buf | ||
15 | |||
16 | #include "setjmp-fpu.c" | ||
diff --git a/src/regress/lib/libc/setjmp-fpu/sigsetjmp.c b/src/regress/lib/libc/setjmp-fpu/sigsetjmp.c deleted file mode 100644 index 8c7a22a92b..0000000000 --- a/src/regress/lib/libc/setjmp-fpu/sigsetjmp.c +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | /* $OpenBSD: sigsetjmp.c,v 1.4 2020/01/13 14:58:38 bluhm Exp $ */ | ||
2 | |||
3 | int test_sigsetjmp(void); | ||
4 | |||
5 | int | ||
6 | main(int argc, char *argv[]) | ||
7 | { | ||
8 | return test_sigsetjmp(); | ||
9 | } | ||
10 | |||
11 | #define SETJMP(env, savemask) sigsetjmp(env, savemask) | ||
12 | #define LONGJMP(env, val) siglongjmp(env, val) | ||
13 | #define TEST_SETJMP test_sigsetjmp | ||
14 | #define JMP_BUF sigjmp_buf | ||
15 | |||
16 | #include "setjmp-fpu.c" | ||
diff --git a/src/regress/lib/libc/setjmp-signal/Makefile b/src/regress/lib/libc/setjmp-signal/Makefile deleted file mode 100644 index a9649a8abe..0000000000 --- a/src/regress/lib/libc/setjmp-signal/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2002/07/31 05:18:24 art Exp $ | ||
2 | |||
3 | PROG= setjmp-signal | ||
4 | |||
5 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/setjmp-signal/setjmp-signal.c b/src/regress/lib/libc/setjmp-signal/setjmp-signal.c deleted file mode 100644 index b50f6b27c5..0000000000 --- a/src/regress/lib/libc/setjmp-signal/setjmp-signal.c +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | /* $OpenBSD: setjmp-signal.c,v 1.4 2017/07/27 12:31:09 bluhm Exp $ */ | ||
2 | /* | ||
3 | * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain. | ||
4 | */ | ||
5 | |||
6 | #include <setjmp.h> | ||
7 | #include <signal.h> | ||
8 | |||
9 | jmp_buf jb; | ||
10 | |||
11 | void | ||
12 | segv_handler(int signum) | ||
13 | { | ||
14 | longjmp(jb, 1); | ||
15 | } | ||
16 | |||
17 | int | ||
18 | main() | ||
19 | { | ||
20 | signal(SIGSEGV, segv_handler); | ||
21 | if (setjmp(jb) == 0) { | ||
22 | *((volatile int *)0L) = 0; | ||
23 | return (1); | ||
24 | } | ||
25 | return (0); | ||
26 | } | ||
diff --git a/src/regress/lib/libc/setjmp/Makefile b/src/regress/lib/libc/setjmp/Makefile deleted file mode 100644 index fc68e8d44c..0000000000 --- a/src/regress/lib/libc/setjmp/Makefile +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | # $OpenBSD: Makefile,v 1.3 2002/01/01 23:00:51 art Exp $ | ||
2 | # $NetBSD: Makefile,v 1.2 1995/04/20 22:40:13 cgd Exp $ | ||
3 | |||
4 | PROG= setjmptest | ||
5 | SRCS= jmptest.c | ||
6 | |||
7 | CFLAGS+= -DTEST_SETJMP | ||
8 | |||
9 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/setjmp/jmptest.c b/src/regress/lib/libc/setjmp/jmptest.c deleted file mode 100644 index 9512c9ee34..0000000000 --- a/src/regress/lib/libc/setjmp/jmptest.c +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | /* $OpenBSD: jmptest.c,v 1.7 2003/09/02 23:52:16 david Exp $ */ | ||
2 | /* $NetBSD: jmptest.c,v 1.2 1995/01/01 20:55:35 jtc Exp $ */ | ||
3 | |||
4 | /* | ||
5 | * Copyright (c) 1994 Christopher G. Demetriou | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. All advertising materials mentioning features or use of this software | ||
17 | * must display the following acknowledgement: | ||
18 | * This product includes software developed by Christopher G. Demetriou | ||
19 | * for the NetBSD Project. | ||
20 | * 4. The name of the author may not be used to endorse or promote products | ||
21 | * derived from this software without specific prior written permission | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | #include <sys/types.h> | ||
36 | #include <err.h> | ||
37 | #include <setjmp.h> | ||
38 | #include <signal.h> | ||
39 | #include <stdio.h> | ||
40 | #include <stdlib.h> | ||
41 | #include <string.h> | ||
42 | #include <unistd.h> | ||
43 | |||
44 | #if (TEST_SETJMP + TEST_U_SETJMP + TEST_SIGSETJMP) != 1 | ||
45 | #error one of TEST_SETJMP, TEST_U_SETJMP, or TEST_SIGSETJMP must be defined | ||
46 | #endif | ||
47 | |||
48 | #ifdef TEST_SETJMP | ||
49 | #define BUF jmp_buf | ||
50 | #define SET(b, m) setjmp(b) | ||
51 | #define JMP(b, v) longjmp(b, v) | ||
52 | #endif | ||
53 | |||
54 | #ifdef TEST_U_SETJMP | ||
55 | #define BUF jmp_buf | ||
56 | #define SET(b, m) _setjmp(b) | ||
57 | #define JMP(b, v) _longjmp(b, v) | ||
58 | #endif | ||
59 | |||
60 | #ifdef TEST_SIGSETJMP | ||
61 | #define BUF sigjmp_buf | ||
62 | #define SET(b, m) sigsetjmp(b, m) | ||
63 | #define JMP(b, v) siglongjmp(b, v) | ||
64 | #endif | ||
65 | |||
66 | int expectsignal; | ||
67 | |||
68 | static void | ||
69 | aborthandler(int signo) | ||
70 | { | ||
71 | |||
72 | if (expectsignal) | ||
73 | _exit(0); | ||
74 | else { | ||
75 | warnx("kill(SIGABRT) succeeded"); | ||
76 | _exit(1); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | int | ||
81 | main(int argc, char *argv[]) | ||
82 | { | ||
83 | struct sigaction sa; | ||
84 | BUF jb; | ||
85 | sigset_t ss; | ||
86 | int i, x; | ||
87 | |||
88 | i = getpid(); | ||
89 | |||
90 | #ifdef TEST_SETJMP | ||
91 | expectsignal = 0; | ||
92 | #endif | ||
93 | #ifdef TEST_U_SETJMP | ||
94 | expectsignal = 1; | ||
95 | #endif | ||
96 | #ifdef TEST_SIGSETJMP | ||
97 | if (argc != 2 || | ||
98 | (strcmp(argv[1], "save") && strcmp(argv[1], "nosave"))) { | ||
99 | fprintf(stderr, "usage: %s [save|nosave]\n", argv[0]); | ||
100 | exit(1); | ||
101 | } | ||
102 | expectsignal = (strcmp(argv[1], "save") != 0); | ||
103 | #endif | ||
104 | |||
105 | sa.sa_handler = aborthandler; | ||
106 | sigemptyset(&sa.sa_mask); | ||
107 | sa.sa_flags = 0; | ||
108 | if (sigaction(SIGABRT, &sa, NULL) == -1) | ||
109 | err(1, "sigaction failed"); | ||
110 | |||
111 | if (sigemptyset(&ss) == -1) | ||
112 | err(1, "sigemptyset failed"); | ||
113 | if (sigaddset(&ss, SIGABRT) == -1) | ||
114 | err(1, "sigaddset failed"); | ||
115 | if (sigprocmask(SIG_BLOCK, &ss, NULL) == -1) | ||
116 | err(1, "sigprocmask (1) failed"); | ||
117 | |||
118 | x = SET(jb, !expectsignal); | ||
119 | if (x != 0) { | ||
120 | if (x != i) | ||
121 | errx(1, "setjmp returned wrong value"); | ||
122 | |||
123 | kill(i, SIGABRT); | ||
124 | if (expectsignal) | ||
125 | errx(1, "kill(SIGABRT) failed"); | ||
126 | else | ||
127 | exit(0); | ||
128 | } | ||
129 | |||
130 | if (sigprocmask(SIG_UNBLOCK, &ss, NULL) == -1) | ||
131 | err(1, "sigprocmask (2) failed"); | ||
132 | |||
133 | JMP(jb, i); | ||
134 | |||
135 | errx(1, "jmp failed"); | ||
136 | } | ||