Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / hppa / fpu / fpu_control.h
blob8f855207dfdcde3fa09215d24fcb4d23927736c1
1 /* FPU control word definitions. HP-PARISC version.
2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _FPU_CONTROL_H
20 #define _FPU_CONTROL_H
22 /* Masking of interrupts */
23 #define _FPU_MASK_PM 0x00000001 /* Inexact (I) */
24 #define _FPU_MASK_UM 0x00000002 /* Underflow (U) */
25 #define _FPU_MASK_OM 0x00000004 /* Overflow (O) */
26 #define _FPU_MASK_ZM 0x00000008 /* Divide by zero (Z) */
27 #define _FPU_MASK_IM 0x00000010 /* Invalid operation (V) */
29 /* Masking of rounding modes. */
30 #define _FPU_HPPA_MASK_RM 0x00000600 /* Rounding mode mask */
31 /* Masking of interrupt enable bits. */
32 #define _FPU_HPPA_MASK_INT 0x0000001f /* Interrupt mask */
34 /* There are no reserved bits in the PA fpsr (though some are undefined). */
35 #define _FPU_RESERVED 0x00000000
36 /* Default is: No traps enabled, no flags set, round to nearest. */
37 #define _FPU_DEFAULT 0x00000000
38 /* Default + exceptions (FE_ALL_EXCEPT) enabled. */
39 #define _FPU_IEEE (_FPU_DEFAULT | _FPU_HPPA_MASK_INT)
41 /* Type of the control word. */
42 typedef unsigned int fpu_control_t;
44 /* Macros for accessing the hardware control word. */
45 #define _FPU_GETCW(cw) \
46 ({ \
47 union { __extension__ unsigned long long __fpreg; unsigned int __halfreg[2]; } __fullfp; \
48 /* Get the current status word. */ \
49 __asm__ ("fstd %%fr0,0(%1)\n\t" \
50 "fldd 0(%1),%%fr0\n\t" \
51 : "=m" (__fullfp.__fpreg) : "r" (&__fullfp.__fpreg) : "%r0"); \
52 cw = __fullfp.__halfreg[0]; \
55 #define _FPU_SETCW(cw) \
56 ({ \
57 union { __extension__ unsigned long long __fpreg; unsigned int __halfreg[2]; } __fullfp; \
58 __fullfp.__halfreg[0] = cw; \
59 __asm__ ("fldd 0(%1),%%fr0\n\t" \
60 : : "m" (__fullfp.__fpreg), "r" (&__fullfp.__fpreg) : "%r0" ); \
63 /* Default control word set at startup. */
64 extern fpu_control_t __fpu_control;
66 #endif /* _FPU_CONTROL_H */