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.
7 * Constants related to floating point arithmetic.
9 * Also included here are some non-ANSI bits for accessing the floating
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
20 #include <gcc_float.h>
21 #elif defined(_MSC_VER)
22 #include <msc_float.h>
27 #ifndef _MINGW_FLOAT_H_
28 #define _MINGW_FLOAT_H_
33 * Functions and definitions for controlling the FPU.
35 #ifndef __STRICT_ANSI__
37 /* TODO: These constants are only valid for x86 machines */
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 */
45 /* Control word values for unNew (use with related unMask above) */
46 #define _EM_INVALID 0x00000010
47 #define _EM_DENORMAL 0x00080000
48 #define _EM_ZERODIVIDE 0x00000008
49 #define _EM_OVERFLOW 0x00000004
50 #define _EM_UNDERFLOW 0x00000002
51 #define _EM_INEXACT 0x00000001
52 #define _IC_AFFINE 0x00040000
53 #define _IC_PROJECTIVE 0x00000000
54 #define _RC_CHOP 0x00000300
55 #define _RC_UP 0x00000200
56 #define _RC_DOWN 0x00000100
57 #define _RC_NEAR 0x00000000
58 #define _PC_24 0x00020000
59 #define _PC_53 0x00010000
60 #define _PC_64 0x00000000
62 /* These are also defined in Mingw math.h, needed to work around
64 /* Return values for fpclass. */
65 #ifndef __MINGW_FPCLASS_DEFINED
66 #define __MINGW_FPCLASS_DEFINED 1
67 #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */
68 #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */
69 #define _FPCLASS_NINF 0x0004 /* Negative Infinity */
70 #define _FPCLASS_NN 0x0008 /* Negative Normal */
71 #define _FPCLASS_ND 0x0010 /* Negative Denormal */
72 #define _FPCLASS_NZ 0x0020 /* Negative Zero */
73 #define _FPCLASS_PZ 0x0040 /* Positive Zero */
74 #define _FPCLASS_PD 0x0080 /* Positive Denormal */
75 #define _FPCLASS_PN 0x0100 /* Positive Normal */
76 #define _FPCLASS_PINF 0x0200 /* Positive Infinity */
77 #endif /* __MINGW_FPCLASS_DEFINED */
79 /* invalid subconditions (_SW_INVALID also set) */
80 #define _SW_UNEMULATED 0x0040 /* unemulated instruction */
81 #define _SW_SQRTNEG 0x0080 /* square root of a neg number */
82 #define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
83 #define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
85 /* Floating point error signals and return codes */
86 #define _FPE_INVALID 0x81
87 #define _FPE_DENORMAL 0x82
88 #define _FPE_ZERODIVIDE 0x83
89 #define _FPE_OVERFLOW 0x84
90 #define _FPE_UNDERFLOW 0x85
91 #define _FPE_INEXACT 0x86
92 #define _FPE_UNEMULATED 0x87
93 #define _FPE_SQRTNEG 0x88
94 #define _FPE_STACKOVERFLOW 0x8a
95 #define _FPE_STACKUNDERFLOW 0x8b
96 #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
104 /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
105 * i.e. change the bits in unMask to have the values they have in unNew,
106 * leaving other bits unchanged. */
107 _CRTIMP
unsigned int __cdecl __MINGW_NOTHROW
_controlfp (unsigned int unNew
, unsigned int unMask
);
108 _CRTIMP
unsigned int __cdecl __MINGW_NOTHROW
_control87 (unsigned int unNew
, unsigned int unMask
);
111 _CRTIMP
unsigned int __cdecl __MINGW_NOTHROW
_clearfp (void); /* Clear the FPU status word */
112 _CRTIMP
unsigned int __cdecl __MINGW_NOTHROW
_statusfp (void); /* Report the FPU status word */
113 #define _clear87 _clearfp
114 #define _status87 _statusfp
118 MSVCRT.dll _fpreset initializes the control register to 0x27f,
119 the status register to zero and the tag word to 0FFFFh.
120 This differs from asm instruction finit/fninit which set control
121 word to 0x37f (64 bit mantissa precison rather than 53 bit).
122 By default, the mingw version of _fpreset sets fp control as
123 per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when
124 building your application.
126 void __cdecl __MINGW_NOTHROW
_fpreset (void);
127 void __cdecl __MINGW_NOTHROW
fpreset (void);
129 /* Global 'variable' for the current floating point error code. */
130 _CRTIMP
int * __cdecl __MINGW_NOTHROW
__fpecode(void);
131 #define _fpecode (*(__fpecode()))
134 * IEEE recommended functions. MS puts them in float.h
135 * but they really belong in math.h.
138 _CRTIMP
double __cdecl __MINGW_NOTHROW
_chgsign (double);
139 _CRTIMP
double __cdecl __MINGW_NOTHROW
_copysign (double, double);
140 _CRTIMP
double __cdecl __MINGW_NOTHROW
_logb (double);
141 _CRTIMP
double __cdecl __MINGW_NOTHROW
_nextafter (double, double);
142 _CRTIMP
double __cdecl __MINGW_NOTHROW
_scalb (double, long);
144 _CRTIMP
int __cdecl __MINGW_NOTHROW
_finite (double);
145 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fpclass (double);
146 _CRTIMP
int __cdecl __MINGW_NOTHROW
_isnan (double);
152 #endif /* Not RC_INVOKED */
154 #endif /* Not __STRICT_ANSI__ */
156 #endif /* _MINGW_FLOAT_H_ */