diff options
| author | deraadt <> | 1995-10-18 08:49:34 +0000 |
|---|---|---|
| committer | deraadt <> | 1995-10-18 08:49:34 +0000 |
| commit | a4f79641824cbf9f60ca9d1168d1fcc46717a82a (patch) | |
| tree | 3a9a60a6831189695ecfa7eb6904bce69aec0bcb /src/regress/lib/libc/ieeefp | |
| parent | 0527d29da443886d92e9a418180c5b25a5f8d270 (diff) | |
| download | openbsd-a4f79641824cbf9f60ca9d1168d1fcc46717a82a.tar.gz openbsd-a4f79641824cbf9f60ca9d1168d1fcc46717a82a.tar.bz2 openbsd-a4f79641824cbf9f60ca9d1168d1fcc46717a82a.zip | |
initial import of NetBSD tree
Diffstat (limited to 'src/regress/lib/libc/ieeefp')
| -rw-r--r-- | src/regress/lib/libc/ieeefp/Makefile | 13 | ||||
| -rw-r--r-- | src/regress/lib/libc/ieeefp/except/Makefile | 12 | ||||
| -rw-r--r-- | src/regress/lib/libc/ieeefp/except/except.c | 87 | ||||
| -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, 168 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..4e2e517b03 --- /dev/null +++ b/src/regress/lib/libc/ieeefp/Makefile | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | # $NetBSD: Makefile,v 1.4 1995/10/03 21:59:36 phil Exp $ | ||
| 2 | |||
| 3 | .if ${MACHINE} == "pc532" | ||
| 4 | SUBDIR+= round | ||
| 5 | .else | ||
| 6 | SUBDIR+= except round | ||
| 7 | .endif | ||
| 8 | |||
| 9 | regress: _SUBDIRUSE | ||
| 10 | |||
| 11 | install: | ||
| 12 | |||
| 13 | .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..0ffdcdd468 --- /dev/null +++ b/src/regress/lib/libc/ieeefp/except/except.c | |||
| @@ -0,0 +1,87 @@ | |||
| 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 | main() | ||
| 16 | { | ||
| 17 | volatile double x; | ||
| 18 | |||
| 19 | /* | ||
| 20 | * check to make sure that all exceptions are masked and | ||
| 21 | * that the accumulated exception status is clear. | ||
| 22 | */ | ||
| 23 | assert(fpgetmask() == 0); | ||
| 24 | assert(fpgetsticky() == 0); | ||
| 25 | |||
| 26 | /* set up signal handler */ | ||
| 27 | signal (SIGFPE, sigfpe); | ||
| 28 | signal_cought = 0; | ||
| 29 | |||
| 30 | /* trip divide by zero */ | ||
| 31 | x = one / zero; | ||
| 32 | assert (fpgetsticky() & FP_X_DZ); | ||
| 33 | assert (signal_cought == 0); | ||
| 34 | fpsetsticky(0); | ||
| 35 | |||
| 36 | /* trip invalid operation */ | ||
| 37 | x = zero / zero; | ||
| 38 | assert (fpgetsticky() & FP_X_INV); | ||
| 39 | assert (signal_cought == 0); | ||
| 40 | fpsetsticky(0); | ||
| 41 | |||
| 42 | /* trip overflow */ | ||
| 43 | x = huge * huge; | ||
| 44 | assert (fpgetsticky() & FP_X_OFL); | ||
| 45 | assert (signal_cought == 0); | ||
| 46 | fpsetsticky(0); | ||
| 47 | |||
| 48 | /* trip underflow */ | ||
| 49 | x = tiny * tiny; | ||
| 50 | assert (fpgetsticky() & FP_X_UFL); | ||
| 51 | assert (signal_cought == 0); | ||
| 52 | fpsetsticky(0); | ||
| 53 | |||
| 54 | #if 0 | ||
| 55 | /* unmask and then trip divide by zero */ | ||
| 56 | fpsetmask(FP_X_DZ); | ||
| 57 | x = one / zero; | ||
| 58 | assert (signal_cought == 1); | ||
| 59 | signal_cought = 0; | ||
| 60 | |||
| 61 | /* unmask and then trip invalid operation */ | ||
| 62 | fpsetmask(FP_X_INV); | ||
| 63 | x = zero / zero; | ||
| 64 | assert (signal_cought == 1); | ||
| 65 | signal_cought = 0; | ||
| 66 | |||
| 67 | /* unmask and then trip overflow */ | ||
| 68 | fpsetmask(FP_X_OFL); | ||
| 69 | x = huge * huge; | ||
| 70 | assert (signal_cought == 1); | ||
| 71 | signal_cought = 0; | ||
| 72 | |||
| 73 | /* unmask and then trip underflow */ | ||
| 74 | fpsetmask(FP_X_UFL); | ||
| 75 | x = tiny * tiny; | ||
| 76 | assert (signal_cought == 1); | ||
| 77 | signal_cought = 0; | ||
| 78 | #endif | ||
| 79 | |||
| 80 | exit(0); | ||
| 81 | } | ||
| 82 | |||
| 83 | void | ||
| 84 | sigfpe() | ||
| 85 | { | ||
| 86 | signal_cought = 1; | ||
| 87 | } | ||
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 | } | ||
