Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/include/x86_ieeefp.h
- This file was copied from sys/i386/include/ieeefp.h.
Show All 31 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 | * from: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93 | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _MACHINE_IEEEFP_H_ | #ifndef _X86_X86_IEEEFP_H_ | ||||
#define _MACHINE_IEEEFP_H_ | #define _X86_X86_IEEEFP_H_ | ||||
/* Deprecated historical FPU control interface */ | |||||
/* | /* | ||||
* Deprecated historical FPU control interface | |||||
* | |||||
* IEEE floating point type, constant and function definitions. | * IEEE floating point type, constant and function definitions. | ||||
* XXX: FP*FLD and FP*OFF are undocumented pollution. | * XXX: {FP,SSE}*FLD and {FP,SSE}*OFF are undocumented pollution. | ||||
*/ | */ | ||||
#ifndef _SYS_CDEFS_H_ | #ifndef _SYS_CDEFS_H_ | ||||
#error this file needs sys/cdefs.h as a prerequisite | #error this file needs sys/cdefs.h as a prerequisite | ||||
#endif | #endif | ||||
/* | /* | ||||
* Rounding modes. | * Rounding modes. | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | if (((_sw & ~_cw) & FP_STKY_FLD) != 0) { | ||||
_env._cw = _newcw; | _env._cw = _newcw; | ||||
__fldenv(&_env); | __fldenv(&_env); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
__fldcw(&_newcw); | __fldcw(&_newcw); | ||||
} | } | ||||
static __inline fp_rnd_t | |||||
fpgetround(void) | |||||
{ | |||||
unsigned short _cw; | |||||
__fnstcw(&_cw); | |||||
return ((fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF)); | |||||
} | |||||
static __inline fp_rnd_t | |||||
fpsetround(fp_rnd_t _m) | |||||
{ | |||||
fp_rnd_t _p; | |||||
unsigned short _cw, _newcw; | |||||
__fnstcw(&_cw); | |||||
_p = (fp_rnd_t)((_cw & FP_RND_FLD) >> FP_RND_OFF); | |||||
_newcw = _cw & ~FP_RND_FLD; | |||||
_newcw |= (_m << FP_RND_OFF) & FP_RND_FLD; | |||||
__fnldcw(_cw, _newcw); | |||||
return (_p); | |||||
} | |||||
static __inline fp_prec_t | |||||
fpgetprec(void) | |||||
{ | |||||
unsigned short _cw; | |||||
__fnstcw(&_cw); | |||||
return ((fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF)); | |||||
} | |||||
static __inline fp_prec_t | |||||
fpsetprec(fp_prec_t _m) | |||||
{ | |||||
fp_prec_t _p; | |||||
unsigned short _cw, _newcw; | |||||
__fnstcw(&_cw); | |||||
_p = (fp_prec_t)((_cw & FP_PRC_FLD) >> FP_PRC_OFF); | |||||
_newcw = _cw & ~FP_PRC_FLD; | |||||
_newcw |= (_m << FP_PRC_OFF) & FP_PRC_FLD; | |||||
__fnldcw(_cw, _newcw); | |||||
return (_p); | |||||
} | |||||
/* | |||||
* Get or set the exception mask. | |||||
* Note that the x87 mask bits are inverted by the API -- a mask bit of 1 | |||||
* means disable for x87 and SSE, but for fp*mask() it means enable. | |||||
*/ | |||||
static __inline fp_except_t | |||||
fpgetmask(void) | |||||
{ | |||||
unsigned short _cw; | |||||
__fnstcw(&_cw); | |||||
return ((~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF); | |||||
} | |||||
static __inline fp_except_t | |||||
fpsetmask(fp_except_t _m) | |||||
{ | |||||
fp_except_t _p; | |||||
unsigned short _cw, _newcw; | |||||
__fnstcw(&_cw); | |||||
_p = (~_cw & FP_MSKS_FLD) >> FP_MSKS_OFF; | |||||
_newcw = _cw & ~FP_MSKS_FLD; | |||||
_newcw |= (~_m << FP_MSKS_OFF) & FP_MSKS_FLD; | |||||
__fnldcw(_cw, _newcw); | |||||
return (_p); | |||||
} | |||||
static __inline fp_except_t | |||||
fpgetsticky(void) | |||||
{ | |||||
unsigned _ex; | |||||
unsigned short _sw; | |||||
__fnstsw(&_sw); | |||||
_ex = (_sw & FP_STKY_FLD) >> FP_STKY_OFF; | |||||
return ((fp_except_t)_ex); | |||||
} | |||||
static __inline fp_except_t | |||||
fpresetsticky(fp_except_t _m) | |||||
{ | |||||
struct { | |||||
unsigned _cw; | |||||
unsigned _sw; | |||||
unsigned _other[5]; | |||||
} _env; | |||||
fp_except_t _p; | |||||
_m &= FP_STKY_FLD >> FP_STKY_OFF; | |||||
_p = fpgetsticky(); | |||||
if ((_p & ~_m) == _p) | |||||
return (_p); | |||||
if ((_p & ~_m) == 0) { | |||||
__fnclex(); | |||||
return (_p); | |||||
} | |||||
__fnstenv(&_env); | |||||
_env._sw &= ~_m; | |||||
__fldenv(&_env); | |||||
return (_p); | |||||
} | |||||
#endif /* __GNUCLIKE_ASM */ | #endif /* __GNUCLIKE_ASM */ | ||||
#endif /* !_MACHINE_IEEEFP_H_ */ | #endif/* _X86_X86_IEEEFP_H_ */ |