Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/m9x/modfl.c
+++ new/usr/src/lib/libm/common/m9x/modfl.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 +
25 26 /*
26 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 28 * Use is subject to license terms.
28 29 */
29 30
30 31 #pragma weak modfl = __modfl
31 32
32 33 #include "libm.h"
33 34
34 35 #if defined(__sparc)
35 -
36 36 long double
37 -__modfl(long double x, long double *iptr) {
37 +__modfl(long double x, long double *iptr)
38 +{
38 39 union {
39 40 unsigned i[4];
40 41 long double q;
41 42 } xx, yy;
43 +
42 44 unsigned hx, s;
43 45
44 46 xx.q = x;
45 47 hx = xx.i[0] & ~0x80000000;
46 48
47 - if (hx >= 0x406f0000) { /* x is NaN, infinite, or integral */
49 + if (hx >= 0x406f0000) { /* x is NaN, infinite, or integral */
48 50 *iptr = x;
49 - if (hx < 0x7fff0000 || (hx == 0x7fff0000 &&
50 - (xx.i[1] | xx.i[2] | xx.i[3]) == 0)) {
51 +
52 + if (hx < 0x7fff0000 || (hx == 0x7fff0000 && (xx.i[1] | xx.i[2] |
53 + xx.i[3]) == 0)) {
51 54 xx.i[0] &= 0x80000000;
52 55 xx.i[1] = xx.i[2] = xx.i[3] = 0;
53 56 }
57 +
54 58 return (xx.q);
55 59 }
56 60
57 - if (hx < 0x3fff0000) { /* |x| < 1 */
61 + if (hx < 0x3fff0000) { /* |x| < 1 */
58 62 xx.i[0] &= 0x80000000;
59 63 xx.i[1] = xx.i[2] = xx.i[3] = 0;
60 64 *iptr = xx.q;
61 65 return (x);
62 66 }
63 67
64 68 /* split x at the binary point */
65 69 s = xx.i[0] & 0x80000000;
70 +
66 71 if (hx < 0x40100000) {
67 72 yy.i[0] = xx.i[0] & ~((1 << (0x400f - (hx >> 16))) - 1);
68 73 yy.i[1] = yy.i[2] = yy.i[3] = 0;
69 74 } else if (hx < 0x40300000) {
70 75 yy.i[0] = xx.i[0];
71 76 yy.i[1] = xx.i[1] & ~((1 << (0x402f - (hx >> 16))) - 1);
72 77 yy.i[2] = yy.i[3] = 0;
73 78 } else if (hx < 0x40500000) {
74 79 yy.i[0] = xx.i[0];
75 80 yy.i[1] = xx.i[1];
76 81 yy.i[2] = xx.i[2] & ~((1 << (0x404f - (hx >> 16))) - 1);
77 82 yy.i[3] = 0;
78 83 } else {
79 84 yy.i[0] = xx.i[0];
80 85 yy.i[1] = xx.i[1];
81 86 yy.i[2] = xx.i[2];
82 87 yy.i[3] = xx.i[3] & ~((1 << (0x406f - (hx >> 16))) - 1);
83 88 }
89 +
84 90 *iptr = yy.q;
85 91
86 92 /*
87 93 * we could implement the following more efficiently than by using
88 94 * software emulation of fsubq, but we'll do it this way for now
89 95 * (and hope hardware support becomes commonplace)
90 96 */
91 97 xx.q -= yy.q;
92 98 xx.i[0] = (xx.i[0] & ~0x80000000) | s; /* keep sign of x */
93 99 return (xx.q);
94 100 }
95 -
96 101 #elif defined(__x86)
97 -
98 102 long double
99 -__modfl(long double x, long double *iptr) {
103 +__modfl(long double x, long double *iptr)
104 +{
100 105 union {
101 106 unsigned i[3];
102 107 long double e;
103 108 } xx, yy;
109 +
104 110 unsigned hx, s;
105 111
106 112 /*
107 113 * It might be faster to use one of the x86 fpops instead of
108 114 * the following.
109 115 */
110 116 xx.e = x;
111 117 hx = xx.i[2] & 0x7fff;
112 118
113 - if (hx >= 0x403e) { /* x is NaN, infinite, or integral */
119 + if (hx >= 0x403e) { /* x is NaN, infinite, or integral */
114 120 *iptr = x;
115 - if (hx < 0x7fff || (hx == 0x7fff &&
116 - ((xx.i[1] << 1) | xx.i[0]) == 0)) {
121 +
122 + if (hx < 0x7fff || (hx == 0x7fff && ((xx.i[1] << 1) |
123 + xx.i[0]) == 0)) {
117 124 xx.i[2] &= 0x8000;
118 125 xx.i[1] = xx.i[0] = 0;
119 126 }
127 +
120 128 return (xx.e);
121 129 }
122 130
123 - if (hx < 0x3fff) { /* |x| < 1 */
131 + if (hx < 0x3fff) { /* |x| < 1 */
124 132 xx.i[2] &= 0x8000;
125 133 xx.i[1] = xx.i[0] = 0;
126 134 *iptr = xx.e;
127 135 return (x);
128 136 }
129 137
130 138 /* split x at the binary point */
131 139 s = xx.i[2] & 0x8000;
132 140 yy.i[2] = xx.i[2];
141 +
133 142 if (hx < 0x401f) {
134 143 yy.i[1] = xx.i[1] & ~((1 << (0x401e - hx)) - 1);
135 144 yy.i[0] = 0;
136 145 } else {
137 146 yy.i[1] = xx.i[1];
138 147 yy.i[0] = xx.i[0] & ~((1 << (0x403e - hx)) - 1);
139 148 }
149 +
140 150 *iptr = yy.e;
141 151 xx.e -= yy.e;
142 152 xx.i[2] = (xx.i[2] & ~0x8000) | s; /* keep sign of x */
143 153 return (xx.e);
144 154 }
145 -
146 155 #else
147 156 #error Unknown architecture
148 157 #endif
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX