diff options
| author | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 1998-10-19 21:47:12 +0000 |
| commit | 5170039cf1df2194faa85741f0733977525cd5c0 (patch) | |
| tree | c667406046ddb1efca5ed4316b02e43494241660 /src/regress/lib/libc/ieeefp | |
| parent | 536c76cbb863bab152f19842ab88772c01e922c7 (diff) | |
| download | openbsd-OPENBSD_2_4_BASE.tar.gz openbsd-OPENBSD_2_4_BASE.tar.bz2 openbsd-OPENBSD_2_4_BASE.zip | |
This commit was manufactured by cvs2git to create tag 'OPENBSD_2_4_BASE'.OPENBSD_2_4_BASE
Diffstat (limited to 'src/regress/lib/libc/ieeefp')
| -rw-r--r-- | src/regress/lib/libc/ieeefp/Makefile | 9 | ||||
| -rw-r--r-- | src/regress/lib/libc/ieeefp/except/Makefile | 12 | ||||
| -rw-r--r-- | src/regress/lib/libc/ieeefp/except/except.c | 88 | ||||
| -rw-r--r-- | src/regress/lib/libc/ieeefp/round/Makefile | 12 | ||||
| -rw-r--r-- | src/regress/lib/libc/ieeefp/round/round.c | 44 |
5 files changed, 165 insertions, 0 deletions
diff --git a/src/regress/lib/libc/ieeefp/Makefile b/src/regress/lib/libc/ieeefp/Makefile new file mode 100644 index 0000000000..0f453a31e9 --- /dev/null +++ b/src/regress/lib/libc/ieeefp/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $ | ||
| 2 | |||
| 3 | SUBDIR+= except round | ||
| 4 | |||
| 5 | regress: _SUBDIRUSE | ||
| 6 | |||
| 7 | install: | ||
| 8 | |||
| 9 | .include <bsd.subdir.mk> | ||
diff --git a/src/regress/lib/libc/ieeefp/except/Makefile b/src/regress/lib/libc/ieeefp/except/Makefile new file mode 100644 index 0000000000..91f24f15f6 --- /dev/null +++ b/src/regress/lib/libc/ieeefp/except/Makefile | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | # $NetBSD: Makefile,v 1.1 1995/04/26 00:27:25 jtc Exp $ | ||
| 2 | |||
| 3 | PROG= except | ||
| 4 | SRCS= except.c | ||
| 5 | NOMAN= | ||
| 6 | |||
| 7 | install: | ||
| 8 | |||
| 9 | regress: ${PROG} | ||
| 10 | ./${PROG} | ||
| 11 | |||
| 12 | .include <bsd.prog.mk> | ||
diff --git a/src/regress/lib/libc/ieeefp/except/except.c b/src/regress/lib/libc/ieeefp/except/except.c new file mode 100644 index 0000000000..a2a107a788 --- /dev/null +++ b/src/regress/lib/libc/ieeefp/except/except.c | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <signal.h> | ||
| 3 | #include <assert.h> | ||
| 4 | #include <ieeefp.h> | ||
| 5 | #include <float.h> | ||
| 6 | |||
| 7 | void sigfpe(); | ||
| 8 | volatile sig_atomic_t signal_cought; | ||
| 9 | |||
| 10 | static volatile const double one = 1.0; | ||
| 11 | static volatile const double zero = 0.0; | ||
| 12 | static volatile const double huge = DBL_MAX; | ||
| 13 | static volatile const double tiny = DBL_MIN; | ||
| 14 | |||
| 15 | int | ||
| 16 | main() | ||
| 17 | { | ||
| 18 | volatile double x; | ||
| 19 | |||
| 20 | /* | ||
| 21 | * check to make sure that all exceptions are masked and | ||
| 22 | * that the accumulated exception status is clear. | ||
| 23 | */ | ||
| 24 | assert(fpgetmask() == 0); | ||
| 25 | assert(fpgetsticky() == 0); | ||
| 26 | |||
| 27 | /* set up signal handler */ | ||
| 28 | signal (SIGFPE, sigfpe); | ||
| 29 | signal_cought = 0; | ||
| 30 | |||
| 31 | /* trip divide by zero */ | ||
| 32 | x = one / zero; | ||
| 33 | assert (fpgetsticky() & FP_X_DZ); | ||
| 34 | assert (signal_cought == 0); | ||
| 35 | fpsetsticky(0); | ||
| 36 | |||
| 37 | /* trip invalid operation */ | ||
| 38 | x = zero / zero; | ||
| 39 | assert (fpgetsticky() & FP_X_INV); | ||
| 40 | assert (signal_cought == 0); | ||
| 41 | fpsetsticky(0); | ||
| 42 | |||
| 43 | /* trip overflow */ | ||
| 44 | x = huge * huge; | ||
| 45 | assert (fpgetsticky() & FP_X_OFL); | ||
| 46 | assert (signal_cought == 0); | ||
| 47 | fpsetsticky(0); | ||
| 48 | |||
| 49 | /* trip underflow */ | ||
| 50 | x = tiny * tiny; | ||
| 51 | assert (fpgetsticky() & FP_X_UFL); | ||
| 52 | assert (signal_cought == 0); | ||
| 53 | fpsetsticky(0); | ||
| 54 | |||
| 55 | #if 0 | ||
| 56 | /* unmask and then trip divide by zero */ | ||
| 57 | fpsetmask(FP_X_DZ); | ||
| 58 | x = one / zero; | ||
| 59 | assert (signal_cought == 1); | ||
| 60 | signal_cought = 0; | ||
| 61 | |||
| 62 | /* unmask and then trip invalid operation */ | ||
| 63 | fpsetmask(FP_X_INV); | ||
| 64 | x = zero / zero; | ||
| 65 | assert (signal_cought == 1); | ||
| 66 | signal_cought = 0; | ||
| 67 | |||
| 68 | /* unmask and then trip overflow */ | ||
| 69 | fpsetmask(FP_X_OFL); | ||
| 70 | x = huge * huge; | ||
| 71 | assert (signal_cought == 1); | ||
| 72 | signal_cought = 0; | ||
| 73 | |||
| 74 | /* unmask and then trip underflow */ | ||
| 75 | fpsetmask(FP_X_UFL); | ||
| 76 | x = tiny * tiny; | ||
| 77 | assert (signal_cought == 1); | ||
| 78 | signal_cought = 0; | ||
| 79 | #endif | ||
| 80 | |||
| 81 | exit(0); | ||
| 82 | } | ||
| 83 | |||
| 84 | void | ||
| 85 | sigfpe() | ||
| 86 | { | ||
| 87 | signal_cought = 1; | ||
| 88 | } | ||
diff --git a/src/regress/lib/libc/ieeefp/round/Makefile b/src/regress/lib/libc/ieeefp/round/Makefile new file mode 100644 index 0000000000..571133436c --- /dev/null +++ b/src/regress/lib/libc/ieeefp/round/Makefile | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | # $NetBSD: Makefile,v 1.1 1995/04/26 00:27:27 jtc Exp $ | ||
| 2 | |||
| 3 | PROG= round | ||
| 4 | SRCS= round.c | ||
| 5 | NOMAN= | ||
| 6 | |||
| 7 | install: | ||
| 8 | |||
| 9 | regress: ${PROG} | ||
| 10 | ./${PROG} | ||
| 11 | |||
| 12 | .include <bsd.prog.mk> | ||
diff --git a/src/regress/lib/libc/ieeefp/round/round.c b/src/regress/lib/libc/ieeefp/round/round.c new file mode 100644 index 0000000000..b9fcd9771e --- /dev/null +++ b/src/regress/lib/libc/ieeefp/round/round.c | |||
| @@ -0,0 +1,44 @@ | |||
| 1 | /* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Written by J.T. Conklin, Apr 18, 1995 | ||
| 5 | * Public domain. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <assert.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <ieeefp.h> | ||
| 11 | #include <float.h> | ||
| 12 | |||
| 13 | int | ||
| 14 | main() | ||
| 15 | { | ||
| 16 | /* | ||
| 17 | * This test would be better if it actually performed some | ||
| 18 | * calculations to verify the selected rounding mode. But | ||
| 19 | * this is probably acceptable since the fp{get,set}round | ||
| 20 | * functions usually just get or set the processors fpu | ||
| 21 | * control word. | ||
| 22 | */ | ||
| 23 | |||
| 24 | assert(fpgetround() == FP_RN); | ||
| 25 | assert(FLT_ROUNDS == 1); | ||
| 26 | |||
| 27 | assert(fpsetround(FP_RP) == FP_RN); | ||
| 28 | assert(fpgetround() == FP_RP); | ||
| 29 | assert(FLT_ROUNDS == 2); | ||
| 30 | |||
| 31 | assert(fpsetround(FP_RM) == FP_RP); | ||
| 32 | assert(fpgetround() == FP_RM); | ||
| 33 | assert(FLT_ROUNDS == 3); | ||
| 34 | |||
| 35 | assert(fpsetround(FP_RZ) == FP_RM); | ||
| 36 | assert(fpgetround() == FP_RZ); | ||
| 37 | assert(FLT_ROUNDS == 0); | ||
| 38 | |||
| 39 | assert(fpsetround(FP_RN) == FP_RZ); | ||
| 40 | assert(fpgetround() == FP_RN); | ||
| 41 | assert(FLT_ROUNDS == 1); | ||
| 42 | |||
| 43 | exit(0); | ||
| 44 | } | ||
