Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/sparcv9/src/libm_inlines.h
+++ new/usr/src/lib/libm/sparcv9/src/libm_inlines.h
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
20 20 */
21 21
22 22 /*
23 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
27 27 /*
28 28 * Copyright 2011, Richard Lowe.
29 29 */
30 30
31 31 /* Functions in this file are duplicated in locallibm.il. Keep them in sync */
32 32
33 33 #ifndef _LIBM_INLINES_H
34 34 #define _LIBM_INLINES_H
35 35
36 36 #ifdef __GNUC__
37 -
38 37 #include <sys/types.h>
39 38 #include <sys/ieeefp.h>
40 39
41 40 #ifdef __cplusplus
42 41 extern "C" {
43 42 #endif
44 43
45 44 extern __GNU_INLINE enum fp_class_type
46 45 fp_classf(float f)
47 46 {
48 47 enum fp_class_type ret;
49 48 int fint; /* scratch for f as int */
50 49 uint64_t tmp;
51 50
52 51 __asm__ __volatile__(
53 52 "fabss %3,%3\n\t"
54 53 "st %3,%1\n\t"
55 54 "ld %1,%0\n\t"
56 55 "orcc %%g0,%0,%%g0\n\t"
57 56 "be,pn %%icc,2f\n\t"
58 57 "nop\n\t"
59 58 "1:\n\t"
60 59 "sethi %%hi(0x7f800000),%2\n\t"
61 60 "andcc %0,%2,%%g0\n\t"
62 61 "bne,pt %%icc,1f\n\t"
63 62 "nop\n\t"
64 63 "or %%g0,1,%0\n\t"
65 64 "ba 2f\n\t" /* subnormal */
66 65 "nop\n\t"
67 66 "1:\n\t"
68 67 "subcc %0,%2,%%g0\n\t"
69 68 "bge,pn %%icc,1f\n\t"
70 69 "nop\n\t"
71 70 "or %%g0,2,%0\n\t"
72 71 "ba 2f\n\t" /* normal */
73 72 "nop\n\t"
74 73 "1:\n\t"
75 74 "bg,pn %%icc,1f\n\t"
76 75 "nop\n\t"
77 76 "or %%g0,3,%0\n\t"
78 77 "ba 2f\n\t" /* infinity */
79 78 "nop\n\t"
80 79 "1:\n\t"
81 80 "sethi %%hi(0x00400000),%2\n\t"
82 81 "andcc %0,%2,%%g0\n\t"
83 82 "or %%g0,4,%0\n\t"
84 83 "bne,pt %%icc,2f\n\t" /* quiet NaN */
85 84 "nop\n\t"
86 85 "or %%g0,5,%0\n\t" /* signalling NaN */
87 86 "2:\n\t"
88 87 : "=r" (ret), "=m" (fint), "=r" (tmp), "+f" (f)
89 88 :
90 89 : "cc");
91 90
92 91 return (ret);
93 92 }
94 93
95 94 extern __GNU_INLINE enum fp_class_type
96 95 fp_class(double d)
97 96 {
98 97 enum fp_class_type ret;
99 98 uint64_t dint; /* Scratch for d-as-long */
100 99 uint64_t tmp;
101 100
102 101 __asm__ __volatile__(
103 102 "fabsd %3,%3\n\t"
104 103 "std %3,%1\n\t"
105 104 "ldx %1,%0\n\t"
106 105 "orcc %%g0,%0,%%g0\n\t"
107 106 "be,pn %%xcc,2f\n\t"
108 107 "nop\n\t"
109 108 "sethi %%hi(0x7ff00000),%2\n\t"
110 109 "sllx %2,32,%2\n\t"
111 110 "andcc %0,%2,%%g0\n\t"
112 111 "bne,pt %%xcc,1f\n\t"
113 112 "nop\n\t"
114 113 "or %%g0,1,%0\n\t"
115 114 "ba 2f\n\t"
116 115 "nop\n\t"
117 116 "1:\n\t"
118 117 "subcc %0,%2,%%g0\n\t"
119 118 "bge,pn %%xcc,1f\n\t"
120 119 "nop\n\t"
121 120 "or %%g0,2,%0\n\t"
122 121 "ba 2f\n\t"
123 122 "nop\n\t"
124 123 "1:\n\t"
125 124 "andncc %0,%2,%0\n\t"
126 125 "bne,pn %%xcc,1f\n\t"
127 126 "nop\n\t"
128 127 "or %%g0,3,%0\n\t"
129 128 "ba 2f\n\t"
130 129 "nop\n\t"
131 130 "1:\n\t"
132 131 "sethi %%hi(0x00080000),%2\n\t"
133 132 "sllx %2,32,%2\n\t"
134 133 "andcc %0,%2,%%g0\n\t"
135 134 "or %%g0,4,%0\n\t"
136 135 "bne,pt %%xcc,2f\n\t"
137 136 "nop\n\t"
138 137 "or %%g0,5,%0\n\t"
139 138 "2:\n\t"
140 139 : "=r" (ret), "=m" (dint), "=r" (tmp), "+e" (d)
141 140 :
142 141 : "cc");
143 142
144 143 return (ret);
145 144 }
146 145
147 146 extern __GNU_INLINE float
148 147 __inline_sqrtf(float f)
149 148 {
150 149 float ret;
151 150
152 151 __asm__ __volatile__("fsqrts %1,%0\n\t" : "=f" (ret) : "f" (f));
153 152 return (ret);
154 153 }
155 154
156 155 extern __GNU_INLINE double
157 156 __inline_sqrt(double d)
158 157 {
159 158 double ret;
160 159
161 160 __asm__ __volatile__("fsqrtd %1,%0\n\t" : "=f" (ret) : "f" (d));
162 161 return (ret);
163 162 }
164 163
165 164 extern __GNU_INLINE int
166 165 __swapEX(int i)
167 166 {
168 167 int ret;
169 168 uint32_t fsr;
170 169 uint64_t tmp1, tmp2;
171 170
172 171 __asm__ __volatile__(
173 172 "and %4,0x1f,%2\n\t"
174 173 "sll %2,5,%2\n\t" /* shift input to aexc bit location */
175 174 ".volatile\n\t"
176 175 "st %%fsr,%1\n\t"
177 176 "ld %1,%0\n\t" /* %0 = fsr */
178 177 "andn %0,0x3e0,%3\n\t"
179 178 "or %2,%3,%2\n\t" /* %2 = new fsr */
180 179 "st %2,%1\n\t"
181 180 "ld %1,%%fsr\n\t"
182 181 "srl %0,5,%0\n\t"
183 182 "and %0,0x1f,%0\n\t"
184 183 ".nonvolatile\n\t"
185 184 : "=r" (ret), "=m" (fsr), "=r" (tmp1), "=r" (tmp2)
186 185 : "r" (i)
187 186 : "cc");
188 187
189 188 return (ret);
190 189 }
191 190
192 191 /*
193 192 * On the SPARC, __swapRP is a no-op; always return 0 for backward
194 193 * compatibility
195 194 */
196 195 /* ARGSUSED */
197 196 extern __GNU_INLINE enum fp_precision_type
198 197 __swapRP(enum fp_precision_type i)
199 198 {
200 199 return (0);
201 200 }
202 201
203 202 extern __GNU_INLINE enum fp_direction_type
204 203 __swapRD(enum fp_direction_type d)
205 204 {
206 205 enum fp_direction_type ret;
207 206 uint32_t fsr;
208 207 uint64_t tmp1, tmp2, tmp3;
209 208
210 209 __asm__ __volatile__(
211 210 "and %5,0x3,%0\n\t"
212 211 "sll %0,30,%2\n\t" /* shift input to RD bit location */
213 212 ".volatile\n\t"
214 213 "st %%fsr,%1\n\t"
215 214 "ld %1,%0\n\t" /* %0 = fsr */
216 215 /* mask of rounding direction bits */
217 216 "sethi %%hi(0xc0000000),%4\n\t"
218 217 "andn %0,%4,%3\n\t"
219 218 "or %2,%3,%2\n\t" /* %2 = new fsr */
220 219 "st %2,%1\n\t"
221 220 "ld %1,%%fsr\n\t"
222 221 "srl %0,30,%0\n\t"
223 222 "and %0,0x3,%0\n\t"
224 223 ".nonvolatile\n\t"
225 224 : "=r" (ret), "=m" (fsr), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3)
226 225 : "r" (d)
227 226 : "cc");
228 227
229 228 return (ret);
230 229 }
231 230
232 231 extern __GNU_INLINE int
233 232 __swapTE(int i)
234 233 {
235 234 int ret;
236 235 uint32_t fsr;
237 236 uint64_t tmp1, tmp2, tmp3;
238 237
239 238 __asm__ __volatile__(
240 239 "and %5,0x1f,%0\n\t"
241 240 "sll %0,23,%2\n\t" /* shift input to TEM bit location */
242 241 ".volatile\n\t"
243 242 "st %%fsr,%1\n\t"
244 243 "ld %1,%0\n\t" /* %0 = fsr */
245 244 /* mask of TEM (Trap Enable Mode bits) */
246 245 "sethi %%hi(0x0f800000),%4\n\t"
247 246 "andn %0,%4,%3\n\t"
248 247 "or %2,%3,%2\n\t" /* %2 = new fsr */
249 248 "st %2,%1\n\t"
250 249 "ld %1,%%fsr\n\t"
251 250 "srl %0,23,%0\n\t"
252 251 "and %0,0x1f,%0\n\t"
253 252 ".nonvolatile\n\t"
254 253 : "=r" (ret), "=m" (fsr), "=r" (tmp1), "=r" (tmp2), "=r" (tmp3)
255 254 : "r" (i)
256 255 : "cc");
257 256
258 257 return (ret);
259 258 }
260 259
261 260
262 261 extern __GNU_INLINE double
263 262 sqrt(double d)
264 263 {
265 264 return (__inline_sqrt(d));
266 265 }
267 266
268 267 extern __GNU_INLINE float
269 268 sqrtf(float f)
270 269 {
271 270 return (__inline_sqrtf(f));
272 271 }
273 272
274 273 extern __GNU_INLINE double
275 274 fabs(double d)
276 275 {
277 276 double ret;
278 277
279 278 __asm__ __volatile__("fabsd %1,%0\n\t" : "=e" (ret) : "e" (d));
280 279 return (ret);
281 280 }
282 281
283 282 extern __GNU_INLINE float
284 283 fabsf(float f)
↓ open down ↓ |
237 lines elided |
↑ open up ↑ |
285 284 {
286 285 float ret;
287 286
288 287 __asm__ __volatile__("fabss %1,%0\n\t" : "=f" (ret) : "f" (f));
289 288 return (ret);
290 289 }
291 290
292 291 #ifdef __cplusplus
293 292 }
294 293 #endif
295 -
296 294 #endif /* __GNUC__ */
297 -
298 295 #endif /* _LIBM_INLINES_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX