Back to index

glibc  2.9
fenv.h
Go to the documentation of this file.
00001 /* Copyright (C) 2004, 2005 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 General Public License
00015    along with GCC; see the file COPYING.  If not, write to the Free
00016    Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
00017    02110-1301, USA.  */
00018 
00019 #ifndef _FENV_H
00020 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
00021 #endif
00022 
00023 /* Define bits representing exceptions in the FPU status word.  */
00024 enum
00025   {
00026     FE_INVALID = 1,
00027 #define FE_INVALID FE_INVALID
00028     FE_DIVBYZERO = 2,
00029 #define FE_DIVBYZERO FE_DIVBYZERO
00030     FE_OVERFLOW = 4,
00031 #define FE_OVERFLOW FE_OVERFLOW
00032     FE_UNDERFLOW = 8,
00033 #define FE_UNDERFLOW FE_UNDERFLOW
00034     FE_INEXACT = 16,
00035 #define FE_INEXACT FE_INEXACT
00036   };
00037 
00038 /* Amount to shift by to convert an exception to a mask bit.  */
00039 #define FE_EXCEPT_SHIFT     8
00040 
00041 /* All supported exceptions.  */
00042 #define FE_ALL_EXCEPT       \
00043        (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
00044 
00045 /* VFP supports all of the four defined rounding modes.  */
00046 enum
00047   {
00048     FE_TONEAREST = 0,
00049 #define FE_TONEAREST FE_TONEAREST
00050     FE_UPWARD = 0x400000,
00051 #define FE_UPWARD FE_UPWARD
00052     FE_DOWNWARD = 0x800000,
00053 #define FE_DOWNWARD FE_DOWNWARD
00054     FE_TOWARDZERO = 0xc00000
00055 #define FE_TOWARDZERO FE_TOWARDZERO
00056   };
00057 
00058 /* Type representing exception flags. */
00059 typedef unsigned int fexcept_t;
00060 
00061 /* Type representing floating-point environment.  */
00062 typedef struct
00063   {
00064     unsigned int __cw;
00065   }
00066 fenv_t;
00067 
00068 /* If the default argument is used we use this value.  */
00069 #define FE_DFL_ENV   ((fenv_t *) -1l)
00070 
00071 #ifdef __USE_GNU
00072 /* Floating-point environment where none of the exceptions are masked.  */
00073 # define FE_NOMASK_ENV  ((__const fenv_t *) -2)
00074 #endif