1 /* Copyright (C) 2000 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by David Huggins-Daines <dhd@debian.org>
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18 
19 #ifndef _FENV_H
20 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
21 #endif
22 
23 /* Define bits representing the exception.  We use the values of the
24    appropriate enable bits in the FPU status word (which,
25    coincidentally, are the same as the flag bits, but shifted right by
26    27 bits).  */
27 enum
28 {
29   FE_INVALID   = 1<<4, /* V */
30 #define FE_INVALID	FE_INVALID
31   FE_DIVBYZERO = 1<<3, /* Z */
32 #define FE_DIVBYZERO	FE_DIVBYZERO
33   FE_OVERFLOW  = 1<<2, /* O */
34 #define FE_OVERFLOW	FE_OVERFLOW
35   FE_UNDERFLOW = 1<<1, /* U */
36 #define FE_UNDERFLOW	FE_UNDERFLOW
37   FE_INEXACT   = 1<<0, /* I */
38 #define FE_INEXACT	FE_INEXACT
39 };
40 
41 #define FE_ALL_EXCEPT \
42 	(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
43 
44 /* The PA-RISC FPU supports all of the four defined rounding modes.
45    We use the values of the RM field in the floating point status
46    register for the appropriate macros.  */
47 enum
48   {
49     FE_TONEAREST  = 0 << 9,
50 #define FE_TONEAREST	FE_TONEAREST
51     FE_TOWARDZERO = 1 << 9,
52 #define FE_TOWARDZERO	FE_TOWARDZERO
53     FE_UPWARD     = 2 << 9,
54 #define FE_UPWARD	FE_UPWARD
55     FE_DOWNWARD   = 3 << 9,
56 #define FE_DOWNWARD	FE_DOWNWARD
57   };
58 
59 /* Type representing exception flags. */
60 typedef unsigned int fexcept_t;
61 
62 /* Type representing floating-point environment.  This structure
63    corresponds to the layout of the status and exception words in the
64    register file. */
65 typedef struct
66 {
67   unsigned int __status_word;
68   unsigned int __exception[7];
69 } fenv_t;
70 
71 /* If the default argument is used we use this value.  */
72 #define FE_DFL_ENV ((fenv_t *) -1)
73 
74 #ifdef __USE_GNU
75 /* Floating-point environment where none of the exceptions are masked.  */
76 # define FE_NOMASK_ENV	((fenv_t *) -2)
77 #endif
78