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