1*53ee8cc1Swenshuai.xi /* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. 2*53ee8cc1Swenshuai.xi This file is part of the GNU C Library. 3*53ee8cc1Swenshuai.xi 4*53ee8cc1Swenshuai.xi The GNU C Library is free software; you can redistribute it and/or 5*53ee8cc1Swenshuai.xi modify it under the terms of the GNU Lesser General Public 6*53ee8cc1Swenshuai.xi License as published by the Free Software Foundation; either 7*53ee8cc1Swenshuai.xi version 2.1 of the License, or (at your option) any later version. 8*53ee8cc1Swenshuai.xi 9*53ee8cc1Swenshuai.xi The GNU C Library is distributed in the hope that it will be useful, 10*53ee8cc1Swenshuai.xi but WITHOUT ANY WARRANTY; without even the implied warranty of 11*53ee8cc1Swenshuai.xi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12*53ee8cc1Swenshuai.xi Lesser General Public License for more details. 13*53ee8cc1Swenshuai.xi 14*53ee8cc1Swenshuai.xi You should have received a copy of the GNU Lesser General Public 15*53ee8cc1Swenshuai.xi License along with the GNU C Library; if not, write to the Free 16*53ee8cc1Swenshuai.xi Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17*53ee8cc1Swenshuai.xi 02111-1307 USA. */ 18*53ee8cc1Swenshuai.xi 19*53ee8cc1Swenshuai.xi /* 20*53ee8cc1Swenshuai.xi * ISO C99 7.6: Floating-point environment <fenv.h> 21*53ee8cc1Swenshuai.xi */ 22*53ee8cc1Swenshuai.xi 23*53ee8cc1Swenshuai.xi #ifndef _FENV_H 24*53ee8cc1Swenshuai.xi #define _FENV_H 1 25*53ee8cc1Swenshuai.xi 26*53ee8cc1Swenshuai.xi #include <features.h> 27*53ee8cc1Swenshuai.xi 28*53ee8cc1Swenshuai.xi /* Get the architecture dependend definitions. The following definitions 29*53ee8cc1Swenshuai.xi are expected to be done: 30*53ee8cc1Swenshuai.xi 31*53ee8cc1Swenshuai.xi fenv_t type for object representing an entire floating-point 32*53ee8cc1Swenshuai.xi environment 33*53ee8cc1Swenshuai.xi 34*53ee8cc1Swenshuai.xi FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument 35*53ee8cc1Swenshuai.xi to functions taking an argument of type fenv_t; in this 36*53ee8cc1Swenshuai.xi case the default environment will be used 37*53ee8cc1Swenshuai.xi 38*53ee8cc1Swenshuai.xi fexcept_t type for object representing the floating-point exception 39*53ee8cc1Swenshuai.xi flags including status associated with the flags 40*53ee8cc1Swenshuai.xi 41*53ee8cc1Swenshuai.xi The following macros are defined iff the implementation supports this 42*53ee8cc1Swenshuai.xi kind of exception. 43*53ee8cc1Swenshuai.xi FE_INEXACT inexact result 44*53ee8cc1Swenshuai.xi FE_DIVBYZERO division by zero 45*53ee8cc1Swenshuai.xi FE_UNDERFLOW result not representable due to underflow 46*53ee8cc1Swenshuai.xi FE_OVERFLOW result not representable due to overflow 47*53ee8cc1Swenshuai.xi FE_INVALID invalid operation 48*53ee8cc1Swenshuai.xi 49*53ee8cc1Swenshuai.xi FE_ALL_EXCEPT bitwise OR of all supported exceptions 50*53ee8cc1Swenshuai.xi 51*53ee8cc1Swenshuai.xi The next macros are defined iff the appropriate rounding mode is 52*53ee8cc1Swenshuai.xi supported by the implementation. 53*53ee8cc1Swenshuai.xi FE_TONEAREST round to nearest 54*53ee8cc1Swenshuai.xi FE_UPWARD round toward +Inf 55*53ee8cc1Swenshuai.xi FE_DOWNWARD round toward -Inf 56*53ee8cc1Swenshuai.xi FE_TOWARDZERO round toward 0 57*53ee8cc1Swenshuai.xi */ 58*53ee8cc1Swenshuai.xi #include <bits/fenv.h> 59*53ee8cc1Swenshuai.xi 60*53ee8cc1Swenshuai.xi __BEGIN_DECLS 61*53ee8cc1Swenshuai.xi 62*53ee8cc1Swenshuai.xi /* Floating-point exception handling. */ 63*53ee8cc1Swenshuai.xi 64*53ee8cc1Swenshuai.xi /* Clear the supported exceptions represented by EXCEPTS. */ 65*53ee8cc1Swenshuai.xi extern int feclearexcept (int __excepts) __THROW; 66*53ee8cc1Swenshuai.xi 67*53ee8cc1Swenshuai.xi /* Store implementation-defined representation of the exception flags 68*53ee8cc1Swenshuai.xi indicated by EXCEPTS in the object pointed to by FLAGP. */ 69*53ee8cc1Swenshuai.xi extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW; 70*53ee8cc1Swenshuai.xi 71*53ee8cc1Swenshuai.xi /* Raise the supported exceptions represented by EXCEPTS. */ 72*53ee8cc1Swenshuai.xi extern int feraiseexcept (int __excepts) __THROW; 73*53ee8cc1Swenshuai.xi 74*53ee8cc1Swenshuai.xi /* Set complete status for exceptions indicated by EXCEPTS according to 75*53ee8cc1Swenshuai.xi the representation in the object pointed to by FLAGP. */ 76*53ee8cc1Swenshuai.xi extern int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW; 77*53ee8cc1Swenshuai.xi 78*53ee8cc1Swenshuai.xi /* Determine which of subset of the exceptions specified by EXCEPTS are 79*53ee8cc1Swenshuai.xi currently set. */ 80*53ee8cc1Swenshuai.xi extern int fetestexcept (int __excepts) __THROW; 81*53ee8cc1Swenshuai.xi 82*53ee8cc1Swenshuai.xi 83*53ee8cc1Swenshuai.xi /* Rounding control. */ 84*53ee8cc1Swenshuai.xi 85*53ee8cc1Swenshuai.xi /* Get current rounding direction. */ 86*53ee8cc1Swenshuai.xi extern int fegetround (void) __THROW; 87*53ee8cc1Swenshuai.xi 88*53ee8cc1Swenshuai.xi /* Establish the rounding direction represented by ROUND. */ 89*53ee8cc1Swenshuai.xi extern int fesetround (int __rounding_direction) __THROW; 90*53ee8cc1Swenshuai.xi 91*53ee8cc1Swenshuai.xi 92*53ee8cc1Swenshuai.xi /* Floating-point environment. */ 93*53ee8cc1Swenshuai.xi 94*53ee8cc1Swenshuai.xi /* Store the current floating-point environment in the object pointed 95*53ee8cc1Swenshuai.xi to by ENVP. */ 96*53ee8cc1Swenshuai.xi extern int fegetenv (fenv_t *__envp) __THROW; 97*53ee8cc1Swenshuai.xi 98*53ee8cc1Swenshuai.xi /* Save the current environment in the object pointed to by ENVP, clear 99*53ee8cc1Swenshuai.xi exception flags and install a non-stop mode (if available) for all 100*53ee8cc1Swenshuai.xi exceptions. */ 101*53ee8cc1Swenshuai.xi extern int feholdexcept (fenv_t *__envp) __THROW; 102*53ee8cc1Swenshuai.xi 103*53ee8cc1Swenshuai.xi /* Establish the floating-point environment represented by the object 104*53ee8cc1Swenshuai.xi pointed to by ENVP. */ 105*53ee8cc1Swenshuai.xi extern int fesetenv (__const fenv_t *__envp) __THROW; 106*53ee8cc1Swenshuai.xi 107*53ee8cc1Swenshuai.xi /* Save current exceptions in temporary storage, install environment 108*53ee8cc1Swenshuai.xi represented by object pointed to by ENVP and raise exceptions 109*53ee8cc1Swenshuai.xi according to saved exceptions. */ 110*53ee8cc1Swenshuai.xi extern int feupdateenv (__const fenv_t *__envp) __THROW; 111*53ee8cc1Swenshuai.xi 112*53ee8cc1Swenshuai.xi 113*53ee8cc1Swenshuai.xi /* Include optimization. */ 114*53ee8cc1Swenshuai.xi #ifdef __OPTIMIZE__ 115*53ee8cc1Swenshuai.xi # include <bits/fenvinline.h> 116*53ee8cc1Swenshuai.xi #endif 117*53ee8cc1Swenshuai.xi 118*53ee8cc1Swenshuai.xi #ifdef __USE_GNU 119*53ee8cc1Swenshuai.xi 120*53ee8cc1Swenshuai.xi /* Enable individual exceptions. Will not enable more exceptions than 121*53ee8cc1Swenshuai.xi EXCEPTS specifies. Returns the previous enabled exceptions if all 122*53ee8cc1Swenshuai.xi exceptions are successfully set, otherwise returns -1. */ 123*53ee8cc1Swenshuai.xi extern int feenableexcept (int __excepts) __THROW; 124*53ee8cc1Swenshuai.xi 125*53ee8cc1Swenshuai.xi /* Disable individual exceptions. Will not disable more exceptions than 126*53ee8cc1Swenshuai.xi EXCEPTS specifies. Returns the previous enabled exceptions if all 127*53ee8cc1Swenshuai.xi exceptions are successfully disabled, otherwise returns -1. */ 128*53ee8cc1Swenshuai.xi extern int fedisableexcept (int __excepts) __THROW; 129*53ee8cc1Swenshuai.xi 130*53ee8cc1Swenshuai.xi /* Return enabled exceptions. */ 131*53ee8cc1Swenshuai.xi extern int fegetexcept (void) __THROW; 132*53ee8cc1Swenshuai.xi #endif 133*53ee8cc1Swenshuai.xi 134*53ee8cc1Swenshuai.xi __END_DECLS 135*53ee8cc1Swenshuai.xi 136*53ee8cc1Swenshuai.xi #endif /* fenv.h */ 137