--- mstools/h/float.h 2018/08/09 18:20:01 1.1 +++ mstools/h/float.h 2018/08/09 18:23:05 1.1.1.4 @@ -1,7 +1,7 @@ /*** *float.h - constants for floating point values * -* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved. +* Copyright (c) 1985-1993, Microsoft Corporation. All rights reserved. * *Purpose: * This file contains defines for a number of implementation dependent @@ -18,10 +18,29 @@ extern "C" { #endif -#if (_MSC_VER <= 600) -#define __cdecl _cdecl +/* + * Conditional macro definition for function calling type and variable type + * qualifiers. + */ +#if ( (_MSC_VER >= 800) && (_M_IX86 >= 300) ) + +/* + * Definitions for MS C8-32 (386/486) compiler + */ +#define _CRTAPI1 __cdecl +#define _CRTAPI2 __cdecl + +#else + +/* + * Other compilers (e.g., MIPS) + */ +#define _CRTAPI1 +#define _CRTAPI2 + #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 */ #define DBL_MANT_DIG 53 /* # of bits in mantissa */ @@ -62,71 +81,106 @@ extern "C" { + +/* function prototypes */ + +unsigned int _CRTAPI1 _clearfp(void); +unsigned int _CRTAPI1 _controlfp(unsigned int,unsigned int); +unsigned int _CRTAPI1 _statusfp(void); +void _CRTAPI1 _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 _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 */ -#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 */ +/* + * i386 specific definitions + */ -#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 _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 */ -/* initial Control Word value */ +#define _EM_DENORMAL 0x00080000 /* denormal exception mask (_control87 only) */ -#define _CW_DEFAULT ( _IC_AFFINE + _RC_NEAR + _PC_64 + _EM_DENORMAL + _EM_UNDERFLOW + _EM_INEXACT ) +#define _SW_DENORMAL 0x00080000 /* denormal status bit */ -/* user Status Word bit definitions */ +unsigned int _CRTAPI1 _control87(unsigned int,unsigned int); -#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) */ +/* + * MIPS R4000 specific definitions + */ -/* invalid subconditions (_SW_INVALID also set) */ +#define _MCW_DN 0x01000000 /* Denormal Control (R4000) */ +#define _DN_FLUSH 0x01000000 /* flush to zero */ +#define _DN_SAVE 0x00000000 /* save */ -#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 */ +/* initial Control Word value */ + +#ifdef _M_IX86 + +#define _CW_DEFAULT ( _RC_NEAR + _PC_64 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT ) + +#elif defined(_M_MRX000) || defined(_MIPS_) + +#define _CW_DEFAULT ( _RC_NEAR + _DN_FLUSH + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT ) + +#elif defined (_ALPHA_) + +#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 -extern int * __fpecode(void); +extern int * _CRTAPI1 __fpecode(void); #define _fpecode (*__fpecode()) #else 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 +199,37 @@ extern int _fpecode; #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ -/* function prototypes */ +/* IEEE recommended functions */ + +double _CRTAPI1 _copysign (double, double); +double _CRTAPI1 _chgsign (double); +double _CRTAPI1 _scalb(double, long); +double _CRTAPI1 _logb(double); +double _CRTAPI1 _nextafter(double, double); +int _CRTAPI1 _finite(double); +int _CRTAPI1 _isnan(double); +int _CRTAPI1 _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 +287,8 @@ unsigned int _status87(void); #define FPE_EXPLICITGEN _FPE_EXPLICITGEN -#endif /* __STDC__ */ +#endif /* __STDC__ */ #ifdef __cplusplus }