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>
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.
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.
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/>. */
20 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
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
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
41 #define FE_ALL_EXCEPT \
42 (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
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. */
49 FE_TONEAREST
= 0 << 9,
50 #define FE_TONEAREST FE_TONEAREST
51 FE_TOWARDZERO
= 1 << 9,
52 #define FE_TOWARDZERO FE_TOWARDZERO
54 #define FE_UPWARD FE_UPWARD
56 #define FE_DOWNWARD FE_DOWNWARD
59 /* Type representing exception flags. */
60 typedef unsigned int fexcept_t
;
62 /* Type representing floating-point environment. This structure
63 corresponds to the layout of the status and exception words in the
64 register file. The exception registers are never saved/stored by
65 userspace. This structure is also not correctly aligned ever, in
66 an ABI error we left out __aligned(8) and subsequently all of our
67 fenv functions must accept unaligned input, align the input, and
68 then use assembly to store fr0. This is a performance hit, but
69 means the ABI is stable. */
72 unsigned int __status_word
;
73 unsigned int __exception
[7];
76 /* If the default argument is used we use this value. */
77 #define FE_DFL_ENV ((fenv_t *) -1)
80 /* Floating-point environment where none of the exceptions are masked. */
81 # define FE_NOMASK_ENV ((fenv_t *) -2)