1 /* Copyright (C) 2004-2012 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 License as
5    published by the Free Software Foundation; either version 2.1 of the
6    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    <http://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 /* Define bits representing exceptions in the FPCSR status word.  */
22 enum
23   {
24     FE_INVALID =
25 #define FE_INVALID	0x4
26       FE_INVALID,
27     FE_DIVBYZERO =
28 #define FE_DIVBYZERO	0x8
29       FE_DIVBYZERO,
30     FE_OVERFLOW =
31 #define FE_OVERFLOW	0x10
32       FE_OVERFLOW,
33     FE_UNDERFLOW =
34 #define FE_UNDERFLOW	0x20
35       FE_UNDERFLOW,
36     FE_INEXACT =
37 #define FE_INEXACT	0x40
38       FE_INEXACT,
39   };
40 
41 
42 /* All supported exceptions.  */
43 #define FE_ALL_EXCEPT	\
44 	(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
45 
46 /* Define bits representing rounding modes in the FPCSR RM field.  */
47 enum
48   {
49     FE_TONEAREST =
50 #define FE_TONEAREST    0x0
51       FE_TONEAREST,
52     FE_UPWARD =
53 #define FE_UPWARD       0x1
54       FE_UPWARD,
55     FE_DOWNWARD =
56 #define FE_DOWNWARD     0x2
57       FE_DOWNWARD,
58     FE_TOWARDZERO =
59 #define FE_TOWARDZERO   0x3
60       FE_TOWARDZERO
61   };
62 
63 /* Type representing exception flags. */
64 typedef unsigned int fexcept_t;
65 
66 /* Type representing floating-point environment.  */
67 typedef struct
68   {
69     unsigned int __fpcsr;
70   }
71 fenv_t;
72 
73 /* If the default argument is used we use this value.  */
74 #define FE_DFL_ENV	((const fenv_t *) -1l)
75 
76 #ifdef __USE_GNU
77 /* Floating-point environment where none of the exceptions are masked.  */
78 # define FE_NOMASK_ENV  ((const fenv_t *) -2)
79 #endif
80