summaryrefslogtreecommitdiff
path: root/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c')
-rw-r--r--src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c b/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
index bbc562d6bd..45b3c1ee0e 100644
--- a/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
+++ b/src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
@@ -2,7 +2,7 @@
2#include <setjmp.h> 2#include <setjmp.h>
3 3
4int 4int
5main(int argc, char *argv[]) 5TEST_SETJMP(int argc, char *argv[])
6{ 6{
7 jmp_buf env; 7 jmp_buf env;
8 int rv; 8 int rv;
@@ -12,23 +12,35 @@ main(int argc, char *argv[])
12 fedisableexcept(FE_ALL_EXCEPT); 12 fedisableexcept(FE_ALL_EXCEPT);
13 feenableexcept(FE_DIVBYZERO); 13 feenableexcept(FE_DIVBYZERO);
14 14
15 rv = setjmp(env); 15 rv = SETJMP(env, 0);
16 16
17 /* Mess with the FPU control word. */
18 if (rv == 0) { 17 if (rv == 0) {
18 fexcept_t flag = FE_OVERFLOW;
19
20 /* Mess with the FPU control word. */
19 fesetround(FE_DOWNWARD); 21 fesetround(FE_DOWNWARD);
20 fedisableexcept(FE_DIVBYZERO); 22 fedisableexcept(FE_DIVBYZERO);
21 longjmp(env, 1); 23
22 /* Verify that the FPU control word is preserved. */ 24 /* Set the FPU exception flags. */
25 fesetexceptflag(&flag, FE_ALL_EXCEPT);
26
27 LONGJMP(env, 1);
23 } else if (rv == 1) { 28 } else if (rv == 1) {
29 fexcept_t flag = 0;
30
31 /* Verify that the FPU control word is preserved. */
24 if (fegetround() != FE_UPWARD 32 if (fegetround() != FE_UPWARD
25 || fegetexcept() != FE_DIVBYZERO) 33 || fegetexcept() != FE_DIVBYZERO)
26 return (1); 34 return (1);
35
36 /* Verify that the FPU exception flags weren't clobbered. */
37 fegetexceptflag(&flag, FE_ALL_EXCEPT);
38 if (flag != FE_OVERFLOW)
39 return (1);
40
27 return (0); 41 return (0);
28 /* This is not supposed to happen. */
29 } else {
30 return (1);
31 } 42 }
32 43
44 /* This is not supposed to happen. */
33 return (1); 45 return (1);
34} 46}