Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / alpha / fpu / bits / fenv.h
blob4dba9b59a008878cb4be1fc516a596e7631ac35b
1 /* Copyright (C) 1997-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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 <http://www.gnu.org/licenses/>. */
18 #ifndef _FENV_H
19 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
20 #endif
23 /* Define the bits representing the exception.
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.
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.
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. */
36 enum
38 #ifdef __USE_GNU
39 FE_DENORMAL =
40 #define FE_DENORMAL (1 << 22)
41 FE_DENORMAL,
42 #endif
44 FE_INEXACT =
45 #define FE_INEXACT (1 << 21)
46 FE_INEXACT,
48 FE_UNDERFLOW =
49 #define FE_UNDERFLOW (1 << 20)
50 FE_UNDERFLOW,
52 FE_OVERFLOW =
53 #define FE_OVERFLOW (1 << 19)
54 FE_OVERFLOW,
56 FE_DIVBYZERO =
57 #define FE_DIVBYZERO (1 << 18)
58 FE_DIVBYZERO,
60 FE_INVALID =
61 #define FE_INVALID (1 << 17)
62 FE_INVALID,
64 FE_ALL_EXCEPT =
65 #define FE_ALL_EXCEPT (0x3f << 17)
66 FE_ALL_EXCEPT
69 /* Alpha chips support all four defined rouding modes.
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
73 this is -fprm d. The default for both is static rounding to nearest.
75 These are shifted down 58 bits from the hardware fpcr because the
76 functions are declared to take integers. */
78 enum
80 FE_TOWARDZERO =
81 #define FE_TOWARDZERO 0
82 FE_TOWARDZERO,
84 FE_DOWNWARD =
85 #define FE_DOWNWARD 1
86 FE_DOWNWARD,
88 FE_TONEAREST =
89 #define FE_TONEAREST 2
90 FE_TONEAREST,
92 FE_UPWARD =
93 #define FE_UPWARD 3
94 FE_UPWARD,
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
103 FE_MAP_DMZ = 1UL << 12, /* Map denorm inputs to zero */
104 #define FE_MAP_DMZ FE_MAP_DMZ
106 FE_MAP_UMZ = 1UL << 13, /* Map underflowed outputs to zero */
107 #define FE_MAP_UMZ FE_MAP_UMZ
109 #endif
111 /* Type representing exception flags. */
112 typedef unsigned long int fexcept_t;
114 /* Type representing floating-point environment. */
115 typedef unsigned long int fenv_t;
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. */
120 #define FE_DFL_ENV ((const fenv_t *) 0x8800000000000000UL)
122 #ifdef __USE_GNU
123 /* Floating-point environment where none of the exceptions are masked. */
124 # define FE_NOMASK_ENV ((const fenv_t *) 0x880000000000003eUL)
126 /* Floating-point environment with (processor-dependent) non-IEEE floating
127 point. In this case, mapping denormals to zero. */
128 # define FE_NONIEEE_ENV ((const fenv_t *) 0x8800000000003000UL)
129 #endif
131 /* The system calls to talk to the kernel's FP code. */
132 extern unsigned long int __ieee_get_fp_control (void) __THROW;
133 extern void __ieee_set_fp_control (unsigned long int __value) __THROW;