summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartynas <>2013-12-29 01:39:44 +0000
committermartynas <>2013-12-29 01:39:44 +0000
commitc057fa8b78920eb9c3f036141d89633cdb5a2626 (patch)
tree64e72dd0a9ea8ed1a7f3a56430c46d8b85760492
parent059e8d1417ca56903c7f426e4a8a23db0b19a7e7 (diff)
downloadopenbsd-c057fa8b78920eb9c3f036141d89633cdb5a2626.tar.gz
openbsd-c057fa8b78920eb9c3f036141d89633cdb5a2626.tar.bz2
openbsd-c057fa8b78920eb9c3f036141d89633cdb5a2626.zip
Add a regression test to verify that the FPU control word state is
preserved by setjmp. Currently under REGRESS_FULL as this fails on certain archs.
-rw-r--r--src/regress/lib/libc/Makefile3
-rw-r--r--src/regress/lib/libc/setjmp-fpu/Makefile8
-rw-r--r--src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c34
3 files changed, 44 insertions, 1 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
index 016255e9dc..3109c0c1fd 100644
--- a/src/regress/lib/libc/Makefile
+++ b/src/regress/lib/libc/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.37 2013/08/01 21:26:30 kettenis Exp $ 1# $OpenBSD: Makefile,v 1.38 2013/12/29 01:39:44 martynas Exp $
2 2
3SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env 3SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env
4SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob 4SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob
@@ -10,6 +10,7 @@ SUBDIR+= telldir time vis
10 10
11.if defined(REGRESS_FULL) 11.if defined(REGRESS_FULL)
12SUBDIR+= getaddrinfo 12SUBDIR+= getaddrinfo
13SUBDIR+= setjmp-fpu
13.endif 14.endif
14 15
15.if (${MACHINE_ARCH} != "vax") 16.if (${MACHINE_ARCH} != "vax")
diff --git a/src/regress/lib/libc/setjmp-fpu/Makefile b/src/regress/lib/libc/setjmp-fpu/Makefile
new file mode 100644
index 0000000000..471de4821c
--- /dev/null
+++ b/src/regress/lib/libc/setjmp-fpu/Makefile
@@ -0,0 +1,8 @@
1# $OpenBSD: Makefile,v 1.1 2013/12/29 01:39:44 martynas Exp $
2
3PROG= setjmp-fpu
4SRCS= setjmp-fpu.c
5
6LDADD= -lm
7
8.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c b/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
new file mode 100644
index 0000000000..bbc562d6bd
--- /dev/null
+++ b/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
@@ -0,0 +1,34 @@
1#include <fenv.h>
2#include <setjmp.h>
3
4int
5main(int argc, char *argv[])
6{
7 jmp_buf env;
8 int rv;
9
10 /* Set up the FPU control word register. */
11 fesetround(FE_UPWARD);
12 fedisableexcept(FE_ALL_EXCEPT);
13 feenableexcept(FE_DIVBYZERO);
14
15 rv = setjmp(env);
16
17 /* Mess with the FPU control word. */
18 if (rv == 0) {
19 fesetround(FE_DOWNWARD);
20 fedisableexcept(FE_DIVBYZERO);
21 longjmp(env, 1);
22 /* Verify that the FPU control word is preserved. */
23 } else if (rv == 1) {
24 if (fegetround() != FE_UPWARD
25 || fegetexcept() != FE_DIVBYZERO)
26 return (1);
27 return (0);
28 /* This is not supposed to happen. */
29 } else {
30 return (1);
31 }
32
33 return (1);
34}