7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include "lint.h"
28 #include <sys/types.h>
29 #include "base_conversion.h"
30 #include <sys/isa_defs.h>
31
32 /*
33 * Miscellaneous support routines used in base conversion
34 */
35
36 static const union {
37 unsigned int u[2];
38 double d;
39 } C[] = {
40 #ifdef _LITTLE_ENDIAN
41 { 0x00000000u, 0x00100000u },
42 { 0x00000001u, 0x7ff00000u }
43 #else
44 { 0x00100000u, 0x00000000u },
45 { 0x7ff00000u, 0x00000001u }
46 #endif
71 * accumulator, causing inexact trap prior to overflow trap
72 * on store.
73 */
74 } else if ((ef & (1 << fp_underflow)) != 0) {
75 t = minnormal;
76 } else
77 return;
78
79 /* Storage forces exception */
80 tstored = t * t;
81 #if defined(__lint)
82 tstored = tstored;
83 #endif
84 }
85
86 /*
87 * The following routine is no longer used in libc, but we have
88 * to leave it for now because it's still used by Sun's old Fortran
89 * runtime libraries. Today this is a bug; in the days of SunOS 4.x,
90 * when the relevant design decisions were made, it was a feature.
91 */
92 enum fp_class_type
93 __class_quadruple(quadruple *x)
94 {
95 quadruple_equivalence kluge;
96
97 kluge.x = *x;
98 if (kluge.f.msw.exponent == 0) { /* 0 or sub */
99 if ((kluge.f.msw.significand == 0) &&
100 (kluge.f.significand2 == 0) &&
101 (kluge.f.significand3 == 0) &&
102 (kluge.f.significand4 == 0))
103 return (fp_zero);
104 else
105 return (fp_subnormal);
106 } else if (kluge.f.msw.exponent == 0x7fff) { /* inf or nan */
107 if ((kluge.f.msw.significand == 0) &&
108 (kluge.f.significand2 == 0) &&
109 (kluge.f.significand3 == 0) &&
110 (kluge.f.significand4 == 0))
111 return (fp_infinity);
|
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright 2019 Joyent, Inc.
29 */
30
31 #include "lint.h"
32 #include <sys/types.h>
33 #include "base_conversion.h"
34 #include <sys/isa_defs.h>
35
36 /*
37 * Miscellaneous support routines used in base conversion
38 */
39
40 static const union {
41 unsigned int u[2];
42 double d;
43 } C[] = {
44 #ifdef _LITTLE_ENDIAN
45 { 0x00000000u, 0x00100000u },
46 { 0x00000001u, 0x7ff00000u }
47 #else
48 { 0x00100000u, 0x00000000u },
49 { 0x7ff00000u, 0x00000001u }
50 #endif
75 * accumulator, causing inexact trap prior to overflow trap
76 * on store.
77 */
78 } else if ((ef & (1 << fp_underflow)) != 0) {
79 t = minnormal;
80 } else
81 return;
82
83 /* Storage forces exception */
84 tstored = t * t;
85 #if defined(__lint)
86 tstored = tstored;
87 #endif
88 }
89
90 /*
91 * The following routine is no longer used in libc, but we have
92 * to leave it for now because it's still used by Sun's old Fortran
93 * runtime libraries. Today this is a bug; in the days of SunOS 4.x,
94 * when the relevant design decisions were made, it was a feature.
95 *
96 * Regardless, on 32-bit, 'quadruple' under GCC is not 128 bits, so it
97 * uses uninitialized memory...
98 */
99 #pragma GCC diagnostic ignored "-Wuninitialized"
100 enum fp_class_type
101 __class_quadruple(quadruple *x)
102 {
103 quadruple_equivalence kluge;
104
105 kluge.x = *x;
106 if (kluge.f.msw.exponent == 0) { /* 0 or sub */
107 if ((kluge.f.msw.significand == 0) &&
108 (kluge.f.significand2 == 0) &&
109 (kluge.f.significand3 == 0) &&
110 (kluge.f.significand4 == 0))
111 return (fp_zero);
112 else
113 return (fp_subnormal);
114 } else if (kluge.f.msw.exponent == 0x7fff) { /* inf or nan */
115 if ((kluge.f.msw.significand == 0) &&
116 (kluge.f.significand2 == 0) &&
117 (kluge.f.significand3 == 0) &&
118 (kluge.f.significand4 == 0))
119 return (fp_infinity);
|