[1046] | 1 | #ifndef _MINGW_FLOAT_H_
|
---|
| 2 | /*
|
---|
| 3 | * float.h
|
---|
| 4 | *
|
---|
| 5 | * This file has no copyright assigned and is placed in the Public Domain.
|
---|
| 6 | * This file is a part of the mingw-runtime package.
|
---|
| 7 | * No warranty is given; refer to the file DISCLAIMER within the package.
|
---|
| 8 | *
|
---|
| 9 | * Constants related to floating point arithmetic.
|
---|
| 10 | *
|
---|
| 11 | * Also included here are some non-ANSI bits for accessing the floating
|
---|
| 12 | * point controller.
|
---|
| 13 | *
|
---|
| 14 | */
|
---|
| 15 | #define _MINGW_FLOAT_H_
|
---|
| 16 | /*
|
---|
| 17 | * NOTE:
|
---|
| 18 | *
|
---|
| 19 | * GCC provides float.h, but it doesn't include the non-standard stuff for
|
---|
| 20 | * accessing the fp controller. We parse the GCC-supplied header, for its
|
---|
| 21 | * standard content, and then define the MS-specific extensions here.
|
---|
| 22 | *
|
---|
| 23 | * In a MinGW standard Win32 hosted environment, this should be the float.h
|
---|
| 24 | * found by a system include path search, but this can't be guaranteed; for
|
---|
| 25 | * a cross-compiler setup, the GCC-supplied header, which is guarded by the
|
---|
| 26 | * _FLOAT_H___ macro, may be found first, thus...
|
---|
| 27 | *
|
---|
| 28 | */
|
---|
| 29 | #if !defined(_FLOAT_H___) && !defined(__FLOAT_H)
|
---|
| 30 |
|
---|
| 31 | /*
|
---|
| 32 | * ...when we didn't find the GCC-supplied header first, we want to pull
|
---|
| 33 | * it in now; include_next should achieve this, (and we must rely on the
|
---|
| 34 | * GCC header maintainers to extend us the same courtesy, to get this one
|
---|
| 35 | * pulled in, when the GCC-supplied header is found first).
|
---|
| 36 | *
|
---|
| 37 | */
|
---|
| 38 | # include_next <float.h>
|
---|
| 39 | #endif
|
---|
| 40 |
|
---|
| 41 | /* All the headers include this file. */
|
---|
| 42 | #include <_mingw.h>
|
---|
| 43 |
|
---|
| 44 | /*
|
---|
| 45 | * Functions and definitions for controlling the FPU.
|
---|
| 46 | */
|
---|
| 47 | #ifndef __STRICT_ANSI__
|
---|
| 48 |
|
---|
| 49 | /* TODO: These constants are only valid for x86 machines */
|
---|
| 50 |
|
---|
| 51 | /* Control word masks for unMask */
|
---|
| 52 | #define _MCW_EM 0x0008001F /* Error masks */
|
---|
| 53 | #define _MCW_IC 0x00040000 /* Infinity */
|
---|
| 54 | #define _MCW_RC 0x00000300 /* Rounding */
|
---|
| 55 | #define _MCW_PC 0x00030000 /* Precision */
|
---|
| 56 |
|
---|
| 57 | /* Control word values for unNew (use with related unMask above) */
|
---|
| 58 | #define _EM_INVALID 0x00000010
|
---|
| 59 | #define _EM_DENORMAL 0x00080000
|
---|
| 60 | #define _EM_ZERODIVIDE 0x00000008
|
---|
| 61 | #define _EM_OVERFLOW 0x00000004
|
---|
| 62 | #define _EM_UNDERFLOW 0x00000002
|
---|
| 63 | #define _EM_INEXACT 0x00000001
|
---|
| 64 | #define _IC_AFFINE 0x00040000
|
---|
| 65 | #define _IC_PROJECTIVE 0x00000000
|
---|
| 66 | #define _RC_CHOP 0x00000300
|
---|
| 67 | #define _RC_UP 0x00000200
|
---|
| 68 | #define _RC_DOWN 0x00000100
|
---|
| 69 | #define _RC_NEAR 0x00000000
|
---|
| 70 | #define _PC_24 0x00020000
|
---|
| 71 | #define _PC_53 0x00010000
|
---|
| 72 | #define _PC_64 0x00000000
|
---|
| 73 |
|
---|
| 74 | /* These are also defined in Mingw math.h, needed to work around
|
---|
| 75 | GCC build issues. */
|
---|
| 76 | /* Return values for fpclass. */
|
---|
| 77 | #ifndef __MINGW_FPCLASS_DEFINED
|
---|
| 78 | #define __MINGW_FPCLASS_DEFINED 1
|
---|
| 79 | #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
|
---|
| 80 | #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
|
---|
| 81 | #define _FPCLASS_NINF 0x0004 /* Negative Infinity */
|
---|
| 82 | #define _FPCLASS_NN 0x0008 /* Negative Normal */
|
---|
| 83 | #define _FPCLASS_ND 0x0010 /* Negative Denormal */
|
---|
| 84 | #define _FPCLASS_NZ 0x0020 /* Negative Zero */
|
---|
| 85 | #define _FPCLASS_PZ 0x0040 /* Positive Zero */
|
---|
| 86 | #define _FPCLASS_PD 0x0080 /* Positive Denormal */
|
---|
| 87 | #define _FPCLASS_PN 0x0100 /* Positive Normal */
|
---|
| 88 | #define _FPCLASS_PINF 0x0200 /* Positive Infinity */
|
---|
| 89 | #endif /* __MINGW_FPCLASS_DEFINED */
|
---|
| 90 |
|
---|
| 91 | /* invalid subconditions (_SW_INVALID also set) */
|
---|
| 92 | #define _SW_UNEMULATED 0x0040 /* unemulated instruction */
|
---|
| 93 | #define _SW_SQRTNEG 0x0080 /* square root of a neg number */
|
---|
| 94 | #define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
|
---|
| 95 | #define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
|
---|
| 96 |
|
---|
| 97 | /* Floating point error signals and return codes */
|
---|
| 98 | #define _FPE_INVALID 0x81
|
---|
| 99 | #define _FPE_DENORMAL 0x82
|
---|
| 100 | #define _FPE_ZERODIVIDE 0x83
|
---|
| 101 | #define _FPE_OVERFLOW 0x84
|
---|
| 102 | #define _FPE_UNDERFLOW 0x85
|
---|
| 103 | #define _FPE_INEXACT 0x86
|
---|
| 104 | #define _FPE_UNEMULATED 0x87
|
---|
| 105 | #define _FPE_SQRTNEG 0x88
|
---|
| 106 | #define _FPE_STACKOVERFLOW 0x8a
|
---|
| 107 | #define _FPE_STACKUNDERFLOW 0x8b
|
---|
| 108 | #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
|
---|
| 109 |
|
---|
| 110 | #ifndef RC_INVOKED
|
---|
| 111 |
|
---|
| 112 | #ifdef __cplusplus
|
---|
| 113 | extern "C" {
|
---|
| 114 | #endif
|
---|
| 115 |
|
---|
| 116 | /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
|
---|
| 117 | * i.e. change the bits in unMask to have the values they have in unNew,
|
---|
| 118 | * leaving other bits unchanged. */
|
---|
| 119 | _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _controlfp (unsigned int unNew, unsigned int unMask);
|
---|
| 120 | _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _control87 (unsigned int unNew, unsigned int unMask);
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _clearfp (void); /* Clear the FPU status word */
|
---|
| 124 | _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _statusfp (void); /* Report the FPU status word */
|
---|
| 125 | #define _clear87 _clearfp
|
---|
| 126 | #define _status87 _statusfp
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | /*
|
---|
| 130 | MSVCRT.dll _fpreset initializes the control register to 0x27f,
|
---|
| 131 | the status register to zero and the tag word to 0FFFFh.
|
---|
| 132 | This differs from asm instruction finit/fninit which set control
|
---|
| 133 | word to 0x37f (64 bit mantissa precison rather than 53 bit).
|
---|
| 134 | By default, the mingw version of _fpreset sets fp control as
|
---|
| 135 | per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
|
---|
| 136 | building your application.
|
---|
| 137 | */
|
---|
| 138 | void __cdecl __MINGW_NOTHROW _fpreset (void);
|
---|
| 139 | void __cdecl __MINGW_NOTHROW fpreset (void);
|
---|
| 140 |
|
---|
| 141 | /* Global 'variable' for the current floating point error code. */
|
---|
| 142 | _CRTIMP int * __cdecl __MINGW_NOTHROW __fpecode(void);
|
---|
| 143 | #define _fpecode (*(__fpecode()))
|
---|
| 144 |
|
---|
| 145 | /*
|
---|
| 146 | * IEEE recommended functions. MS puts them in float.h
|
---|
| 147 | * but they really belong in math.h.
|
---|
| 148 | */
|
---|
| 149 |
|
---|
| 150 | _CRTIMP double __cdecl __MINGW_NOTHROW _chgsign (double);
|
---|
| 151 | _CRTIMP double __cdecl __MINGW_NOTHROW _copysign (double, double);
|
---|
| 152 | _CRTIMP double __cdecl __MINGW_NOTHROW _logb (double);
|
---|
| 153 | _CRTIMP double __cdecl __MINGW_NOTHROW _nextafter (double, double);
|
---|
| 154 | _CRTIMP double __cdecl __MINGW_NOTHROW _scalb (double, long);
|
---|
| 155 |
|
---|
| 156 | _CRTIMP int __cdecl __MINGW_NOTHROW _finite (double);
|
---|
| 157 | _CRTIMP int __cdecl __MINGW_NOTHROW _fpclass (double);
|
---|
| 158 | _CRTIMP int __cdecl __MINGW_NOTHROW _isnan (double);
|
---|
| 159 |
|
---|
| 160 | #ifdef __cplusplus
|
---|
| 161 | }
|
---|
| 162 | #endif
|
---|
| 163 |
|
---|
| 164 | #endif /* Not RC_INVOKED */
|
---|
| 165 |
|
---|
| 166 | #endif /* Not __STRICT_ANSI__ */
|
---|
| 167 |
|
---|
| 168 | #endif /* _MINGW_FLOAT_H_ */
|
---|
| 169 |
|
---|