-# $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
--- /dev/null
+#define SETJMP(env, savemask) _setjmp(env)
+#define LONGJMP(env, val) _longjmp(env, val)
+#define TEST_SETJMP test__setjmp
+
+#include "setjmp-fpu.c"
#include <setjmp.h>
int
-main(int argc, char *argv[])
+TEST_SETJMP(int argc, char *argv[])
{
jmp_buf env;
int rv;
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);
}
--- /dev/null
+#define SETJMP(env, savemask) setjmp(env)
+#define LONGJMP(env, val) longjmp(env, val)
+#define TEST_SETJMP test_setjmp
+
+#include "setjmp-fpu.c"
--- /dev/null
+#define SETJMP(env, savemask) sigsetjmp(env, savemask)
+#define LONGJMP(env, val) siglongjmp(env, val)
+#define TEST_SETJMP test_sigsetjmp
+
+#include "setjmp-fpu.c"