diff options
| author | miod <> | 2004-01-15 18:53:24 +0000 |
|---|---|---|
| committer | miod <> | 2004-01-15 18:53:24 +0000 |
| commit | b4594fd38896c2ffb37c430cb680d9a4a2c6ad0d (patch) | |
| tree | 78f778214dbc465eaed1d49a55652ddf4e8e2c93 /src/regress/lib/libc/ieeefp/infinity/infinity.c | |
| parent | c1bb64f8042660ab47b0a566fa595b844e3da388 (diff) | |
| download | openbsd-b4594fd38896c2ffb37c430cb680d9a4a2c6ad0d.tar.gz openbsd-b4594fd38896c2ffb37c430cb680d9a4a2c6ad0d.tar.bz2 openbsd-b4594fd38896c2ffb37c430cb680d9a4a2c6ad0d.zip | |
Add a new regression test, which checks that we handle fp overflow correctly,
and produce a correct infinity.
Currently, this tests fails on 68060 (060sp is to blame) and 88100 processors,
and maybe more.
Diffstat (limited to 'src/regress/lib/libc/ieeefp/infinity/infinity.c')
| -rw-r--r-- | src/regress/lib/libc/ieeefp/infinity/infinity.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/regress/lib/libc/ieeefp/infinity/infinity.c b/src/regress/lib/libc/ieeefp/infinity/infinity.c new file mode 100644 index 0000000000..0f60b4762b --- /dev/null +++ b/src/regress/lib/libc/ieeefp/infinity/infinity.c | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | /* $OpenBSD: infinity.c,v 1.1 2004/01/15 18:53:24 miod Exp $ */ | ||
| 2 | /* | ||
| 3 | * Written by Miodrag Vallat, 2004 - Public Domain | ||
| 4 | * Inspired from Perl's t/op/arith test #134 | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | #include <signal.h> | ||
| 9 | |||
| 10 | void | ||
| 11 | sigfpe(int signum) | ||
| 12 | { | ||
| 13 | /* looks like we don't handle fp overflow correctly... */ | ||
| 14 | _exit(1); | ||
| 15 | } | ||
| 16 | |||
| 17 | int | ||
| 18 | main(int argc, char *argv[]) | ||
| 19 | { | ||
| 20 | double d, u; | ||
| 21 | int i; | ||
| 22 | |||
| 23 | signal(SIGFPE, sigfpe); | ||
| 24 | |||
| 25 | d = 1.0; | ||
| 26 | for (i = 2000; i != 0; i--) { | ||
| 27 | d = d * 2.0; | ||
| 28 | } | ||
| 29 | |||
| 30 | /* result should be _positive_ infinity */ | ||
| 31 | return ((isinf(d) && copysign(1.0, d) > 0.0) ? 0 : 1); | ||
| 32 | } | ||
