Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/amd64/src/libm_inlines.h
+++ new/usr/src/lib/libm/amd64/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 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
↓ open down ↓ |
29 lines elided |
↑ open up ↑ |
30 30 /*
31 31 * Copyright 2011, Richard Lowe.
32 32 */
33 33
34 34 /* Functions in this file are duplicated in locallibm.il. Keep them in sync */
35 35
36 36 #ifndef _LIBM_INLINES_H
37 37 #define _LIBM_INLINES_H
38 38
39 39 #ifdef __GNUC__
40 -
41 40 #ifdef __cplusplus
42 41 extern "C" {
43 42 #endif
44 43
45 44 #include <sys/types.h>
46 45 #include <sys/ieeefp.h>
47 46
48 47 extern __GNU_INLINE float
49 48 __inline_sqrtf(float a)
50 49 {
51 50 float ret;
52 51
53 52 __asm__ __volatile__("sqrtss %1, %0\n\t" : "=x" (ret) : "x" (a));
54 53 return (ret);
55 54 }
56 55
57 56 extern __GNU_INLINE double
58 57 __inline_sqrt(double a)
59 58 {
60 59 double ret;
61 60
62 61 __asm__ __volatile__("sqrtsd %1, %0\n\t" : "=x" (ret) : "x" (a));
63 62 return (ret);
64 63 }
65 64
66 65 extern __GNU_INLINE double
67 66 __ieee754_sqrt(double a)
68 67 {
69 68 return (__inline_sqrt(a));
70 69 }
71 70
72 71 /*
73 72 * 00 - 24 bits
74 73 * 01 - reserved
75 74 * 10 - 53 bits
76 75 * 11 - 64 bits
77 76 */
78 77 extern __GNU_INLINE int
79 78 __swapRP(int i)
80 79 {
81 80 int ret;
82 81 uint16_t cw;
83 82
84 83 __asm__ __volatile__("fstcw %0\n\t" : "=m" (cw));
85 84
86 85 ret = (cw >> 8) & 0x3;
87 86 cw = (cw & 0xfcff) | ((i & 0x3) << 8);
88 87
89 88 __asm__ __volatile__("fldcw %0\n\t" : : "m" (cw));
90 89
91 90 return (ret);
92 91 }
93 92
94 93 /*
95 94 * 00 - Round to nearest, with even preferred
96 95 * 01 - Round down
97 96 * 10 - Round up
98 97 * 11 - Chop
99 98 */
100 99 extern __GNU_INLINE enum fp_direction_type
101 100 __swap87RD(enum fp_direction_type i)
102 101 {
103 102 int ret;
104 103 uint16_t cw;
105 104
106 105 __asm__ __volatile__("fstcw %0\n\t" : "=m" (cw));
107 106
108 107 ret = (cw >> 10) & 0x3;
109 108 cw = (cw & 0xf3ff) | ((i & 0x3) << 10);
110 109
111 110 __asm__ __volatile__("fldcw %0\n\t" : : "m" (cw));
112 111
113 112 return (ret);
114 113 }
115 114
116 115 extern __GNU_INLINE int
117 116 abs(int i)
118 117 {
119 118 int ret;
120 119 __asm__ __volatile__(
121 120 "movl %1, %0\n\t"
122 121 "negl %1\n\t"
123 122 "cmovnsl %1, %0\n\t"
124 123 : "=r" (ret), "+r" (i)
125 124 :
126 125 : "cc");
127 126 return (ret);
128 127 }
129 128
130 129 extern __GNU_INLINE double
131 130 copysign(double d1, double d2)
132 131 {
133 132 double tmpd;
134 133
135 134 __asm__ __volatile__(
136 135 "movd %3, %1\n\t"
137 136 "andpd %1, %0\n\t"
138 137 "andnpd %2, %1\n\t"
139 138 "orpd %1, %0\n\t"
140 139 : "+&x" (d1), "=&x" (tmpd)
141 140 : "x" (d2), "r" (0x7fffffffffffffff));
142 141
143 142 return (d1);
144 143 }
145 144
146 145 extern __GNU_INLINE double
147 146 fabs(double d)
148 147 {
149 148 double tmp;
150 149
151 150 __asm__ __volatile__(
152 151 "movd %2, %1\n\t"
153 152 "andpd %1, %0"
154 153 : "+x" (d), "=&x" (tmp)
155 154 : "r" (0x7fffffffffffffff));
156 155
157 156 return (d);
158 157 }
159 158
160 159 extern __GNU_INLINE float
161 160 fabsf(float d)
162 161 {
163 162 __asm__ __volatile__(
164 163 "andpd %1, %0"
165 164 : "+x" (d)
166 165 : "x" (0x7fffffff));
167 166
168 167 return (d);
169 168 }
170 169
171 170 extern __GNU_INLINE int
172 171 finite(double d)
173 172 {
174 173 long ret = 0x7fffffffffffffff;
175 174 uint64_t tmp;
176 175
177 176 __asm__ __volatile__(
178 177 "movq %2, %1\n\t"
179 178 "andq %1, %0\n\t"
180 179 "movq $0x7ff0000000000000, %1\n\t"
181 180 "subq %1, %0\n\t"
182 181 "shrq $63, %0\n\t"
183 182 : "+r" (ret), "=r" (tmp)
184 183 : "x" (d)
185 184 : "cc");
186 185
187 186 return (ret);
188 187 }
189 188
190 189 extern __GNU_INLINE int
191 190 signbit(double d)
192 191 {
193 192 long ret;
194 193 __asm__ __volatile__(
195 194 "movmskpd %1, %0\n\t"
196 195 "andq $1, %0\n\t"
197 196 : "=r" (ret)
198 197 : "x" (d)
199 198 : "cc");
200 199 return (ret);
201 200 }
202 201
203 202 extern __GNU_INLINE double
204 203 sqrt(double d)
205 204 {
206 205 return (__inline_sqrt(d));
207 206 }
↓ open down ↓ |
157 lines elided |
↑ open up ↑ |
208 207
209 208 extern __GNU_INLINE float
210 209 sqrtf(float f)
211 210 {
212 211 return (__inline_sqrtf(f));
213 212 }
214 213
215 214 #ifdef __cplusplus
216 215 }
217 216 #endif
218 -
219 217 #endif /* __GNUC__ */
220 -
221 218 #endif /* _LIBM_INLINES_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX