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 | |
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')
-rw-r--r-- | src/regress/lib/libc/ieeefp/Makefile | 4 | ||||
-rw-r--r-- | src/regress/lib/libc/ieeefp/infinity/Makefile | 9 | ||||
-rw-r--r-- | src/regress/lib/libc/ieeefp/infinity/infinity.c | 32 |
3 files changed, 43 insertions, 2 deletions
diff --git a/src/regress/lib/libc/ieeefp/Makefile b/src/regress/lib/libc/ieeefp/Makefile index f9a6035fa9..89ff51a2e7 100644 --- a/src/regress/lib/libc/ieeefp/Makefile +++ b/src/regress/lib/libc/ieeefp/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | # $OpenBSD: Makefile,v 1.5 2002/02/23 01:25:11 art Exp $ | 1 | # $OpenBSD: Makefile,v 1.6 2004/01/15 18:53:23 miod Exp $ |
2 | # $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $ | 2 | # $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $ |
3 | 3 | ||
4 | SUBDIR+= except inf round | 4 | SUBDIR+= except inf infinity round |
5 | 5 | ||
6 | install: | 6 | install: |
7 | 7 | ||
diff --git a/src/regress/lib/libc/ieeefp/infinity/Makefile b/src/regress/lib/libc/ieeefp/infinity/Makefile new file mode 100644 index 0000000000..a593fcf37d --- /dev/null +++ b/src/regress/lib/libc/ieeefp/infinity/Makefile | |||
@@ -0,0 +1,9 @@ | |||
1 | # $OpenBSD: Makefile,v 1.1 2004/01/15 18:53:24 miod Exp $ | ||
2 | |||
3 | PROG= infinity | ||
4 | SRCS= infinity.c | ||
5 | |||
6 | DPADD+= ${LIBM} | ||
7 | LDADD+= -lm | ||
8 | |||
9 | .include <bsd.regress.mk> | ||
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 | } | ||