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 David Huggins-Daines <dhd@debian.org>
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 values of the
00025    appropriate enable bits in the FPU status word (which,
00026    coincidentally, are the same as the flag bits, but shifted right by
00027    27 bits).  */
00028 enum
00029 {
00030   FE_INVALID   = 1<<4, /* V */
00031 #define FE_INVALID   FE_INVALID
00032   FE_DIVBYZERO = 1<<3, /* Z */
00033 #define FE_DIVBYZERO FE_DIVBYZERO
00034   FE_OVERFLOW  = 1<<2, /* O */
00035 #define FE_OVERFLOW  FE_OVERFLOW
00036   FE_UNDERFLOW = 1<<1, /* U */
00037 #define FE_UNDERFLOW FE_UNDERFLOW
00038   FE_INEXACT   = 1<<0, /* I */
00039 #define FE_INEXACT   FE_INEXACT
00040 };
00041 
00042 #define FE_ALL_EXCEPT \
00043        (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
00044 
00045 /* The PA-RISC FPU supports all of the four defined rounding modes.
00046    We use the values of the RM field in the floating point status
00047    register for the appropriate macros.  */
00048 enum
00049   {
00050     FE_TONEAREST  = 0 << 9,
00051 #define FE_TONEAREST FE_TONEAREST
00052     FE_TOWARDZERO = 1 << 9,
00053 #define FE_TOWARDZERO       FE_TOWARDZERO
00054     FE_UPWARD     = 2 << 9,
00055 #define FE_UPWARD    FE_UPWARD
00056     FE_DOWNWARD   = 3 << 9,
00057 #define FE_DOWNWARD  FE_DOWNWARD
00058   };
00059 
00060 /* Type representing exception flags. */
00061 typedef unsigned int fexcept_t;
00062 
00063 /* Type representing floating-point environment.  This structure
00064    corresponds to the layout of the status and exception words in the
00065    register file. The exception registers are never saved/stored by
00066    userspace. This structure is also not correctly aligned ever, in
00067    an ABI error we left out __aligned(8) and subsequently all of our
00068    fenv functions must accept unaligned input, align the input, and
00069    then use assembly to store fr0. This is a performance hit, but 
00070    means the ABI is stable. */
00071 typedef struct
00072 {
00073   unsigned int __status_word;
00074   unsigned int __exception[7];
00075 } fenv_t;
00076 
00077 /* If the default argument is used we use this value.  */
00078 #define FE_DFL_ENV ((fenv_t *) -1)
00079 
00080 #ifdef __USE_GNU
00081 /* Floating-point environment where none of the exceptions are masked.  */
00082 # define FE_NOMASK_ENV      ((fenv_t *) -2)
00083 #endif