1 | #ifndef _FENV_H_
|
---|
2 | #define _FENV_H_
|
---|
3 |
|
---|
4 | #include <_mingw.h>
|
---|
5 |
|
---|
6 | /* FPU status word exception flags */
|
---|
7 | #define FE_INVALID 0x01
|
---|
8 | #define FE_DENORMAL 0x02
|
---|
9 | #define FE_DIVBYZERO 0x04
|
---|
10 | #define FE_OVERFLOW 0x08
|
---|
11 | #define FE_UNDERFLOW 0x10
|
---|
12 | #define FE_INEXACT 0x20
|
---|
13 | #define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
|
---|
14 | | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
|
---|
15 |
|
---|
16 | /* FPU control word rounding flags */
|
---|
17 | #define FE_TONEAREST 0x0000
|
---|
18 | #define FE_DOWNWARD 0x0400
|
---|
19 | #define FE_UPWARD 0x0800
|
---|
20 | #define FE_TOWARDZERO 0x0c00
|
---|
21 |
|
---|
22 | /* The MXCSR exception flags are the same as the
|
---|
23 | FE flags. */
|
---|
24 | #define __MXCSR_EXCEPT_FLAG_SHIFT 0
|
---|
25 |
|
---|
26 | /* How much to shift FE status word exception flags
|
---|
27 | to get the MXCSR exeptions masks, */
|
---|
28 | #define __MXCSR_EXCEPT_MASK_SHIFT 7
|
---|
29 |
|
---|
30 | /* How much to shift FE control word rounding flags
|
---|
31 | to get MXCSR rounding flags, */
|
---|
32 | #define __MXCSR_ROUND_FLAG_SHIFT 3
|
---|
33 |
|
---|
34 | #ifndef RC_INVOKED
|
---|
35 | /*
|
---|
36 | For now, support only for the basic abstraction of flags that are
|
---|
37 | either set or clear. fexcept_t could be structure that holds more
|
---|
38 | info about the fp environment.
|
---|
39 | */
|
---|
40 | typedef unsigned short fexcept_t;
|
---|
41 |
|
---|
42 | /* This 32-byte struct represents the entire floating point
|
---|
43 | environment as stored by fnstenv or fstenv, augmented by
|
---|
44 | the contents of the MXCSR register, as stored by stmxcsr
|
---|
45 | (if CPU supports it). */
|
---|
46 | typedef struct
|
---|
47 | {
|
---|
48 | unsigned short __control_word;
|
---|
49 | unsigned short __unused0;
|
---|
50 | unsigned short __status_word;
|
---|
51 | unsigned short __unused1;
|
---|
52 | unsigned short __tag_word;
|
---|
53 | unsigned short __unused2;
|
---|
54 | unsigned int __ip_offset; /* instruction pointer offset */
|
---|
55 | unsigned short __ip_selector;
|
---|
56 | unsigned short __opcode;
|
---|
57 | unsigned int __data_offset;
|
---|
58 | unsigned short __data_selector;
|
---|
59 | unsigned short __unused3;
|
---|
60 | unsigned int __mxcsr; /* contents of the MXCSR register */
|
---|
61 | } fenv_t;
|
---|
62 |
|
---|
63 |
|
---|
64 | /*The C99 standard (7.6.9) allows us to define implementation-specific macros for
|
---|
65 | different fp environments */
|
---|
66 |
|
---|
67 | /* The default Intel x87 floating point environment (64-bit mantissa) */
|
---|
68 | #define FE_PC64_ENV ((const fenv_t *)-1)
|
---|
69 |
|
---|
70 | /* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
|
---|
71 | #define FE_PC53_ENV ((const fenv_t *)-2)
|
---|
72 |
|
---|
73 | /* The FE_DFL_ENV macro is required by standard.
|
---|
74 | fesetenv will use the environment set at app startup.*/
|
---|
75 | #define FE_DFL_ENV ((const fenv_t *) 0)
|
---|
76 |
|
---|
77 | #ifdef __cplusplus
|
---|
78 | extern "C" {
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | /*TODO: Some of these could be inlined */
|
---|
82 | /* 7.6.2 Exception */
|
---|
83 |
|
---|
84 | extern int __cdecl __MINGW_NOTHROW feclearexcept (int);
|
---|
85 | extern int __cdecl __MINGW_NOTHROW fegetexceptflag (fexcept_t * flagp, int excepts);
|
---|
86 | extern int __cdecl __MINGW_NOTHROW feraiseexcept (int excepts );
|
---|
87 | extern int __cdecl __MINGW_NOTHROW fesetexceptflag (const fexcept_t *, int);
|
---|
88 | extern int __cdecl __MINGW_NOTHROW fetestexcept (int excepts);
|
---|
89 |
|
---|
90 | /* 7.6.3 Rounding */
|
---|
91 |
|
---|
92 | extern int __cdecl __MINGW_NOTHROW fegetround (void);
|
---|
93 | extern int __cdecl __MINGW_NOTHROW fesetround (int mode);
|
---|
94 |
|
---|
95 | /* 7.6.4 Environment */
|
---|
96 |
|
---|
97 | extern int __cdecl __MINGW_NOTHROW fegetenv (fenv_t * envp);
|
---|
98 | extern int __cdecl __MINGW_NOTHROW fesetenv (const fenv_t * );
|
---|
99 | extern int __cdecl __MINGW_NOTHROW feupdateenv (const fenv_t *);
|
---|
100 | extern int __cdecl __MINGW_NOTHROW feholdexcept (fenv_t *);
|
---|
101 |
|
---|
102 | #ifdef __cplusplus
|
---|
103 | }
|
---|
104 | #endif
|
---|
105 | #endif /* Not RC_INVOKED */
|
---|
106 |
|
---|
107 | #endif /* ndef _FENV_H */
|
---|