diff options
-rw-r--r-- | regress/lib/libc/setjmp-fpu/Makefile | 4 | ||||
-rw-r--r-- | regress/lib/libc/setjmp-fpu/_setjmp.c | 5 | ||||
-rw-r--r-- | regress/lib/libc/setjmp-fpu/main.c | 11 | ||||
-rw-r--r-- | regress/lib/libc/setjmp-fpu/setjmp-fpu.c | 28 | ||||
-rw-r--r-- | regress/lib/libc/setjmp-fpu/setjmp.c | 5 | ||||
-rw-r--r-- | regress/lib/libc/setjmp-fpu/sigsetjmp.c | 5 |
6 files changed, 48 insertions, 10 deletions
diff --git a/regress/lib/libc/setjmp-fpu/Makefile b/regress/lib/libc/setjmp-fpu/Makefile index 471de4821c8..33d0f7e88a0 100644 --- a/regress/lib/libc/setjmp-fpu/Makefile +++ b/regress/lib/libc/setjmp-fpu/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.1 2013/12/29 01:39:44 martynas Exp $ +# $OpenBSD: Makefile,v 1.2 2013/12/29 05:46:43 martynas Exp $ PROG= setjmp-fpu -SRCS= setjmp-fpu.c +SRCS= _setjmp.c main.c setjmp.c sigsetjmp.c LDADD= -lm diff --git a/regress/lib/libc/setjmp-fpu/_setjmp.c b/regress/lib/libc/setjmp-fpu/_setjmp.c new file mode 100644 index 00000000000..a10b582f3f7 --- /dev/null +++ b/regress/lib/libc/setjmp-fpu/_setjmp.c @@ -0,0 +1,5 @@ +#define SETJMP(env, savemask) _setjmp(env) +#define LONGJMP(env, val) _longjmp(env, val) +#define TEST_SETJMP test__setjmp + +#include "setjmp-fpu.c" diff --git a/regress/lib/libc/setjmp-fpu/main.c b/regress/lib/libc/setjmp-fpu/main.c new file mode 100644 index 00000000000..43f9b6216cb --- /dev/null +++ b/regress/lib/libc/setjmp-fpu/main.c @@ -0,0 +1,11 @@ +int test__setjmp(void); +int test_setjmp(void); +int test_sigsetjmp(void); + +int +main(int argc, char *argv[]) +{ + return (test__setjmp() + | test_setjmp() + | test_sigsetjmp()); +} diff --git a/regress/lib/libc/setjmp-fpu/setjmp-fpu.c b/regress/lib/libc/setjmp-fpu/setjmp-fpu.c index bbc562d6bdd..45b3c1ee0e9 100644 --- a/regress/lib/libc/setjmp-fpu/setjmp-fpu.c +++ b/regress/lib/libc/setjmp-fpu/setjmp-fpu.c @@ -2,7 +2,7 @@ #include <setjmp.h> int -main(int argc, char *argv[]) +TEST_SETJMP(int argc, char *argv[]) { jmp_buf env; int rv; @@ -12,23 +12,35 @@ main(int argc, char *argv[]) fedisableexcept(FE_ALL_EXCEPT); feenableexcept(FE_DIVBYZERO); - rv = setjmp(env); + rv = SETJMP(env, 0); - /* Mess with the FPU control word. */ if (rv == 0) { + fexcept_t flag = FE_OVERFLOW; + + /* Mess with the FPU control word. */ fesetround(FE_DOWNWARD); fedisableexcept(FE_DIVBYZERO); - longjmp(env, 1); - /* Verify that the FPU control word is preserved. */ + + /* Set the FPU exception flags. */ + fesetexceptflag(&flag, FE_ALL_EXCEPT); + + LONGJMP(env, 1); } else if (rv == 1) { + fexcept_t flag = 0; + + /* Verify that the FPU control word is preserved. */ if (fegetround() != FE_UPWARD || fegetexcept() != FE_DIVBYZERO) return (1); + + /* Verify that the FPU exception flags weren't clobbered. */ + fegetexceptflag(&flag, FE_ALL_EXCEPT); + if (flag != FE_OVERFLOW) + return (1); + return (0); - /* This is not supposed to happen. */ - } else { - return (1); } + /* This is not supposed to happen. */ return (1); } diff --git a/regress/lib/libc/setjmp-fpu/setjmp.c b/regress/lib/libc/setjmp-fpu/setjmp.c new file mode 100644 index 00000000000..04de1df302a --- /dev/null +++ b/regress/lib/libc/setjmp-fpu/setjmp.c @@ -0,0 +1,5 @@ +#define SETJMP(env, savemask) setjmp(env) +#define LONGJMP(env, val) longjmp(env, val) +#define TEST_SETJMP test_setjmp + +#include "setjmp-fpu.c" diff --git a/regress/lib/libc/setjmp-fpu/sigsetjmp.c b/regress/lib/libc/setjmp-fpu/sigsetjmp.c new file mode 100644 index 00000000000..8ba80e26124 --- /dev/null +++ b/regress/lib/libc/setjmp-fpu/sigsetjmp.c @@ -0,0 +1,5 @@ +#define SETJMP(env, savemask) sigsetjmp(env, savemask) +#define LONGJMP(env, val) siglongjmp(env, val) +#define TEST_SETJMP test_sigsetjmp + +#include "setjmp-fpu.c" |