1 /* Copyright (C) 1999-2025 Free Software Foundation, Inc.
2 
3    The GNU C Library is free software; you can redistribute it and/or
4    modify it under the terms of the GNU Lesser General Public
5    License as published by the Free Software Foundation; either
6    version 2.1 of the License, or (at your option) any later version.
7 
8    The GNU C Library is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11    Lesser General Public License for more details.
12 
13    You should have received a copy of the GNU Lesser General Public
14    License along with the GNU C Library; if not, see
15    <https://www.gnu.org/licenses/>.  */
16 
17 #ifndef _FENV_H
18 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
19 #endif
20 
21 
22 /* Define bits representing the exception.  We use the bit positions
23    of the appropriate bits in the FPU control word.  */
24 enum
25   {
26     FE_INEXACT =
27 #define FE_INEXACT	0x04
28       FE_INEXACT,
29     FE_UNDERFLOW =
30 #define FE_UNDERFLOW	0x08
31       FE_UNDERFLOW,
32     FE_OVERFLOW =
33 #define FE_OVERFLOW	0x10
34       FE_OVERFLOW,
35     FE_DIVBYZERO =
36 #define FE_DIVBYZERO	0x20
37       FE_DIVBYZERO,
38     FE_INVALID =
39 #define FE_INVALID	0x40
40       FE_INVALID,
41   };
42 
43 #define FE_ALL_EXCEPT \
44 	(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
45 
46 /* The SH FPU supports two of the four defined rounding modes: round to nearest
47    and round to zero.  We use again the bit positions in the FPU control word
48    as the values for the appropriate macros.  */
49 enum
50   {
51     __FE_UNDEFINED = -1,
52 
53     FE_TONEAREST =
54 #define FE_TONEAREST	0x0
55       FE_TONEAREST,
56     FE_TOWARDZERO =
57 #define FE_TOWARDZERO	0x1
58       FE_TOWARDZERO,
59   };
60 
61 
62 /* Type representing exception flags.  */
63 typedef unsigned short int fexcept_t;
64 
65 
66 /* Type representing floating-point environment.  This function corresponds
67    to the layout of the block written by the `fstenv'.  */
68 typedef struct
69   {
70     unsigned int __fpscr;
71   }
72 fenv_t;
73 
74 /* If the default argument is used we use this value.  */
75 #define FE_DFL_ENV	((const fenv_t *) -1)
76 
77 /* Type representing floating-point control modes.  */
78 typedef unsigned int femode_t;
79 
80 /* Default floating-point control modes.  */
81 # define FE_DFL_MODE	((const femode_t *) -1L)
82