6811333 Remove prom_printf() message in emlxs driver
[opensolaris.git] / usr / src / lib / libc / port / fp / _base_sup.c
blobb07957740c587ba49e433a854712bf77a588f736
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include "lint.h"
30 #include <sys/types.h>
31 #include "base_conversion.h"
32 #include <sys/isa_defs.h>
35 * Miscellaneous support routines used in base conversion
38 static const union {
39 unsigned int u[2];
40 double d;
41 } C[] = {
42 #ifdef _LITTLE_ENDIAN
43 { 0x00000000u, 0x00100000u },
44 { 0x00000001u, 0x7ff00000u }
45 #else
46 { 0x00100000u, 0x00000000u },
47 { 0x7ff00000u, 0x00000001u }
48 #endif
51 #define minnormal C[0].d
52 #define signalingnan C[1].d
54 /* raise the floating point exceptions indicated by ef */
55 void
56 __base_conversion_set_exception(fp_exception_field_type ef)
58 double t;
59 volatile double tstored;
61 if (ef == (1 << fp_inexact)) {
62 t = 9.999999962747097015E-1;
64 * 28 sig bits so product isn't inexact in extended
65 * accumulator, causing two inexact traps.
67 } else if ((ef & (1 << fp_invalid)) != 0) {
68 t = signalingnan;
69 } else if ((ef & (1 << fp_overflow)) != 0) {
70 t = 4.149515553422842866E+180;
72 * 28 sig bits so product isn't inexact in extended
73 * accumulator, causing inexact trap prior to overflow trap
74 * on store.
76 } else if ((ef & (1 << fp_underflow)) != 0) {
77 t = minnormal;
78 } else
79 return;
81 /* Storage forces exception */
82 tstored = t * t;
83 #if defined(__lint)
84 tstored = tstored;
85 #endif
89 * The following routine is no longer used in libc, but we have
90 * to leave it for now because it's still used by Sun's old Fortran
91 * runtime libraries. Today this is a bug; in the days of SunOS 4.x,
92 * when the relevant design decisions were made, it was a feature.
94 enum fp_class_type
95 __class_quadruple(quadruple *x)
97 quadruple_equivalence kluge;
99 kluge.x = *x;
100 if (kluge.f.msw.exponent == 0) { /* 0 or sub */
101 if ((kluge.f.msw.significand == 0) &&
102 (kluge.f.significand2 == 0) &&
103 (kluge.f.significand3 == 0) &&
104 (kluge.f.significand4 == 0))
105 return (fp_zero);
106 else
107 return (fp_subnormal);
108 } else if (kluge.f.msw.exponent == 0x7fff) { /* inf or nan */
109 if ((kluge.f.msw.significand == 0) &&
110 (kluge.f.significand2 == 0) &&
111 (kluge.f.significand3 == 0) &&
112 (kluge.f.significand4 == 0))
113 return (fp_infinity);
114 else if ((kluge.f.msw.significand & 0xffff) >=
115 (unsigned int)0x8000)
116 return (fp_quiet);
117 else
118 return (fp_signaling);
119 } else
120 return (fp_normal);