Add fetestexceptflag.
[glibc.git] / math / fenv.h
blob10d32db909b410ded72f03d992b8694917f762f4
1 /* Copyright (C) 1997-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
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.
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
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99 7.6: Floating-point environment <fenv.h>
22 #ifndef _FENV_H
23 #define _FENV_H 1
25 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
26 #include <bits/libc-header-start.h>
28 /* Get the architecture dependend definitions. The following definitions
29 are expected to be done:
31 fenv_t type for object representing an entire floating-point
32 environment
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
38 fexcept_t type for object representing the floating-point exception
39 flags including status associated with the flags
41 The following macros are defined iff the implementation supports this
42 kind of exception.
43 FE_INEXACT inexact result
44 FE_DIVBYZERO division by zero
45 FE_UNDERFLOW result not representable due to underflow
46 FE_OVERFLOW result not representable due to overflow
47 FE_INVALID invalid operation
49 FE_ALL_EXCEPT bitwise OR of all supported exceptions
51 The next macros are defined iff the appropriate rounding mode is
52 supported by the implementation.
53 FE_TONEAREST round to nearest
54 FE_UPWARD round toward +Inf
55 FE_DOWNWARD round toward -Inf
56 FE_TOWARDZERO round toward 0
58 #include <bits/fenv.h>
60 __BEGIN_DECLS
62 /* Floating-point exception handling. */
64 /* Clear the supported exceptions represented by EXCEPTS. */
65 extern int feclearexcept (int __excepts) __THROW;
67 /* Store implementation-defined representation of the exception flags
68 indicated by EXCEPTS in the object pointed to by FLAGP. */
69 extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
71 /* Raise the supported exceptions represented by EXCEPTS. */
72 extern int feraiseexcept (int __excepts) __THROW;
74 #if __GLIBC_USE (IEC_60559_BFP_EXT)
75 /* Set the supported exception flags represented by EXCEPTS, without
76 causing enabled traps to be taken. */
77 extern int fesetexcept (int __excepts) __THROW;
78 #endif
80 /* Set complete status for exceptions indicated by EXCEPTS according to
81 the representation in the object pointed to by FLAGP. */
82 extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW;
84 /* Determine which of subset of the exceptions specified by EXCEPTS are
85 currently set. */
86 extern int fetestexcept (int __excepts) __THROW;
88 #if __GLIBC_USE (IEC_60559_BFP_EXT)
89 /* Determine which of subset of the exceptions specified by EXCEPTS
90 are set in *FLAGP. */
91 extern int fetestexceptflag (const fexcept_t *__flagp, int __excepts) __THROW;
92 #endif
95 /* Rounding control. */
97 /* Get current rounding direction. */
98 extern int fegetround (void) __THROW __attribute_pure__;
100 /* Establish the rounding direction represented by ROUND. */
101 extern int fesetround (int __rounding_direction) __THROW;
104 /* Floating-point environment. */
106 /* Store the current floating-point environment in the object pointed
107 to by ENVP. */
108 extern int fegetenv (fenv_t *__envp) __THROW;
110 /* Save the current environment in the object pointed to by ENVP, clear
111 exception flags and install a non-stop mode (if available) for all
112 exceptions. */
113 extern int feholdexcept (fenv_t *__envp) __THROW;
115 /* Establish the floating-point environment represented by the object
116 pointed to by ENVP. */
117 extern int fesetenv (const fenv_t *__envp) __THROW;
119 /* Save current exceptions in temporary storage, install environment
120 represented by object pointed to by ENVP and raise exceptions
121 according to saved exceptions. */
122 extern int feupdateenv (const fenv_t *__envp) __THROW;
125 /* Include optimization. */
126 #ifdef __OPTIMIZE__
127 # include <bits/fenvinline.h>
128 #endif
130 #ifdef __USE_GNU
132 /* Enable individual exceptions. Will not enable more exceptions than
133 EXCEPTS specifies. Returns the previous enabled exceptions if all
134 exceptions are successfully set, otherwise returns -1. */
135 extern int feenableexcept (int __excepts) __THROW;
137 /* Disable individual exceptions. Will not disable more exceptions than
138 EXCEPTS specifies. Returns the previous enabled exceptions if all
139 exceptions are successfully disabled, otherwise returns -1. */
140 extern int fedisableexcept (int __excepts) __THROW;
142 /* Return enabled exceptions. */
143 extern int fegetexcept (void) __THROW;
144 #endif
146 __END_DECLS
148 #endif /* fenv.h */