Back to index

glibc  2.9
fenv.h
Go to the documentation of this file.
00001 /* Copyright (C) 2000 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com).
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _FENV_H
00021 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
00022 #endif
00023 
00024 /* Define bits representing the exception.  We use the bit positions
00025    of the appropriate bits in the FPU control word.  */
00026 enum
00027   {
00028     FE_INVALID = 0x80,
00029 #define FE_INVALID   FE_INVALID
00030     FE_DIVBYZERO = 0x40,
00031 #define FE_DIVBYZERO FE_DIVBYZERO
00032     FE_OVERFLOW = 0x20,
00033 #define FE_OVERFLOW  FE_OVERFLOW
00034     FE_UNDERFLOW = 0x10,
00035 #define FE_UNDERFLOW FE_UNDERFLOW
00036     FE_INEXACT = 0x08
00037 #define FE_INEXACT   FE_INEXACT
00038   };
00039 /* We dont use the y bit of the DXC in the floating point control register
00040    as glibc has no FE encoding for fe inexact incremented
00041    or fe inexact truncated.
00042    We currently  use the flag bits in the fpc
00043    as these are sticky for feholdenv & feupdatenv as it is defined
00044    in the HP Manpages.  */
00045 
00046 
00047 #define FE_ALL_EXCEPT \
00048        (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
00049 
00050 enum
00051   {
00052     FE_TONEAREST = 0,
00053 #define FE_TONEAREST FE_TONEAREST
00054     FE_DOWNWARD = 0x3,
00055 #define FE_DOWNWARD  FE_DOWNWARD
00056     FE_UPWARD = 0x2,
00057 #define FE_UPWARD    FE_UPWARD
00058     FE_TOWARDZERO = 0x1
00059 #define FE_TOWARDZERO       FE_TOWARDZERO
00060   };
00061 
00062 
00063 /* Type representing exception flags.  */
00064 typedef unsigned int fexcept_t; /* size of fpc */
00065 
00066 
00067 /* Type representing floating-point environment.  This function corresponds
00068    to the layout of the block written by the `fstenv'.  */
00069 typedef struct
00070 {
00071   fexcept_t fpc;
00072   void *ieee_instruction_pointer;
00073   /* failing instruction for ieee exceptions */
00074 } fenv_t;
00075 
00076 /* If the default argument is used we use this value.  */
00077 #define FE_DFL_ENV   ((__const fenv_t *) -1)
00078 
00079 #ifdef __USE_GNU
00080 /* Floating-point environment where none of the exceptions are masked.  */
00081 # define FE_NOMASK_ENV      ((__const fenv_t *) -2)
00082 #endif