xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Copyright (C) 1997-2016 Free Software Foundation, Inc. |
| 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 |
| 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. |
| 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 |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 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/>. */ |
| 17 | |
| 18 | /* |
| 19 | * ISO C99 7.6: Floating-point environment <fenv.h> |
| 20 | */ |
| 21 | |
| 22 | #ifndef _FENV_H |
| 23 | #define _FENV_H 1 |
| 24 | |
| 25 | #include <features.h> |
| 26 | |
| 27 | /* Get the architecture dependend definitions. The following definitions |
| 28 | are expected to be done: |
| 29 | |
| 30 | fenv_t type for object representing an entire floating-point |
| 31 | environment |
| 32 | |
| 33 | FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument |
| 34 | to functions taking an argument of type fenv_t; in this |
| 35 | case the default environment will be used |
| 36 | |
| 37 | fexcept_t type for object representing the floating-point exception |
| 38 | flags including status associated with the flags |
| 39 | |
| 40 | The following macros are defined iff the implementation supports this |
| 41 | kind of exception. |
| 42 | FE_INEXACT inexact result |
| 43 | FE_DIVBYZERO division by zero |
| 44 | FE_UNDERFLOW result not representable due to underflow |
| 45 | FE_OVERFLOW result not representable due to overflow |
| 46 | FE_INVALID invalid operation |
| 47 | |
| 48 | FE_ALL_EXCEPT bitwise OR of all supported exceptions |
| 49 | |
| 50 | The next macros are defined iff the appropriate rounding mode is |
| 51 | supported by the implementation. |
| 52 | FE_TONEAREST round to nearest |
| 53 | FE_UPWARD round toward +Inf |
| 54 | FE_DOWNWARD round toward -Inf |
| 55 | FE_TOWARDZERO round toward 0 |
| 56 | */ |
| 57 | #include <bits/fenv.h> |
| 58 | |
| 59 | __BEGIN_DECLS |
| 60 | |
| 61 | /* Floating-point exception handling. */ |
| 62 | |
| 63 | /* Clear the supported exceptions represented by EXCEPTS. */ |
| 64 | extern int feclearexcept (int __excepts) __THROW; |
| 65 | |
| 66 | /* Store implementation-defined representation of the exception flags |
| 67 | indicated by EXCEPTS in the object pointed to by FLAGP. */ |
| 68 | extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW; |
| 69 | |
| 70 | /* Raise the supported exceptions represented by EXCEPTS. */ |
| 71 | extern int feraiseexcept (int __excepts) __THROW; |
| 72 | |
| 73 | /* Set complete status for exceptions indicated by EXCEPTS according to |
| 74 | the representation in the object pointed to by FLAGP. */ |
| 75 | extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW; |
| 76 | |
| 77 | /* Determine which of subset of the exceptions specified by EXCEPTS are |
| 78 | currently set. */ |
| 79 | extern int fetestexcept (int __excepts) __THROW; |
| 80 | |
| 81 | |
| 82 | /* Rounding control. */ |
| 83 | |
| 84 | /* Get current rounding direction. */ |
| 85 | extern int fegetround (void) __THROW __attribute_pure__; |
| 86 | |
| 87 | /* Establish the rounding direction represented by ROUND. */ |
| 88 | extern int fesetround (int __rounding_direction) __THROW; |
| 89 | |
| 90 | |
| 91 | /* Floating-point environment. */ |
| 92 | |
| 93 | /* Store the current floating-point environment in the object pointed |
| 94 | to by ENVP. */ |
| 95 | extern int fegetenv (fenv_t *__envp) __THROW; |
| 96 | |
| 97 | /* Save the current environment in the object pointed to by ENVP, clear |
| 98 | exception flags and install a non-stop mode (if available) for all |
| 99 | exceptions. */ |
| 100 | extern int feholdexcept (fenv_t *__envp) __THROW; |
| 101 | |
| 102 | /* Establish the floating-point environment represented by the object |
| 103 | pointed to by ENVP. */ |
| 104 | extern int fesetenv (const fenv_t *__envp) __THROW; |
| 105 | |
| 106 | /* Save current exceptions in temporary storage, install environment |
| 107 | represented by object pointed to by ENVP and raise exceptions |
| 108 | according to saved exceptions. */ |
| 109 | extern int feupdateenv (const fenv_t *__envp) __THROW; |
| 110 | |
| 111 | |
| 112 | /* Include optimization. */ |
| 113 | #ifdef __OPTIMIZE__ |
| 114 | # include <bits/fenvinline.h> |
| 115 | #endif |
| 116 | |
| 117 | #ifdef __USE_GNU |
| 118 | |
| 119 | /* Enable individual exceptions. Will not enable more exceptions than |
| 120 | EXCEPTS specifies. Returns the previous enabled exceptions if all |
| 121 | exceptions are successfully set, otherwise returns -1. */ |
| 122 | extern int feenableexcept (int __excepts) __THROW; |
| 123 | |
| 124 | /* Disable individual exceptions. Will not disable more exceptions than |
| 125 | EXCEPTS specifies. Returns the previous enabled exceptions if all |
| 126 | exceptions are successfully disabled, otherwise returns -1. */ |
| 127 | extern int fedisableexcept (int __excepts) __THROW; |
| 128 | |
| 129 | /* Return enabled exceptions. */ |
| 130 | extern int fegetexcept (void) __THROW; |
| 131 | #endif |
| 132 | |
| 133 | __END_DECLS |
| 134 | |
| 135 | #endif /* fenv.h */ |