Back to index

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