[CLASSPNP] Fix MSVC build. Brought to you by Timo.
[reactos.git] / reactos / sdk / include / crt / float.h
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
19 #ifndef _MINGW_FLOAT_H_
20 #define _MINGW_FLOAT_H_
21
22 #if defined(__GNUC__)
23 #include "mingw32/gcc_float.h"
24 #elif defined(_MSC_VER)
25 #include "msc/msc_float.h"
26 #else
27 #error
28 #endif
29
30 #include <crtdefs.h>
31
32 /*
33 * Functions and definitions for controlling the FPU.
34 */
35 #ifndef __STRICT_ANSI__
36
37 /* TODO: These constants are only valid for x86 machines */
38
39 /* Control word masks for unMask */
40 #define _MCW_EM 0x0008001F /* Error masks */
41 #define _MCW_IC 0x00040000 /* Infinity */
42 #define _MCW_RC 0x00000300 /* Rounding */
43 #define _MCW_PC 0x00030000 /* Precision */
44 #define _MCW_DN 0x03000000 /* Denormal */
45
46 /* Control word values for unNew (use with related unMask above) */
47 #define _EM_INVALID 0x00000010
48 #define _EM_DENORMAL 0x00080000
49 #define _EM_ZERODIVIDE 0x00000008
50 #define _EM_OVERFLOW 0x00000004
51 #define _EM_UNDERFLOW 0x00000002
52 #define _EM_INEXACT 0x00000001
53 #define _IC_AFFINE 0x00040000
54 #define _IC_PROJECTIVE 0x00000000
55 #define _RC_CHOP 0x00000300
56 #define _RC_UP 0x00000200
57 #define _RC_DOWN 0x00000100
58 #define _RC_NEAR 0x00000000
59 #define _PC_24 0x00020000
60 #define _PC_53 0x00010000
61 #define _PC_64 0x00000000
62
63 /* These are also defined in Mingw math.h, needed to work around
64 GCC build issues. */
65 /* Return values for fpclass. */
66 #ifndef __MINGW_FPCLASS_DEFINED
67 #define __MINGW_FPCLASS_DEFINED 1
68 #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
69 #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
70 #define _FPCLASS_NINF 0x0004 /* Negative Infinity */
71 #define _FPCLASS_NN 0x0008 /* Negative Normal */
72 #define _FPCLASS_ND 0x0010 /* Negative Denormal */
73 #define _FPCLASS_NZ 0x0020 /* Negative Zero */
74 #define _FPCLASS_PZ 0x0040 /* Positive Zero */
75 #define _FPCLASS_PD 0x0080 /* Positive Denormal */
76 #define _FPCLASS_PN 0x0100 /* Positive Normal */
77 #define _FPCLASS_PINF 0x0200 /* Positive Infinity */
78 #endif /* __MINGW_FPCLASS_DEFINED */
79
80 /* invalid subconditions (_SW_INVALID also set) */
81 #define _SW_UNEMULATED 0x0040 /* unemulated instruction */
82 #define _SW_SQRTNEG 0x0080 /* square root of a neg number */
83 #define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
84 #define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
85
86 /* Floating point error signals and return codes */
87 #define _FPE_INVALID 0x81
88 #define _FPE_DENORMAL 0x82
89 #define _FPE_ZERODIVIDE 0x83
90 #define _FPE_OVERFLOW 0x84
91 #define _FPE_UNDERFLOW 0x85
92 #define _FPE_INEXACT 0x86
93 #define _FPE_UNEMULATED 0x87
94 #define _FPE_SQRTNEG 0x88
95 #define _FPE_STACKOVERFLOW 0x8a
96 #define _FPE_STACKUNDERFLOW 0x8b
97 #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
98
99 #ifndef RC_INVOKED
100
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
104
105 /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
106 * i.e. change the bits in unMask to have the values they have in unNew,
107 * leaving other bits unchanged. */
108
109 __MINGW_NOTHROW
110 _CRTIMP
111 unsigned int
112 __cdecl
113 _controlfp(
114 _In_ unsigned int unNew,
115 _In_ unsigned int unMask);
116
117 __MINGW_NOTHROW
118 _CRTIMP
119 unsigned int
120 __cdecl
121 _control87(
122 _In_ unsigned int unNew,
123 _In_ unsigned int unMask);
124
125 __MINGW_NOTHROW _CRTIMP unsigned int __cdecl _clearfp (void); /* Clear the FPU status word */
126 __MINGW_NOTHROW _CRTIMP unsigned int __cdecl _statusfp (void); /* Report the FPU status word */
127 #define _clear87 _clearfp
128 #define _status87 _statusfp
129
130
131 /*
132 MSVCRT.dll _fpreset initializes the control register to 0x27f,
133 the status register to zero and the tag word to 0FFFFh.
134 This differs from asm instruction finit/fninit which set control
135 word to 0x37f (64 bit mantissa precison rather than 53 bit).
136 By default, the mingw version of _fpreset sets fp control as
137 per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
138 building your application.
139 */
140 __MINGW_NOTHROW void __cdecl _fpreset (void);
141 __MINGW_NOTHROW void __cdecl fpreset (void);
142
143 /* Global 'variable' for the current floating point error code. */
144 __MINGW_NOTHROW _CRTIMP int * __cdecl __fpecode(void);
145 #define _fpecode (*(__fpecode()))
146
147 /*
148 * IEEE recommended functions. MS puts them in float.h
149 * but they really belong in math.h.
150 */
151
152 _Check_return_
153 __MINGW_NOTHROW
154 _CRTIMP
155 double
156 __cdecl
157 _chgsign(
158 _In_ double);
159
160 _Check_return_
161 __MINGW_NOTHROW
162 _CRTIMP
163 double
164 __cdecl
165 _copysign(
166 _In_ double,
167 _In_ double);
168
169 _Check_return_
170 __MINGW_NOTHROW
171 _CRTIMP
172 double
173 __cdecl
174 _logb(
175 _In_ double);
176
177 _Check_return_
178 __MINGW_NOTHROW
179 _CRTIMP
180 double
181 __cdecl
182 _nextafter(
183 _In_ double,
184 _In_ double);
185
186 _Check_return_
187 __MINGW_NOTHROW
188 _CRTIMP
189 double
190 __cdecl
191 _scalb(
192 _In_ double,
193 _In_ long);
194
195 _Check_return_
196 __MINGW_NOTHROW
197 _CRTIMP
198 int
199 __cdecl
200 _finite(
201 _In_ double);
202
203 _Check_return_
204 __MINGW_NOTHROW
205 _CRTIMP
206 int
207 __cdecl
208 _fpclass(
209 _In_ double);
210
211 _Check_return_
212 __MINGW_NOTHROW
213 _CRTIMP
214 int
215 __cdecl
216 _isnan(
217 _In_ double);
218
219 #ifdef __cplusplus
220 }
221 #endif
222
223 #endif /* Not RC_INVOKED */
224
225 #endif /* Not __STRICT_ANSI__ */
226
227 #endif /* _MINGW_FLOAT_H_ */