Print this page
5262 libm needs to be carefully unifdef'd
5268 libm doesn't need to hide symbols which are already local
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.
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
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 -#if defined(ELFOBJ)
31 30 #pragma weak modfl = __modfl
32 -#endif
33 31
34 32 #include "libm.h"
35 33
36 34 #if defined(__sparc)
37 35
38 36 long double
39 37 __modfl(long double x, long double *iptr) {
40 38 union {
41 39 unsigned i[4];
42 40 long double q;
43 41 } xx, yy;
44 42 unsigned hx, s;
45 43
46 44 xx.q = x;
47 45 hx = xx.i[0] & ~0x80000000;
48 46
49 47 if (hx >= 0x406f0000) { /* x is NaN, infinite, or integral */
50 48 *iptr = x;
51 49 if (hx < 0x7fff0000 || (hx == 0x7fff0000 &&
52 50 (xx.i[1] | xx.i[2] | xx.i[3]) == 0)) {
53 51 xx.i[0] &= 0x80000000;
54 52 xx.i[1] = xx.i[2] = xx.i[3] = 0;
55 53 }
56 54 return (xx.q);
57 55 }
58 56
59 57 if (hx < 0x3fff0000) { /* |x| < 1 */
60 58 xx.i[0] &= 0x80000000;
61 59 xx.i[1] = xx.i[2] = xx.i[3] = 0;
62 60 *iptr = xx.q;
63 61 return (x);
64 62 }
65 63
66 64 /* split x at the binary point */
67 65 s = xx.i[0] & 0x80000000;
68 66 if (hx < 0x40100000) {
69 67 yy.i[0] = xx.i[0] & ~((1 << (0x400f - (hx >> 16))) - 1);
70 68 yy.i[1] = yy.i[2] = yy.i[3] = 0;
71 69 } else if (hx < 0x40300000) {
72 70 yy.i[0] = xx.i[0];
73 71 yy.i[1] = xx.i[1] & ~((1 << (0x402f - (hx >> 16))) - 1);
74 72 yy.i[2] = yy.i[3] = 0;
75 73 } else if (hx < 0x40500000) {
76 74 yy.i[0] = xx.i[0];
77 75 yy.i[1] = xx.i[1];
78 76 yy.i[2] = xx.i[2] & ~((1 << (0x404f - (hx >> 16))) - 1);
79 77 yy.i[3] = 0;
80 78 } else {
81 79 yy.i[0] = xx.i[0];
82 80 yy.i[1] = xx.i[1];
83 81 yy.i[2] = xx.i[2];
84 82 yy.i[3] = xx.i[3] & ~((1 << (0x406f - (hx >> 16))) - 1);
85 83 }
86 84 *iptr = yy.q;
87 85
88 86 /*
89 87 * we could implement the following more efficiently than by using
90 88 * software emulation of fsubq, but we'll do it this way for now
91 89 * (and hope hardware support becomes commonplace)
92 90 */
93 91 xx.q -= yy.q;
94 92 xx.i[0] = (xx.i[0] & ~0x80000000) | s; /* keep sign of x */
95 93 return (xx.q);
96 94 }
97 95
98 96 #elif defined(__x86)
99 97
100 98 long double
101 99 __modfl(long double x, long double *iptr) {
102 100 union {
103 101 unsigned i[3];
104 102 long double e;
105 103 } xx, yy;
106 104 unsigned hx, s;
107 105
108 106 /*
109 107 * It might be faster to use one of the x86 fpops instead of
110 108 * the following.
111 109 */
112 110 xx.e = x;
113 111 hx = xx.i[2] & 0x7fff;
114 112
115 113 if (hx >= 0x403e) { /* x is NaN, infinite, or integral */
116 114 *iptr = x;
117 115 if (hx < 0x7fff || (hx == 0x7fff &&
118 116 ((xx.i[1] << 1) | xx.i[0]) == 0)) {
119 117 xx.i[2] &= 0x8000;
120 118 xx.i[1] = xx.i[0] = 0;
121 119 }
122 120 return (xx.e);
123 121 }
124 122
125 123 if (hx < 0x3fff) { /* |x| < 1 */
126 124 xx.i[2] &= 0x8000;
127 125 xx.i[1] = xx.i[0] = 0;
128 126 *iptr = xx.e;
129 127 return (x);
130 128 }
131 129
132 130 /* split x at the binary point */
133 131 s = xx.i[2] & 0x8000;
134 132 yy.i[2] = xx.i[2];
135 133 if (hx < 0x401f) {
136 134 yy.i[1] = xx.i[1] & ~((1 << (0x401e - hx)) - 1);
137 135 yy.i[0] = 0;
138 136 } else {
139 137 yy.i[1] = xx.i[1];
140 138 yy.i[0] = xx.i[0] & ~((1 << (0x403e - hx)) - 1);
141 139 }
142 140 *iptr = yy.e;
143 141 xx.e -= yy.e;
144 142 xx.i[2] = (xx.i[2] & ~0x8000) | s; /* keep sign of x */
145 143 return (xx.e);
146 144 }
147 145
148 146 #else
149 147 #error Unknown architecture
150 148 #endif
↓ open down ↓ |
108 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX