Deleted Added
full compact
fenv.h (203441) fenv.h (226218)
1/*-
2 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/msun/i387/fenv.h 203441 2010-02-03 20:23:47Z kib $
26 * $FreeBSD: head/lib/msun/i387/fenv.h 226218 2011-10-10 15:43:09Z das $
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/cdefs.h>
33#include <sys/_types.h>
34
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/cdefs.h>
33#include <sys/_types.h>
34
35#ifndef __fenv_static
36#define __fenv_static static
37#endif
38
35/*
36 * To preserve binary compatibility with FreeBSD 5.3, we pack the
37 * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
38 */
39typedef struct {
40 __uint16_t __control;
41 __uint16_t __mxcsr_hi;
42 __uint16_t __status;

--- 62 unchanged lines hidden (view full) ---

105#define __fnclex() __asm __volatile("fnclex")
106#define __fnstenv(__env) __asm __volatile("fnstenv %0" : "=m" (*(__env)))
107#define __fnstcw(__cw) __asm __volatile("fnstcw %0" : "=m" (*(__cw)))
108#define __fnstsw(__sw) __asm __volatile("fnstsw %0" : "=am" (*(__sw)))
109#define __fwait() __asm __volatile("fwait")
110#define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
111#define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
112
39/*
40 * To preserve binary compatibility with FreeBSD 5.3, we pack the
41 * mxcsr into some reserved fields, rather than changing sizeof(fenv_t).
42 */
43typedef struct {
44 __uint16_t __control;
45 __uint16_t __mxcsr_hi;
46 __uint16_t __status;

--- 62 unchanged lines hidden (view full) ---

109#define __fnclex() __asm __volatile("fnclex")
110#define __fnstenv(__env) __asm __volatile("fnstenv %0" : "=m" (*(__env)))
111#define __fnstcw(__cw) __asm __volatile("fnstcw %0" : "=m" (*(__cw)))
112#define __fnstsw(__sw) __asm __volatile("fnstsw %0" : "=am" (*(__sw)))
113#define __fwait() __asm __volatile("fwait")
114#define __ldmxcsr(__csr) __asm __volatile("ldmxcsr %0" : : "m" (__csr))
115#define __stmxcsr(__csr) __asm __volatile("stmxcsr %0" : "=m" (*(__csr)))
116
113static __inline int
117__fenv_static inline int
114feclearexcept(int __excepts)
115{
116 fenv_t __env;
117 __uint32_t __mxcsr;
118
119 if (__excepts == FE_ALL_EXCEPT) {
120 __fnclex();
121 } else {

--- 4 unchanged lines hidden (view full) ---

126 if (__HAS_SSE()) {
127 __stmxcsr(&__mxcsr);
128 __mxcsr &= ~__excepts;
129 __ldmxcsr(__mxcsr);
130 }
131 return (0);
132}
133
118feclearexcept(int __excepts)
119{
120 fenv_t __env;
121 __uint32_t __mxcsr;
122
123 if (__excepts == FE_ALL_EXCEPT) {
124 __fnclex();
125 } else {

--- 4 unchanged lines hidden (view full) ---

130 if (__HAS_SSE()) {
131 __stmxcsr(&__mxcsr);
132 __mxcsr &= ~__excepts;
133 __ldmxcsr(__mxcsr);
134 }
135 return (0);
136}
137
134static __inline int
138__fenv_static inline int
135fegetexceptflag(fexcept_t *__flagp, int __excepts)
136{
137 __uint32_t __mxcsr;
138 __uint16_t __status;
139
140 __fnstsw(&__status);
141 if (__HAS_SSE())
142 __stmxcsr(&__mxcsr);
143 else
144 __mxcsr = 0;
145 *__flagp = (__mxcsr | __status) & __excepts;
146 return (0);
147}
148
149int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
150int feraiseexcept(int __excepts);
151
139fegetexceptflag(fexcept_t *__flagp, int __excepts)
140{
141 __uint32_t __mxcsr;
142 __uint16_t __status;
143
144 __fnstsw(&__status);
145 if (__HAS_SSE())
146 __stmxcsr(&__mxcsr);
147 else
148 __mxcsr = 0;
149 *__flagp = (__mxcsr | __status) & __excepts;
150 return (0);
151}
152
153int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
154int feraiseexcept(int __excepts);
155
152static __inline int
156__fenv_static inline int
153fetestexcept(int __excepts)
154{
155 __uint32_t __mxcsr;
156 __uint16_t __status;
157
158 __fnstsw(&__status);
159 if (__HAS_SSE())
160 __stmxcsr(&__mxcsr);
161 else
162 __mxcsr = 0;
163 return ((__status | __mxcsr) & __excepts);
164}
165
157fetestexcept(int __excepts)
158{
159 __uint32_t __mxcsr;
160 __uint16_t __status;
161
162 __fnstsw(&__status);
163 if (__HAS_SSE())
164 __stmxcsr(&__mxcsr);
165 else
166 __mxcsr = 0;
167 return ((__status | __mxcsr) & __excepts);
168}
169
166static __inline int
170__fenv_static inline int
167fegetround(void)
168{
169 __uint16_t __control;
170
171 /*
172 * We assume that the x87 and the SSE unit agree on the
173 * rounding mode. Reading the control word on the x87 turns
174 * out to be about 5 times faster than reading it on the SSE
175 * unit on an Opteron 244.
176 */
177 __fnstcw(&__control);
178 return (__control & _ROUND_MASK);
179}
180
171fegetround(void)
172{
173 __uint16_t __control;
174
175 /*
176 * We assume that the x87 and the SSE unit agree on the
177 * rounding mode. Reading the control word on the x87 turns
178 * out to be about 5 times faster than reading it on the SSE
179 * unit on an Opteron 244.
180 */
181 __fnstcw(&__control);
182 return (__control & _ROUND_MASK);
183}
184
181static __inline int
185__fenv_static inline int
182fesetround(int __round)
183{
184 __uint32_t __mxcsr;
185 __uint16_t __control;
186
187 if (__round & ~_ROUND_MASK)
188 return (-1);
189

--- 10 unchanged lines hidden (view full) ---

200 }
201
202 return (0);
203}
204
205int fegetenv(fenv_t *__envp);
206int feholdexcept(fenv_t *__envp);
207
186fesetround(int __round)
187{
188 __uint32_t __mxcsr;
189 __uint16_t __control;
190
191 if (__round & ~_ROUND_MASK)
192 return (-1);
193

--- 10 unchanged lines hidden (view full) ---

204 }
205
206 return (0);
207}
208
209int fegetenv(fenv_t *__envp);
210int feholdexcept(fenv_t *__envp);
211
208static __inline int
212__fenv_static inline int
209fesetenv(const fenv_t *__envp)
210{
211 fenv_t __env = *__envp;
212 __uint32_t __mxcsr;
213
214 __mxcsr = __get_mxcsr(__env);
215 __set_mxcsr(__env, 0xffffffff);
216 /*

--- 12 unchanged lines hidden (view full) ---

229
230int feupdateenv(const fenv_t *__envp);
231
232#if __BSD_VISIBLE
233
234int feenableexcept(int __mask);
235int fedisableexcept(int __mask);
236
213fesetenv(const fenv_t *__envp)
214{
215 fenv_t __env = *__envp;
216 __uint32_t __mxcsr;
217
218 __mxcsr = __get_mxcsr(__env);
219 __set_mxcsr(__env, 0xffffffff);
220 /*

--- 12 unchanged lines hidden (view full) ---

233
234int feupdateenv(const fenv_t *__envp);
235
236#if __BSD_VISIBLE
237
238int feenableexcept(int __mask);
239int fedisableexcept(int __mask);
240
237static __inline int
241/* We currently provide no external definition of fegetexcept(). */
242static inline int
238fegetexcept(void)
239{
240 __uint16_t __control;
241
242 /*
243 * We assume that the masks for the x87 and the SSE unit are
244 * the same.
245 */
246 __fnstcw(&__control);
247 return (~__control & FE_ALL_EXCEPT);
248}
249
250#endif /* __BSD_VISIBLE */
251
252__END_DECLS
253
254#endif /* !_FENV_H_ */
243fegetexcept(void)
244{
245 __uint16_t __control;
246
247 /*
248 * We assume that the masks for the x87 and the SSE unit are
249 * the same.
250 */
251 __fnstcw(&__control);
252 return (~__control & FE_ALL_EXCEPT);
253}
254
255#endif /* __BSD_VISIBLE */
256
257__END_DECLS
258
259#endif /* !_FENV_H_ */