Back to index

glibc  2.9
fenv.h
Go to the documentation of this file.
00001 /* Copyright (C) 1997,1998,1999,2000,2001,2004 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 #ifndef _FENV_H
00020 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
00021 #endif
00022 
00023 #include <bits/wordsize.h>
00024 
00025 
00026 /* Define bits representing the exception.  We use the bit positions
00027    of the appropriate bits in the FPU control word.  */
00028 enum
00029   {
00030     FE_INVALID = 0x01,
00031 #define FE_INVALID   FE_INVALID
00032     __FE_DENORM = 0x02,
00033     FE_DIVBYZERO = 0x04,
00034 #define FE_DIVBYZERO FE_DIVBYZERO
00035     FE_OVERFLOW = 0x08,
00036 #define FE_OVERFLOW  FE_OVERFLOW
00037     FE_UNDERFLOW = 0x10,
00038 #define FE_UNDERFLOW FE_UNDERFLOW
00039     FE_INEXACT = 0x20
00040 #define FE_INEXACT   FE_INEXACT
00041   };
00042 
00043 #define FE_ALL_EXCEPT \
00044        (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
00045 
00046 /* The ix87 FPU supports all of the four defined rounding modes.  We
00047    use again the bit positions in the FPU control word as the values
00048    for the appropriate macros.  */
00049 enum
00050   {
00051     FE_TONEAREST = 0,
00052 #define FE_TONEAREST FE_TONEAREST
00053     FE_DOWNWARD = 0x400,
00054 #define FE_DOWNWARD  FE_DOWNWARD
00055     FE_UPWARD = 0x800,
00056 #define FE_UPWARD    FE_UPWARD
00057     FE_TOWARDZERO = 0xc00
00058 #define FE_TOWARDZERO       FE_TOWARDZERO
00059   };
00060 
00061 
00062 /* Type representing exception flags.  */
00063 typedef unsigned short int fexcept_t;
00064 
00065 
00066 /* Type representing floating-point environment.  This structure
00067    corresponds to the layout of the block written by the `fstenv'
00068    instruction and has additional fields for the contents of the MXCSR
00069    register as written by the `stmxcsr' instruction.  */
00070 typedef struct
00071   {
00072     unsigned short int __control_word;
00073     unsigned short int __unused1;
00074     unsigned short int __status_word;
00075     unsigned short int __unused2;
00076     unsigned short int __tags;
00077     unsigned short int __unused3;
00078     unsigned int __eip;
00079     unsigned short int __cs_selector;
00080     unsigned int __opcode:11;
00081     unsigned int __unused4:5;
00082     unsigned int __data_offset;
00083     unsigned short int __data_selector;
00084     unsigned short int __unused5;
00085 #if __WORDSIZE == 64
00086     unsigned int __mxcsr;
00087 #endif
00088   }
00089 fenv_t;
00090 
00091 /* If the default argument is used we use this value.  */
00092 #define FE_DFL_ENV   ((__const fenv_t *) -1)
00093 
00094 #ifdef __USE_GNU
00095 /* Floating-point environment where none of the exception is masked.  */
00096 # define FE_NOMASK_ENV      ((__const fenv_t *) -2)
00097 #endif