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