Replace FSF snail mail address with URLs.
[glibc.git] / sysdeps / sparc / fpu / bits / fenv.h
blob2168de58271b403182227dc27c9aee7648661313
1 /* Copyright (C) 1997, 1998, 1999, 2000, 2012 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
22 #include <bits/wordsize.h>
25 /* Define bits representing the exception. We use the bit positions
26 of the appropriate accrued exception bits from the FSR. */
27 enum
29 FE_INVALID = (1 << 9),
30 #define FE_INVALID FE_INVALID
31 FE_OVERFLOW = (1 << 8),
32 #define FE_OVERFLOW FE_OVERFLOW
33 FE_UNDERFLOW = (1 << 7),
34 #define FE_UNDERFLOW FE_UNDERFLOW
35 FE_DIVBYZERO = (1 << 6),
36 #define FE_DIVBYZERO FE_DIVBYZERO
37 FE_INEXACT = (1 << 5)
38 #define FE_INEXACT FE_INEXACT
41 #define FE_ALL_EXCEPT \
42 (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
44 /* The Sparc FPU supports all of the four defined rounding modes. We
45 use again the bit positions in the FPU control word as the values
46 for the appropriate macros. */
47 enum
49 FE_TONEAREST = (0U << 30),
50 #define FE_TONEAREST FE_TONEAREST
51 FE_TOWARDZERO = (1U << 30),
52 #define FE_TOWARDZERO FE_TOWARDZERO
53 FE_UPWARD = (2U << 30),
54 #define FE_UPWARD FE_UPWARD
55 FE_DOWNWARD = (3U << 30)
56 #define FE_DOWNWARD FE_DOWNWARD
59 #define __FE_ROUND_MASK (3U << 30)
62 /* Type representing exception flags. */
63 typedef unsigned long int fexcept_t;
66 /* Type representing floating-point environment. */
67 typedef unsigned long int fenv_t;
69 /* If the default argument is used we use this value. */
70 #define FE_DFL_ENV ((const fenv_t *) -1)
72 #ifdef __USE_GNU
73 /* Floating-point environment where none of the exception is masked. */
74 # define FE_NOMASK_ENV ((const fenv_t *) -2)
75 #endif
77 /* For internal use only: access the fp state register. */
78 #if __WORDSIZE == 64
79 # define __fenv_stfsr(X) __asm__ ("stx %%fsr,%0" : "=m" (X))
80 # define __fenv_ldfsr(X) __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (X))
81 #else
82 # define __fenv_stfsr(X) __asm__ ("st %%fsr,%0" : "=m" (X))
83 # define __fenv_ldfsr(X) __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (X))
84 #endif