1 /* Floating point environment, OpenRISC version.
2    Copyright (C) 2022 Free Software Foundation, Inc.
3 
4    This file is part of the GNU C Library.
5 
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public License as
8    published by the Free Software Foundation; either version 2.1 of the
9    License, or (at your option) any later version.
10 
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, see
18    <https://www.gnu.org/licenses/>.  */
19 
20 #ifndef _FENV_H
21 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
22 #endif
23 
24 /* Define bits representing exceptions in the FPCSR status word.  */
25 enum
26   {
27     FE_OVERFLOW =
28 #define FE_OVERFLOW	(1 << 3)
29       FE_OVERFLOW,
30     FE_UNDERFLOW =
31 #define FE_UNDERFLOW	(1 << 4)
32       FE_UNDERFLOW,
33     FE_INEXACT =
34 #define FE_INEXACT	(1 << 8)
35       FE_INEXACT,
36     FE_INVALID =
37 #define FE_INVALID	(1 << 9)
38       FE_INVALID,
39     FE_DIVBYZERO =
40 #define FE_DIVBYZERO	(1 << 11)
41       FE_DIVBYZERO,
42   };
43 
44 /* All supported exceptions.  */
45 #define FE_ALL_EXCEPT	\
46 	(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
47 
48 /* Define bits representing rounding modes in the FPCSR Rmode field.  */
49 #define FE_TONEAREST  (0x0 << 1)
50 #define FE_TOWARDZERO (0x1 << 1)
51 #define FE_UPWARD     (0x2 << 1)
52 #define FE_DOWNWARD   (0x3 << 1)
53 
54 /* Type representing exception flags.  */
55 typedef unsigned int fexcept_t;
56 
57 /* Type representing floating-point environment.  */
58 typedef unsigned int fenv_t;
59 
60 /* If the default argument is used we use this value.  */
61 #define FE_DFL_ENV	((const fenv_t *) -1l)
62 
63 #if __GLIBC_USE (IEC_60559_BFP_EXT)
64 /* Type representing floating-point control modes.  */
65 typedef unsigned int femode_t;
66 
67 /* Default floating-point control modes.  */
68 # define FE_DFL_MODE	((const femode_t *) -1L)
69 #endif
70