source: Daodan/MinGW/include/fenv.h@ 1054

Last change on this file since 1054 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 3.2 KB
Line 
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*/
40typedef 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). */
46typedef 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
78extern "C" {
79#endif
80
81/*TODO: Some of these could be inlined */
82/* 7.6.2 Exception */
83
84extern int __cdecl __MINGW_NOTHROW feclearexcept (int);
85extern int __cdecl __MINGW_NOTHROW fegetexceptflag (fexcept_t * flagp, int excepts);
86extern int __cdecl __MINGW_NOTHROW feraiseexcept (int excepts );
87extern int __cdecl __MINGW_NOTHROW fesetexceptflag (const fexcept_t *, int);
88extern int __cdecl __MINGW_NOTHROW fetestexcept (int excepts);
89
90/* 7.6.3 Rounding */
91
92extern int __cdecl __MINGW_NOTHROW fegetround (void);
93extern int __cdecl __MINGW_NOTHROW fesetround (int mode);
94
95/* 7.6.4 Environment */
96
97extern int __cdecl __MINGW_NOTHROW fegetenv (fenv_t * envp);
98extern int __cdecl __MINGW_NOTHROW fesetenv (const fenv_t * );
99extern int __cdecl __MINGW_NOTHROW feupdateenv (const fenv_t *);
100extern 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 */
Note: See TracBrowser for help on using the repository browser.