diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libc/Makefile | 3 | ||||
| -rw-r--r-- | src/regress/lib/libc/setjmp-fpu/Makefile | 8 | ||||
| -rw-r--r-- | src/regress/lib/libc/setjmp-fpu/setjmp-fpu.c | 34 |
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 | ||
| 3 | SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env | 3 | SUBDIR+= _setjmp alloca atexit basename cephes cxa-atexit db dirname env |
| 4 | SUBDIR+= fmemopen fnmatch fpclassify getcap getopt_long glob | 4 | SUBDIR+= 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) |
| 12 | SUBDIR+= getaddrinfo | 12 | SUBDIR+= getaddrinfo |
| 13 | SUBDIR+= 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 | |||
| 3 | PROG= setjmp-fpu | ||
| 4 | SRCS= setjmp-fpu.c | ||
| 5 | |||
| 6 | LDADD= -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 | |||
| 4 | int | ||
| 5 | main(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 | } | ||
