Back to index

glibc  2.9
fenv.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /*
00020  * ISO C99 7.6: Floating-point environment       <fenv.h>
00021  */
00022 
00023 #ifndef _FENV_H
00024 #define _FENV_H      1
00025 
00026 #include <features.h>
00027 
00028 /* Get the architecture dependend definitions.  The following definitions
00029    are expected to be done:
00030 
00031    fenv_t     type for object representing an entire floating-point
00032               environment
00033 
00034    FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument
00035               to functions taking an argument of type fenv_t; in this
00036               case the default environment will be used
00037 
00038    fexcept_t  type for object representing the floating-point exception
00039               flags including status associated with the flags
00040 
00041    The following macros are defined iff the implementation supports this
00042    kind of exception.
00043    FE_INEXACT        inexact result
00044    FE_DIVBYZERO             division by zero
00045    FE_UNDERFLOW             result not representable due to underflow
00046    FE_OVERFLOW              result not representable due to overflow
00047    FE_INVALID        invalid operation
00048 
00049    FE_ALL_EXCEPT     bitwise OR of all supported exceptions
00050 
00051    The next macros are defined iff the appropriate rounding mode is
00052    supported by the implementation.
00053    FE_TONEAREST             round to nearest
00054    FE_UPWARD         round toward +Inf
00055    FE_DOWNWARD              round toward -Inf
00056    FE_TOWARDZERO     round toward 0
00057 */
00058 #include <bits/fenv.h>
00059 
00060 __BEGIN_DECLS
00061 
00062 /* Floating-point exception handling.  */
00063 
00064 /* Clear the supported exceptions represented by EXCEPTS.  */
00065 extern int feclearexcept (int __excepts) __THROW;
00066 
00067 /* Store implementation-defined representation of the exception flags
00068    indicated by EXCEPTS in the object pointed to by FLAGP.  */
00069 extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
00070 
00071 /* Raise the supported exceptions represented by EXCEPTS.  */
00072 extern int feraiseexcept (int __excepts) __THROW;
00073 
00074 /* Set complete status for exceptions indicated by EXCEPTS according to
00075    the representation in the object pointed to by FLAGP.  */
00076 extern int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW;
00077 
00078 /* Determine which of subset of the exceptions specified by EXCEPTS are
00079    currently set.  */
00080 extern int fetestexcept (int __excepts) __THROW;
00081 
00082 
00083 /* Rounding control.  */
00084 
00085 /* Get current rounding direction.  */
00086 extern int fegetround (void) __THROW;
00087 
00088 /* Establish the rounding direction represented by ROUND.  */
00089 extern int fesetround (int __rounding_direction) __THROW;
00090 
00091 
00092 /* Floating-point environment.  */
00093 
00094 /* Store the current floating-point environment in the object pointed
00095    to by ENVP.  */
00096 extern int fegetenv (fenv_t *__envp) __THROW;
00097 
00098 /* Save the current environment in the object pointed to by ENVP, clear
00099    exception flags and install a non-stop mode (if available) for all
00100    exceptions.  */
00101 extern int feholdexcept (fenv_t *__envp) __THROW;
00102 
00103 /* Establish the floating-point environment represented by the object
00104    pointed to by ENVP.  */
00105 extern int fesetenv (__const fenv_t *__envp) __THROW;
00106 
00107 /* Save current exceptions in temporary storage, install environment
00108    represented by object pointed to by ENVP and raise exceptions
00109    according to saved exceptions.  */
00110 extern int feupdateenv (__const fenv_t *__envp) __THROW;
00111 
00112 
00113 /* Include optimization.  */
00114 #ifdef __OPTIMIZE__
00115 # include <bits/fenvinline.h>
00116 #endif
00117 
00118 #ifdef __USE_GNU
00119 
00120 /* Enable individual exceptions.  Will not enable more exceptions than
00121    EXCEPTS specifies.  Returns the previous enabled exceptions if all
00122    exceptions are successfully set, otherwise returns -1.  */
00123 extern int feenableexcept (int __excepts) __THROW;
00124 
00125 /* Disable individual exceptions.  Will not disable more exceptions than
00126    EXCEPTS specifies.  Returns the previous enabled exceptions if all
00127    exceptions are successfully disabled, otherwise returns -1.  */
00128 extern int fedisableexcept (int __excepts) __THROW;
00129 
00130 /* Return enabled exceptions.  */
00131 extern int fegetexcept (void) __THROW;
00132 #endif
00133 
00134 __END_DECLS
00135 
00136 #endif /* fenv.h */