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/arm/fenv.h 230192 2012-01-16 04:09:17Z das $
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/_types.h>
33
34#ifndef __fenv_static
--- 24 unchanged lines hidden (view full) ---
59/* Default floating-point environment */
60extern const fenv_t __fe_dfl_env;
61#define FE_DFL_ENV (&__fe_dfl_env)
62
63/* We need to be able to map status flag positions to mask flag positions */
64#define _FPUSW_SHIFT 16
65#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
66
67#ifndef ARM_HARD_FLOAT
68/*
69 * The following macros map between the softfloat emulator's flags and
70 * the hardware's FPSR. The hardware this file was written for doesn't
71 * have rounding control bits, so we stick those in the system ID byte.
72 */
73#define __set_env(env, flags, mask, rnd) env = ((flags) \
74 | (mask)<<_FPUSW_SHIFT \
75 | (rnd) << 24)
76#define __env_flags(env) ((env) & FE_ALL_EXCEPT)
77#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \
78 & FE_ALL_EXCEPT)
79#define __env_round(env) (((env) >> 24) & _ROUND_MASK)
80#include <fenv-softfloat.h>
81
82#else /* ARM_HARD_FLOAT */
83
84#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr)))
85#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr))
86
87__fenv_static inline int
88feclearexcept(int __excepts)
89{
90 fexcept_t __fpsr;
91
92 __rfs(&__fpsr);
93 __fpsr &= ~__excepts;
--- 131 unchanged lines hidden (view full) ---
225 fenv_t __fpsr;
226
227 __rfs(&__fpsr);
228 return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
229}
230
231#endif /* __BSD_VISIBLE */
232
233#endif /* ARM_HARD_FLOAT */
234
235__END_DECLS
236
237#endif /* !_FENV_H_ */
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/arm/fenv.h 230192 2012-01-16 04:09:17Z das $
27 */
28
29#ifndef _FENV_H_
30#define _FENV_H_
31
32#include <sys/_types.h>
33
34#ifndef __fenv_static
--- 24 unchanged lines hidden (view full) ---
59/* Default floating-point environment */
60extern const fenv_t __fe_dfl_env;
61#define FE_DFL_ENV (&__fe_dfl_env)
62
63/* We need to be able to map status flag positions to mask flag positions */
64#define _FPUSW_SHIFT 16
65#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
66
67#ifndef ARM_HARD_FLOAT
68/*
69 * The following macros map between the softfloat emulator's flags and
70 * the hardware's FPSR. The hardware this file was written for doesn't
71 * have rounding control bits, so we stick those in the system ID byte.
72 */
73#define __set_env(env, flags, mask, rnd) env = ((flags) \
74 | (mask)<<_FPUSW_SHIFT \
75 | (rnd) << 24)
76#define __env_flags(env) ((env) & FE_ALL_EXCEPT)
77#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \
78 & FE_ALL_EXCEPT)
79#define __env_round(env) (((env) >> 24) & _ROUND_MASK)
80#include <fenv-softfloat.h>
81
82#else /* ARM_HARD_FLOAT */
83
84#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr)))
85#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr))
86
87__fenv_static inline int
88feclearexcept(int __excepts)
89{
90 fexcept_t __fpsr;
91
92 __rfs(&__fpsr);
93 __fpsr &= ~__excepts;
--- 131 unchanged lines hidden (view full) ---
225 fenv_t __fpsr;
226
227 __rfs(&__fpsr);
228 return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
229}
230
231#endif /* __BSD_VISIBLE */
232
233#endif /* ARM_HARD_FLOAT */
234
235__END_DECLS
236
237#endif /* !_FENV_H_ */