OSDN Git Service

Correct mistyped __MINGW_NOTHROW macro.
[mingw/mingw-org-wsl.git] / include / fenv.h
1 /**
2  * @file fenv.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _FENV_H_
25 #define _FENV_H_
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 /* FPU status word exception flags */
30 #define FE_INVALID      0x01
31 #define FE_DENORMAL     0x02
32 #define FE_DIVBYZERO    0x04
33 #define FE_OVERFLOW     0x08
34 #define FE_UNDERFLOW    0x10
35 #define FE_INEXACT      0x20
36 #define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
37                        | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
38
39 /* FPU control word rounding flags */
40 #define FE_TONEAREST    0x0000
41 #define FE_DOWNWARD     0x0400
42 #define FE_UPWARD       0x0800
43 #define FE_TOWARDZERO   0x0c00
44
45 /* The MXCSR exception flags are the same as the
46    FE flags. */
47 #define __MXCSR_EXCEPT_FLAG_SHIFT 0
48
49 /* How much to shift FE status word exception flags
50    to get the MXCSR exeptions masks,  */
51 #define __MXCSR_EXCEPT_MASK_SHIFT 7
52
53 /* How much to shift FE control word rounding flags
54    to get MXCSR rounding flags,  */
55 #define __MXCSR_ROUND_FLAG_SHIFT 3
56
57 #ifndef RC_INVOKED
58 /*
59   For now, support only for the basic abstraction of flags that are
60   either set or clear. fexcept_t could be  structure that holds more
61   info about the fp environment.
62 */
63 typedef unsigned short fexcept_t;
64
65 /* This 32-byte struct represents the entire floating point
66    environment as stored by fnstenv or fstenv, augmented by
67    the  contents of the MXCSR register, as stored by stmxcsr
68    (if CPU supports it). */
69 typedef struct
70 {
71   unsigned short __control_word;
72   unsigned short __unused0;
73   unsigned short __status_word;
74   unsigned short __unused1;
75   unsigned short __tag_word;
76   unsigned short __unused2;  
77   unsigned int   __ip_offset;    /* instruction pointer offset */
78   unsigned short __ip_selector;  
79   unsigned short __opcode;
80   unsigned int   __data_offset;
81   unsigned short __data_selector;
82   unsigned short  __unused3;
83   unsigned int __mxcsr; /* contents of the MXCSR register  */
84 } fenv_t;
85
86
87 /*The C99 standard (7.6.9) allows us to define implementation-specific macros for
88   different fp environments */
89   
90 /* The default Intel x87 floating point environment (64-bit mantissa) */
91 #define FE_PC64_ENV ((const fenv_t *)-1)
92
93 /* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
94 #define FE_PC53_ENV ((const fenv_t *)-2)
95
96 /* The FE_DFL_ENV macro is required by standard.
97   fesetenv will use the environment set at app startup.*/
98 #define FE_DFL_ENV ((const fenv_t *) 0)
99
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103
104 /*TODO: Some of these could be inlined */
105 /* 7.6.2 Exception */
106
107 extern int __cdecl __MINGW_NOTHROW feclearexcept (int);
108 extern int __cdecl __MINGW_NOTHROW fegetexceptflag (fexcept_t * flagp, int excepts);
109 extern int __cdecl __MINGW_NOTHROW feraiseexcept (int excepts );
110 extern int __cdecl __MINGW_NOTHROW fesetexceptflag (const fexcept_t *, int);
111 extern int __cdecl __MINGW_NOTHROW fetestexcept (int excepts);
112
113 /* 7.6.3 Rounding */
114
115 extern int __cdecl __MINGW_NOTHROW fegetround (void);
116 extern int __cdecl __MINGW_NOTHROW fesetround (int mode);
117
118 /* 7.6.4 Environment */
119
120 extern int __cdecl __MINGW_NOTHROW fegetenv (fenv_t * envp);
121 extern int __cdecl __MINGW_NOTHROW fesetenv (const fenv_t * );
122 extern int __cdecl __MINGW_NOTHROW feupdateenv (const fenv_t *);
123 extern int __cdecl __MINGW_NOTHROW feholdexcept (fenv_t *);
124
125 #ifdef __cplusplus
126 }
127 #endif
128 #endif  /* Not RC_INVOKED */
129
130 #endif /* ndef _FENV_H */