--- mstools/h/float.h 2018/08/09 18:20:01 1.1.1.1 +++ mstools/h/float.h 2018/08/09 18:20:31 1.1.1.2 @@ -18,9 +18,11 @@ extern "C" { #endif +#ifndef MIPS #if (_MSC_VER <= 600) #define __cdecl _cdecl #endif +#endif #define DBL_DIG 15 /* # of decimal digits of precision */ #define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */ @@ -62,62 +64,89 @@ extern "C" { + +/* function prototypes */ + +unsigned int _clearfp(void); +unsigned int _controlfp(unsigned int,unsigned int); +unsigned int _statusfp(void); +void _fpreset(void); + +#define _clear87 _clearfp +#define _status87 _statusfp + /* - * 8087/80287 math control information + * Abstract User Control Word Mask and bit definitions */ +#define _MCW_EM 0x0008001f /* interrupt Exception Masks */ +#define _EM_INEXACT 0x00000001 /* inexact (precision) */ +#define _EM_UNDERFLOW 0x00000002 /* underflow */ +#define _EM_OVERFLOW 0x00000004 /* overflow */ +#define _EM_ZERODIVIDE 0x00000008 /* zero divide */ +#define _EM_INVALID 0x00000010 /* invalid */ + +#define _MCW_RC 0x00000300 /* Rounding Control */ +#define _RC_NEAR 0x00000000 /* near */ +#define _RC_DOWN 0x00000100 /* down */ +#define _RC_UP 0x00000200 /* up */ +#define _RC_CHOP 0x00000300 /* chop */ -/* User Control Word Mask and bit definitions. - * These definitions match the 8087/80287 +/* + * Abstract User Status Word bit definitions */ -#define _MCW_EM 0x003f /* interrupt Exception Masks */ -#define _EM_INVALID 0x0001 /* invalid */ -#define _EM_DENORMAL 0x0002 /* denormal */ -#define _EM_ZERODIVIDE 0x0004 /* zero divide */ -#define _EM_OVERFLOW 0x0008 /* overflow */ -#define _EM_UNDERFLOW 0x0010 /* underflow */ -#define _EM_INEXACT 0x0020 /* inexact (precision) */ - -#define _MCW_IC 0x1000 /* Infinity Control */ -#define _IC_AFFINE 0x1000 /* affine */ -#define _IC_PROJECTIVE 0x0000 /* projective */ - -#define _MCW_RC 0x0c00 /* Rounding Control */ -#define _RC_CHOP 0x0c00 /* chop */ -#define _RC_UP 0x0800 /* up */ -#define _RC_DOWN 0x0400 /* down */ -#define _RC_NEAR 0x0000 /* near */ - -#define _MCW_PC 0x0300 /* Precision Control */ -#define _PC_24 0x0000 /* 24 bits */ -#define _PC_53 0x0200 /* 53 bits */ -#define _PC_64 0x0300 /* 64 bits */ +#define _SW_INEXACT 0x00000001 /* inexact (precision) */ +#define _SW_UNDERFLOW 0x00000002 /* underflow */ +#define _SW_OVERFLOW 0x00000004 /* overflow */ +#define _SW_ZERODIVIDE 0x00000008 /* zero divide */ +#define _SW_INVALID 0x00000010 /* invalid */ -/* initial Control Word value */ +/* + * i386 specific definitions + */ -#define _CW_DEFAULT ( _IC_AFFINE + _RC_NEAR + _PC_64 + _EM_DENORMAL + _EM_UNDERFLOW + _EM_INEXACT ) +#define _MCW_PC 0x00030000 /* Precision Control */ +#define _PC_64 0x00000000 /* 64 bits */ +#define _PC_53 0x00010000 /* 53 bits */ +#define _PC_24 0x00020000 /* 24 bits */ + +#define _MCW_IC 0x00040000 /* Infinity Control */ +#define _IC_AFFINE 0x00040000 /* affine */ +#define _IC_PROJECTIVE 0x00000000 /* projective */ +#define _EM_DENORMAL 0x00080000 /* denormal exception mask (_control87 only) */ -/* user Status Word bit definitions */ +#define _SW_DENORMAL 0x00080000 /* denormal status bit */ -#define _SW_INVALID 0x0001 /* invalid */ -#define _SW_DENORMAL 0x0002 /* denormal */ -#define _SW_ZERODIVIDE 0x0004 /* zero divide */ -#define _SW_OVERFLOW 0x0008 /* overflow */ -#define _SW_UNDERFLOW 0x0010 /* underflow */ -#define _SW_INEXACT 0x0020 /* inexact (precision) */ +unsigned int _control87(unsigned int,unsigned int); -/* invalid subconditions (_SW_INVALID also set) */ -#define _SW_UNEMULATED 0x0040 /* unemulated instruction */ -#define _SW_SQRTNEG 0x0080 /* square root of a neg number */ -#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ -#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ +/* + * MIPS R4000 specific definitions + */ + +#define _MCW_DN 0x01000000 /* Denormal Control (R4000) */ +#define _DN_FLUSH 0x01000000 /* flush to zero */ +#define _DN_SAVE 0x00000000 /* save */ +/* initial Control Word value */ + +#ifdef i386 + +#define _CW_DEFAULT ( _RC_NEAR + _PC_64 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT ) + +#endif + +#ifdef MIPS + +#define _CW_DEFAULT ( _RC_NEAR + _DN_FLUSH + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT ) + +#endif + /* Global variable holding floating point error code */ #ifdef _MT @@ -127,6 +156,12 @@ extern int * __fpecode(void); extern int _fpecode; #endif +/* invalid subconditions (_SW_INVALID also set) */ + +#define _SW_UNEMULATED 0x0040 /* unemulated instruction */ +#define _SW_SQRTNEG 0x0080 /* square root of a neg number */ +#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ +#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ /* Floating point error signals and return codes */ @@ -145,16 +180,37 @@ extern int _fpecode; #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ -/* function prototypes */ +/* IEEE recommended functions */ + +double _copysign (double, double); +double _chgsign (double); +double _scalb(double, long); +double _logb(double); +double _nextafter(double, double); +int _finite(double); +int _isnan(double); +int _fpclass(double); + +#define _FPCLASS_SNAN 0x0001 /* signaling NaN */ +#define _FPCLASS_QNAN 0x0002 /* quiet NaN */ +#define _FPCLASS_NINF 0x0004 /* negative infinity */ +#define _FPCLASS_NN 0x0008 /* negative normal */ +#define _FPCLASS_ND 0x0010 /* negative denormal */ +#define _FPCLASS_NZ 0x0020 /* -0 */ +#define _FPCLASS_PZ 0x0040 /* +0 */ +#define _FPCLASS_PD 0x0080 /* positive denormal */ +#define _FPCLASS_PN 0x0100 /* positive normal */ +#define _FPCLASS_PINF 0x0200 /* positive infinity */ -unsigned int _clear87(void); -unsigned int _control87(unsigned int,unsigned int); -void _fpreset(void); -unsigned int _status87(void); #if !__STDC__ /* Non-ANSI names for compatibility */ +#define clear87 _clear87 +#define status87 _status87 +#define control87 _control87 +#define fpreset _fpreset + #define DBL_RADIX _DBL_RADIX #define DBL_ROUNDS _DBL_ROUNDS @@ -212,8 +268,8 @@ unsigned int _status87(void); #define FPE_EXPLICITGEN _FPE_EXPLICITGEN -#endif /* __STDC__ */ +#endif /* __STDC__ */ #ifdef __cplusplus }