diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-07-13 14:53:55 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2005-07-13 14:53:55 +0000 |
commit | 0147d73439fae6cc68545c98899dbd920e45b067 (patch) | |
tree | a55bf2fbe9257834ce8f4586422f57810c8e4c90 /regress/sys/kern | |
parent | 0aebd68c444b0b85d8331fe71108a2ef6f838684 (diff) |
As mickey@ pointed out, this test does not belong in libm. Move to
correct place.
Diffstat (limited to 'regress/sys/kern')
-rw-r--r-- | regress/sys/kern/signal/Makefile | 4 | ||||
-rw-r--r-- | regress/sys/kern/signal/fpsig/Makefile | 5 | ||||
-rw-r--r-- | regress/sys/kern/signal/fpsig/fpsig.c | 54 |
3 files changed, 61 insertions, 2 deletions
diff --git a/regress/sys/kern/signal/Makefile b/regress/sys/kern/signal/Makefile index c7d0d4023a7..234b1e3a15d 100644 --- a/regress/sys/kern/signal/Makefile +++ b/regress/sys/kern/signal/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.1 2002/04/30 23:23:39 millert Exp $ +# $OpenBSD: Makefile,v 1.2 2005/07/13 14:53:54 otto Exp $ -SUBDIR+= sigfpe siginfo_addr +SUBDIR+= sigfpe siginfo_addr fpsig install: diff --git a/regress/sys/kern/signal/fpsig/Makefile b/regress/sys/kern/signal/fpsig/Makefile new file mode 100644 index 00000000000..613b8d94882 --- /dev/null +++ b/regress/sys/kern/signal/fpsig/Makefile @@ -0,0 +1,5 @@ +# $OpenBSD: Makefile,v 1.1 2005/07/13 14:53:54 otto Exp $ + +PROG=fpsig + +.include <bsd.regress.mk> diff --git a/regress/sys/kern/signal/fpsig/fpsig.c b/regress/sys/kern/signal/fpsig/fpsig.c new file mode 100644 index 00000000000..85560340d95 --- /dev/null +++ b/regress/sys/kern/signal/fpsig/fpsig.c @@ -0,0 +1,54 @@ +/* $OpenBSD: fpsig.c,v 1.1 2005/07/13 14:53:54 otto Exp $ */ + +/* + * Public domain. 2005, Otto Moerbeek + * + * Try to check if fp registers are properly saved and restored while + * calling a signal hander. This is not supposed to catch all that + * can go wrong, but trashed fp regsiters will typically get caught. + */ + +#include <err.h> +#include <signal.h> +#include <unistd.h> + +#define LIMIT 10.0 + +volatile sig_atomic_t count; + +double g1; +double g2; + +void +handler(int signo) +{ + double a, b, c = 0.0; + + if (signo) + alarm(1); + for (a = 0.0; a < LIMIT; a++) + for (b = 0.0; b < LIMIT; b++) + c += a * a + b * b; + + if (signo) { + g1 = c; + count++; + } else + g2 = c; +} + +int +main() +{ + signal(SIGALRM, handler); + /* initialize global vars */ + handler(0); + handler(1); + + while (count < 10) { + handler(0); + if (g1 != g2) + errx(1, "%f %f", g1, g2); + } + return (0); +} |