summaryrefslogtreecommitdiff
path: root/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'regress/lib/libc/setjmp-fpu/setjmp-fpu.c')
-rw-r--r--regress/lib/libc/setjmp-fpu/setjmp-fpu.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/regress/lib/libc/setjmp-fpu/setjmp-fpu.c b/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
index 694061dcbb9..11d616ae712 100644
--- a/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
+++ b/regress/lib/libc/setjmp-fpu/setjmp-fpu.c
@@ -1,46 +1,62 @@
+#include <err.h>
#include <fenv.h>
#include <setjmp.h>
int
-TEST_SETJMP(int argc, char *argv[])
+TEST_SETJMP(void)
{
JMP_BUF env;
int rv;
/* Set up the FPU control word register. */
- fesetround(FE_UPWARD);
+ rv = fesetround(FE_UPWARD);
+ if (rv != 0)
+ errx(1, "fesetround FE_UPWARD returned %d", rv);
fedisableexcept(FE_ALL_EXCEPT);
feenableexcept(FE_DIVBYZERO);
rv = SETJMP(env, 0);
- if (rv == 0) {
+ switch(rv) {
+ case 0: {
fexcept_t flag = FE_OVERFLOW;
/* Mess with the FPU control word. */
- fesetround(FE_DOWNWARD);
+ rv = fesetround(FE_DOWNWARD);
+ if (rv != 0)
+ errx(1, "fesetround FE_DOWNWARD returned %d", rv);
fedisableexcept(FE_DIVBYZERO);
/* Set the FPU exception flags. */
- fesetexceptflag(&flag, FE_ALL_EXCEPT);
+ rv = fesetexceptflag(&flag, FE_ALL_EXCEPT);
+ if (rv != 0)
+ errx(1, "fesetexceptflag returned %d", rv);
LONGJMP(env, 1);
- } else if (rv == 1) {
+ errx(1, "longjmp returned");
+ }
+ case 1: {
fexcept_t flag = 0;
/* Verify that the FPU control word is preserved. */
- if (fegetround() != FE_UPWARD
- || fegetexcept() != FE_DIVBYZERO)
- return (1);
+ rv = fegetround();
+ if (rv != FE_UPWARD)
+ errx(1, "fegetround returned %d, not FE_UPWARD", rv);
+ rv = fegetexcept();
+ if (rv != FE_DIVBYZERO)
+ errx(1, "fegetexcept returned %d, not FE_DIVBYZERO",
+ rv);
/* Verify that the FPU exception flags weren't clobbered. */
- fegetexceptflag(&flag, FE_ALL_EXCEPT);
+ rv = fegetexceptflag(&flag, FE_ALL_EXCEPT);
+ if (rv != 0)
+ errx(1, "fegetexceptflag returned %d", rv);
if (flag != FE_OVERFLOW)
- return (1);
+ errx(1, "except flag is %d, no FE_OVERFLOW", rv);
return (0);
}
-
- /* This is not supposed to happen. */
- return (1);
+ default:
+ errx(1, "setjmp returned %d", rv);
+ }
}