1 /* Copyright (C) 2000-2022 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3 
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8 
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13 
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <https://www.gnu.org/licenses/>.  */
17 
18 #ifndef _FENV_H
19 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
20 #endif
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_INVALID =
27 #define FE_INVALID	0x80
28       FE_INVALID,
29     FE_DIVBYZERO =
30 #define FE_DIVBYZERO	0x40
31       FE_DIVBYZERO,
32     FE_OVERFLOW =
33 #define FE_OVERFLOW	0x20
34       FE_OVERFLOW,
35     FE_UNDERFLOW =
36 #define FE_UNDERFLOW	0x10
37       FE_UNDERFLOW,
38     FE_INEXACT =
39 #define FE_INEXACT	0x08
40       FE_INEXACT
41   };
42 /* We dont use the y bit of the DXC in the floating point control register
43    as glibc has no FE encoding for fe inexact incremented
44    or fe inexact truncated.
45    We currently  use the flag bits in the fpc
46    as these are sticky for feholdenv & feupdatenv as it is defined
47    in the HP Manpages.  */
48 
49 
50 #define FE_ALL_EXCEPT \
51 	(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
52 
53 enum
54   {
55     FE_TONEAREST =
56 #define FE_TONEAREST	0
57       FE_TONEAREST,
58     FE_DOWNWARD =
59 #define FE_DOWNWARD	0x3
60       FE_DOWNWARD,
61     FE_UPWARD =
62 #define FE_UPWARD	0x2
63       FE_UPWARD,
64     FE_TOWARDZERO =
65 #define FE_TOWARDZERO	0x1
66       FE_TOWARDZERO
67   };
68 
69 
70 /* Type representing exception flags.  */
71 typedef unsigned int fexcept_t; /* size of fpc */
72 
73 
74 /* Type representing floating-point environment.  This function corresponds
75    to the layout of the block used by fegetenv and fesetenv.  */
76 typedef struct
77 {
78   fexcept_t __fpc;
79   void *__unused;
80   /* The field __unused (formerly __ieee_instruction_pointer) is a relict from
81      commit "Remove PTRACE_PEEKUSER" (87b9b50f0d4b92248905e95a06a13c513dc45e59)
82      and isn't used anymore.  */
83 } fenv_t;
84 
85 /* If the default argument is used we use this value.  */
86 #define FE_DFL_ENV	((const fenv_t *) -1)
87 
88 #ifdef __USE_GNU
89 /* Floating-point environment where none of the exceptions are masked.  */
90 # define FE_NOMASK_ENV	((const fenv_t *) -2)
91 #endif
92 
93 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
94 /* Type representing floating-point control modes.  */
95 typedef unsigned int femode_t;
96 
97 /* Default floating-point control modes.  */
98 # define FE_DFL_MODE	((const femode_t *) -1L)
99 #endif
100