source: Daodan/MSYS2/mingw32/i686-w64-mingw32/include/fenv.h@ 1167

Last change on this file since 1167 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 4.3 KB
Line 
1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _FENV_H_
7#define _FENV_H_
8
9#include <crtdefs.h>
10
11#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
12
13/* FPU status word exception flags */
14#define FE_INVALID 0x01
15#define FE_DIVBYZERO 0x02
16#define FE_OVERFLOW 0x04
17#define FE_UNDERFLOW 0x08
18#define FE_INEXACT 0x10
19#define FE_ALL_EXCEPT (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
20
21/* FPU control word rounding flags */
22#define FE_TONEAREST 0x00000000
23#define FE_UPWARD 0x00400000
24#define FE_DOWNWARD 0x00800000
25#define FE_TOWARDZERO 0x00c00000
26
27/* Amount to shift by to convert an exception to a mask bit. */
28#define FE_EXCEPT_SHIFT 0x08
29
30#else
31
32#define FE_INVALID 0x01
33#define FE_DENORMAL 0x02
34#define FE_DIVBYZERO 0x04
35#define FE_OVERFLOW 0x08
36#define FE_UNDERFLOW 0x10
37#define FE_INEXACT 0x20
38#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
39 | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
40
41/* FPU control word rounding flags */
42#define FE_TONEAREST 0x0000
43#define FE_DOWNWARD 0x0400
44#define FE_UPWARD 0x0800
45#define FE_TOWARDZERO 0x0c00
46
47/* The MXCSR exception flags are the same as the
48 FE flags. */
49#define __MXCSR_EXCEPT_FLAG_SHIFT 0
50
51/* How much to shift FE status word exception flags
52 to get the MXCSR exeptions masks, */
53#define __MXCSR_EXCEPT_MASK_SHIFT 7
54
55/* How much to shift FE status word exception flags
56 to get MXCSR rounding flags, */
57#define __MXCSR_ROUND_FLAG_SHIFT 3
58
59#endif /* defined(_ARM_) || defined(__arm__) */
60
61#ifndef RC_INVOKED
62
63#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
64
65/* Type representing exception flags. */
66typedef unsigned int fexcept_t;
67
68/* Type representing floating-point environment. */
69typedef struct
70{
71 unsigned int __cw;
72} fenv_t;
73
74/* If the default argument is used we use this value. */
75#define FE_DFL_ENV ((const fenv_t *) -1l)
76
77#else
78
79/*
80 For now, support only for the basic abstraction of flags that are
81 either set or clear. fexcept_t could be structure that holds more
82 info about the fp environment.
83*/
84typedef unsigned short fexcept_t;
85
86/* This 32-byte struct represents the entire floating point
87 environment as stored by fnstenv or fstenv, augmented by
88 the contents of the MXCSR register, as stored by stmxcsr
89 (if CPU supports it). */
90typedef struct
91{
92 unsigned short __control_word;
93 unsigned short __unused0;
94 unsigned short __status_word;
95 unsigned short __unused1;
96 unsigned short __tag_word;
97 unsigned short __unused2;
98 unsigned int __ip_offset; /* instruction pointer offset */
99 unsigned short __ip_selector;
100 unsigned short __opcode;
101 unsigned int __data_offset;
102 unsigned short __data_selector;
103 unsigned short __unused3;
104 unsigned int __mxcsr; /* contents of the MXCSR register */
105} fenv_t;
106
107
108/*The C99 standard (7.6.9) allows us to define implementation-specific macros for
109 different fp environments */
110
111/* The default Intel x87 floating point environment (64-bit mantissa) */
112#define FE_PC64_ENV ((const fenv_t *)-1)
113
114/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
115#define FE_PC53_ENV ((const fenv_t *)-2)
116
117/* The FE_DFL_ENV macro is required by standard.
118 fesetenv will use the environment set at app startup.*/
119#define FE_DFL_ENV ((const fenv_t *) 0)
120
121#endif /* defined(_ARM_) || defined(__arm__) */
122
123#ifdef __cplusplus
124extern "C" {
125#endif
126
127/*TODO: Some of these could be inlined */
128/* 7.6.2 Exception */
129
130extern int __cdecl feclearexcept (int);
131extern int __cdecl fegetexceptflag (fexcept_t * flagp, int excepts);
132extern int __cdecl feraiseexcept (int excepts );
133extern int __cdecl fesetexceptflag (const fexcept_t *, int);
134extern int __cdecl fetestexcept (int excepts);
135
136/* 7.6.3 Rounding */
137
138extern int __cdecl fegetround (void);
139extern int __cdecl fesetround (int mode);
140
141/* 7.6.4 Environment */
142
143extern int __cdecl fegetenv(fenv_t * envp);
144extern int __cdecl fesetenv(const fenv_t * );
145extern int __cdecl feupdateenv(const fenv_t *);
146extern int __cdecl feholdexcept(fenv_t *);
147
148#ifdef __cplusplus
149}
150#endif
151#endif /* Not RC_INVOKED */
152
153#endif /* ndef _FENV_H */
Note: See TracBrowser for help on using the repository browser.