]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 1997-2021 Free Software Foundation, Inc. |
63551311 UD |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either | |
7 | version 2.1 of the License, or (at your option) any later version. | |
63551311 UD |
8 | |
9 | The GNU C Library is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 12 | Lesser General Public License for more details. |
63551311 | 13 | |
41bdb6e2 | 14 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 15 | License along with the GNU C Library; if not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
63551311 UD |
17 | |
18 | /* | |
63ae7b63 | 19 | * ISO C99 7.6: Floating-point environment <fenv.h> |
63551311 UD |
20 | */ |
21 | ||
22 | #ifndef _FENV_H | |
779ae82e | 23 | #define _FENV_H 1 |
5107cf1d | 24 | |
5146356f JM |
25 | #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION |
26 | #include <bits/libc-header-start.h> | |
63551311 UD |
27 | |
28 | /* Get the architecture dependend definitions. The following definitions | |
29 | are expected to be done: | |
30 | ||
31 | fenv_t type for object representing an entire floating-point | |
32 | environment | |
33 | ||
34 | FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument | |
35 | to functions taking an argument of type fenv_t; in this | |
36 | case the default environment will be used | |
37 | ||
38 | fexcept_t type for object representing the floating-point exception | |
39 | flags including status associated with the flags | |
40 | ||
ec94343f JM |
41 | femode_t type for object representing floating-point control modes |
42 | ||
43 | FE_DFL_MODE macro of type pointer to const femode_t to be used as the | |
44 | argument to fesetmode; in this case the default control | |
45 | modes will be used | |
46 | ||
63551311 UD |
47 | The following macros are defined iff the implementation supports this |
48 | kind of exception. | |
779ae82e | 49 | FE_INEXACT inexact result |
8267e47b | 50 | FE_DIVBYZERO division by zero |
63551311 UD |
51 | FE_UNDERFLOW result not representable due to underflow |
52 | FE_OVERFLOW result not representable due to overflow | |
53 | FE_INVALID invalid operation | |
54 | ||
55 | FE_ALL_EXCEPT bitwise OR of all supported exceptions | |
56 | ||
57 | The next macros are defined iff the appropriate rounding mode is | |
58 | supported by the implementation. | |
59 | FE_TONEAREST round to nearest | |
60 | FE_UPWARD round toward +Inf | |
61 | FE_DOWNWARD round toward -Inf | |
62 | FE_TOWARDZERO round toward 0 | |
63 | */ | |
5107cf1d | 64 | #include <bits/fenv.h> |
63551311 UD |
65 | |
66 | __BEGIN_DECLS | |
67 | ||
68 | /* Floating-point exception handling. */ | |
69 | ||
70 | /* Clear the supported exceptions represented by EXCEPTS. */ | |
63ae7b63 | 71 | extern int feclearexcept (int __excepts) __THROW; |
63551311 UD |
72 | |
73 | /* Store implementation-defined representation of the exception flags | |
74 | indicated by EXCEPTS in the object pointed to by FLAGP. */ | |
63ae7b63 | 75 | extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW; |
63551311 UD |
76 | |
77 | /* Raise the supported exceptions represented by EXCEPTS. */ | |
63ae7b63 | 78 | extern int feraiseexcept (int __excepts) __THROW; |
63551311 | 79 | |
0175c9e9 | 80 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
5146356f JM |
81 | /* Set the supported exception flags represented by EXCEPTS, without |
82 | causing enabled traps to be taken. */ | |
83 | extern int fesetexcept (int __excepts) __THROW; | |
84 | #endif | |
85 | ||
1f205a47 | 86 | /* Set complete status for exceptions indicated by EXCEPTS according to |
63551311 | 87 | the representation in the object pointed to by FLAGP. */ |
a784e502 | 88 | extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW; |
63551311 UD |
89 | |
90 | /* Determine which of subset of the exceptions specified by EXCEPTS are | |
91 | currently set. */ | |
4d3a563f | 92 | extern int fetestexcept (int __excepts) __THROW; |
63551311 | 93 | |
0175c9e9 | 94 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
780257d4 JM |
95 | /* Determine which of subset of the exceptions specified by EXCEPTS |
96 | are set in *FLAGP. */ | |
97 | extern int fetestexceptflag (const fexcept_t *__flagp, int __excepts) __THROW; | |
98 | #endif | |
99 | ||
63551311 UD |
100 | |
101 | /* Rounding control. */ | |
102 | ||
103 | /* Get current rounding direction. */ | |
223d1cac | 104 | extern int fegetround (void) __THROW __attribute_pure__; |
63551311 UD |
105 | |
106 | /* Establish the rounding direction represented by ROUND. */ | |
4d3a563f | 107 | extern int fesetround (int __rounding_direction) __THROW; |
63551311 UD |
108 | |
109 | ||
110 | /* Floating-point environment. */ | |
111 | ||
112 | /* Store the current floating-point environment in the object pointed | |
113 | to by ENVP. */ | |
63ae7b63 | 114 | extern int fegetenv (fenv_t *__envp) __THROW; |
63551311 UD |
115 | |
116 | /* Save the current environment in the object pointed to by ENVP, clear | |
117 | exception flags and install a non-stop mode (if available) for all | |
118 | exceptions. */ | |
4d3a563f | 119 | extern int feholdexcept (fenv_t *__envp) __THROW; |
63551311 UD |
120 | |
121 | /* Establish the floating-point environment represented by the object | |
122 | pointed to by ENVP. */ | |
a784e502 | 123 | extern int fesetenv (const fenv_t *__envp) __THROW; |
63551311 UD |
124 | |
125 | /* Save current exceptions in temporary storage, install environment | |
126 | represented by object pointed to by ENVP and raise exceptions | |
127 | according to saved exceptions. */ | |
a784e502 | 128 | extern int feupdateenv (const fenv_t *__envp) __THROW; |
63551311 | 129 | |
7ad6d73d | 130 | |
ec94343f JM |
131 | /* Control modes. */ |
132 | ||
0175c9e9 | 133 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) |
ec94343f JM |
134 | /* Store the current floating-point control modes in the object |
135 | pointed to by MODEP. */ | |
136 | extern int fegetmode (femode_t *__modep) __THROW; | |
137 | ||
138 | /* Establish the floating-point control modes represented by the | |
139 | object pointed to by MODEP. */ | |
140 | extern int fesetmode (const femode_t *__modep) __THROW; | |
141 | #endif | |
142 | ||
7ad6d73d | 143 | |
c0b43536 JM |
144 | /* NaN support. */ |
145 | ||
0175c9e9 | 146 | #if (__GLIBC_USE (IEC_60559_BFP_EXT_C2X) \ |
c0b43536 JM |
147 | && defined FE_INVALID \ |
148 | && defined __SUPPORT_SNAN__) | |
149 | # define FE_SNANS_ALWAYS_SIGNAL 1 | |
150 | #endif | |
151 | ||
05ef7ce9 UD |
152 | #ifdef __USE_GNU |
153 | ||
154 | /* Enable individual exceptions. Will not enable more exceptions than | |
155 | EXCEPTS specifies. Returns the previous enabled exceptions if all | |
6e8afc1c | 156 | exceptions are successfully set, otherwise returns -1. */ |
05ef7ce9 UD |
157 | extern int feenableexcept (int __excepts) __THROW; |
158 | ||
159 | /* Disable individual exceptions. Will not disable more exceptions than | |
160 | EXCEPTS specifies. Returns the previous enabled exceptions if all | |
6e8afc1c | 161 | exceptions are successfully disabled, otherwise returns -1. */ |
05ef7ce9 UD |
162 | extern int fedisableexcept (int __excepts) __THROW; |
163 | ||
164 | /* Return enabled exceptions. */ | |
165 | extern int fegetexcept (void) __THROW; | |
166 | #endif | |
167 | ||
63551311 UD |
168 | __END_DECLS |
169 | ||
170 | #endif /* fenv.h */ |