]>
Commit | Line | Data |
---|---|---|
dff8da6b | 1 | /* Copyright (C) 1997-2024 Free Software Foundation, Inc. |
dc75d9cb | 2 | This file is part of the GNU C Library. |
dc75d9cb UD |
3 | |
4 | The GNU C Library is free software; you can redistribute it and/or | |
3214b89b AJ |
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. | |
dc75d9cb UD |
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 | |
3214b89b | 12 | Lesser General Public License for more details. |
dc75d9cb | 13 | |
3214b89b | 14 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff | 15 | License along with the GNU C Library. If not, see |
5a82c748 | 16 | <https://www.gnu.org/licenses/>. */ |
dc75d9cb UD |
17 | |
18 | #ifndef _FENV_H | |
90571408 | 19 | # error "Never use <bits/fenv.h> directly; include <fenv.h> instead." |
dc75d9cb UD |
20 | #endif |
21 | ||
22 | ||
23 | /* Define the bits representing the exception. | |
24 | ||
25 | Note that these are the bit positions as defined by the OSF/1 | |
26 | ieee_{get,set}_control_word interface and not by the hardware fpcr. | |
27 | ||
28 | See the Alpha Architecture Handbook section 4.7.7.3 for details, | |
29 | but in summary, trap shadows mean the hardware register can acquire | |
30 | extra exception bits so for proper IEEE support the tracking has to | |
31 | be done in software -- in this case with kernel support. | |
32 | ||
33 | As to why the system call interface isn't in the same format as | |
34 | the hardware register, only those crazy folks at DEC can tell you. */ | |
35 | ||
36 | enum | |
37 | { | |
18297532 | 38 | #ifdef __USE_GNU |
fbeafede JM |
39 | FE_DENORMAL = |
40 | #define FE_DENORMAL (1 << 22) | |
41 | FE_DENORMAL, | |
18297532 UD |
42 | #endif |
43 | ||
fbeafede JM |
44 | FE_INEXACT = |
45 | #define FE_INEXACT (1 << 21) | |
46 | FE_INEXACT, | |
dc75d9cb | 47 | |
fbeafede JM |
48 | FE_UNDERFLOW = |
49 | #define FE_UNDERFLOW (1 << 20) | |
50 | FE_UNDERFLOW, | |
dc75d9cb | 51 | |
fbeafede JM |
52 | FE_OVERFLOW = |
53 | #define FE_OVERFLOW (1 << 19) | |
54 | FE_OVERFLOW, | |
dc75d9cb | 55 | |
fbeafede JM |
56 | FE_DIVBYZERO = |
57 | #define FE_DIVBYZERO (1 << 18) | |
58 | FE_DIVBYZERO, | |
dc75d9cb | 59 | |
fbeafede JM |
60 | FE_INVALID = |
61 | #define FE_INVALID (1 << 17) | |
62 | FE_INVALID, | |
90571408 | 63 | |
fbeafede JM |
64 | FE_ALL_EXCEPT = |
65 | #define FE_ALL_EXCEPT (0x3f << 17) | |
66 | FE_ALL_EXCEPT | |
dc75d9cb UD |
67 | }; |
68 | ||
65cc53fe | 69 | /* Alpha chips support all four defined rounding modes. |
dc75d9cb UD |
70 | |
71 | Note that code must be compiled to use dynamic rounding (/d) instructions | |
72 | to see these changes. For gcc this is -mfp-rounding-mode=d; for DEC cc | |
90571408 | 73 | this is -fprm d. The default for both is static rounding to nearest. |
dc75d9cb | 74 | |
90571408 | 75 | These are shifted down 58 bits from the hardware fpcr because the |
dc75d9cb UD |
76 | functions are declared to take integers. */ |
77 | ||
78 | enum | |
79 | { | |
fbeafede JM |
80 | FE_TOWARDZERO = |
81 | #define FE_TOWARDZERO 0 | |
82 | FE_TOWARDZERO, | |
dc75d9cb | 83 | |
fbeafede JM |
84 | FE_DOWNWARD = |
85 | #define FE_DOWNWARD 1 | |
86 | FE_DOWNWARD, | |
dc75d9cb | 87 | |
fbeafede JM |
88 | FE_TONEAREST = |
89 | #define FE_TONEAREST 2 | |
90 | FE_TONEAREST, | |
dc75d9cb | 91 | |
fbeafede JM |
92 | FE_UPWARD = |
93 | #define FE_UPWARD 3 | |
94 | FE_UPWARD, | |
dc75d9cb UD |
95 | }; |
96 | ||
18297532 UD |
97 | #ifdef __USE_GNU |
98 | /* On later hardware, and later kernels for earlier hardware, we can forcibly | |
99 | underflow denormal inputs and outputs. This can speed up certain programs | |
100 | significantly, usually without affecting accuracy. */ | |
101 | enum | |
102 | { | |
103 | FE_MAP_DMZ = 1UL << 12, /* Map denorm inputs to zero */ | |
104 | #define FE_MAP_DMZ FE_MAP_DMZ | |
105 | ||
106 | FE_MAP_UMZ = 1UL << 13, /* Map underflowed outputs to zero */ | |
107 | #define FE_MAP_UMZ FE_MAP_UMZ | |
108 | }; | |
109 | #endif | |
dc75d9cb UD |
110 | |
111 | /* Type representing exception flags. */ | |
d31690f1 | 112 | typedef unsigned long int fexcept_t; |
dc75d9cb UD |
113 | |
114 | /* Type representing floating-point environment. */ | |
d31690f1 | 115 | typedef unsigned long int fenv_t; |
dc75d9cb UD |
116 | |
117 | /* If the default argument is used we use this value. Note that due to | |
118 | architecture-specified page mappings, no user-space pointer will ever | |
119 | have its two high bits set. Co-opt one. */ | |
24d6e175 | 120 | #define FE_DFL_ENV ((const fenv_t *) 0x8800000000000000UL) |
dc75d9cb UD |
121 | |
122 | #ifdef __USE_GNU | |
123 | /* Floating-point environment where none of the exceptions are masked. */ | |
24d6e175 | 124 | # define FE_NOMASK_ENV ((const fenv_t *) 0x880000000000003eUL) |
18297532 UD |
125 | |
126 | /* Floating-point environment with (processor-dependent) non-IEEE floating | |
127 | point. In this case, mapping denormals to zero. */ | |
24d6e175 | 128 | # define FE_NONIEEE_ENV ((const fenv_t *) 0x8800000000003000UL) |
dc75d9cb UD |
129 | #endif |
130 | ||
131 | /* The system calls to talk to the kernel's FP code. */ | |
d41b66ce AJ |
132 | extern unsigned long int __ieee_get_fp_control (void) __THROW; |
133 | extern void __ieee_set_fp_control (unsigned long int __value) __THROW; | |
ec94343f | 134 | |
42cc619d | 135 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C23) |
ec94343f JM |
136 | /* Type representing floating-point control modes. */ |
137 | typedef unsigned long int femode_t; | |
138 | ||
139 | /* Default floating-point control modes. */ | |
140 | # define FE_DFL_MODE ((const femode_t *) 0x8800000000000000UL) | |
141 | #endif |