test-container: add "su" command to run test as root, add unshare hints
[glibc.git] / sysdeps / powerpc / fpu_control.h
blob9d0698b4fc3eb5956023469916585a0c005ae1ab
1 /* FPU control word definitions. PowerPC version.
2 Copyright (C) 1996-2018 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 #ifdef _SOFT_FLOAT
24 # define _FPU_RESERVED 0xffffffff
25 # define _FPU_DEFAULT 0x00000000 /* Default value. */
26 typedef unsigned int fpu_control_t;
27 # define _FPU_GETCW(cw) (cw) = 0
28 # define _FPU_SETCW(cw) (void) (cw)
29 extern fpu_control_t __fpu_control;
31 #elif defined __NO_FPRS__ /* e500 */
33 /* rounding control */
34 # define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
35 # define _FPU_RC_DOWN 0x03
36 # define _FPU_RC_UP 0x02
37 # define _FPU_RC_ZERO 0x01
39 /* masking of interrupts */
40 # define _FPU_MASK_ZM 0x10 /* zero divide */
41 # define _FPU_MASK_OM 0x04 /* overflow */
42 # define _FPU_MASK_UM 0x08 /* underflow */
43 # define _FPU_MASK_XM 0x40 /* inexact */
44 # define _FPU_MASK_IM 0x20 /* invalid operation */
46 # define _FPU_RESERVED 0x00c10080 /* These bits are reserved and not changed. */
48 /* Correct IEEE semantics require traps to be enabled at the hardware
49 level; the kernel then does the emulation and determines whether
50 generation of signals from those traps was enabled using prctl. */
51 # define _FPU_DEFAULT 0x0000003c /* Default value. */
52 # define _FPU_IEEE _FPU_DEFAULT
54 /* Type of the control word. */
55 typedef unsigned int fpu_control_t;
57 /* Macros for accessing the hardware control word. */
58 # define _FPU_GETCW(cw) \
59 __asm__ volatile ("mfspefscr %0" : "=r" (cw))
60 # define _FPU_SETCW(cw) \
61 __asm__ volatile ("mtspefscr %0" : : "r" (cw))
63 /* Default control word set at startup. */
64 extern fpu_control_t __fpu_control;
66 #else /* PowerPC 6xx floating-point. */
68 /* rounding control */
69 # define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */
70 # define _FPU_RC_DOWN 0x03
71 # define _FPU_RC_UP 0x02
72 # define _FPU_RC_ZERO 0x01
74 # define _FPU_MASK_NI 0x04 /* non-ieee mode */
76 /* masking of interrupts */
77 # define _FPU_MASK_ZM 0x10 /* zero divide */
78 # define _FPU_MASK_OM 0x40 /* overflow */
79 # define _FPU_MASK_UM 0x20 /* underflow */
80 # define _FPU_MASK_XM 0x08 /* inexact */
81 # define _FPU_MASK_IM 0x80 /* invalid operation */
83 # define _FPU_RESERVED 0xffffff00 /* These bits are reserved are not changed. */
85 /* The fdlibm code requires no interrupts for exceptions. */
86 # define _FPU_DEFAULT 0x00000000 /* Default value. */
88 /* IEEE: same as above, but (some) exceptions;
89 we leave the 'inexact' exception off.
91 # define _FPU_IEEE 0x000000f0
93 /* Type of the control word. */
94 typedef unsigned int fpu_control_t;
96 /* Macros for accessing the hardware control word. */
97 # define _FPU_GETCW(cw) \
98 ({union { double __d; unsigned long long __ll; } __u; \
99 register double __fr; \
100 __asm__ ("mffs %0" : "=f" (__fr)); \
101 __u.__d = __fr; \
102 (cw) = (fpu_control_t) __u.__ll; \
103 (fpu_control_t) __u.__ll; \
106 # define _FPU_SETCW(cw) \
107 { union { double __d; unsigned long long __ll; } __u; \
108 register double __fr; \
109 __u.__ll = 0xfff80000LL << 32; /* This is a QNaN. */ \
110 __u.__ll |= (cw) & 0xffffffffLL; \
111 __fr = __u.__d; \
112 __asm__ ("mtfsf 255,%0" : : "f" (__fr)); \
115 /* Default control word set at startup. */
116 extern fpu_control_t __fpu_control;
118 #endif /* PowerPC 6xx floating-point. */
120 #endif /* _FPU_CONTROL_H */