1 /* FPU control word bits. SPARC version. 2 Copyright (C) 1997-2025 Free Software Foundation, Inc. 3 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. 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 12 Lesser General Public License for more details. 13 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 <https://www.gnu.org/licenses/>. */ 17 18 #ifndef _FPU_CONTROL_H 19 #define _FPU_CONTROL_H 1 20 21 22 #include <features.h> 23 #include <bits/wordsize.h> 24 25 /* masking of interrupts */ 26 #define _FPU_MASK_IM 0x08000000 27 #define _FPU_MASK_OM 0x04000000 28 #define _FPU_MASK_UM 0x02000000 29 #define _FPU_MASK_ZM 0x01000000 30 #define _FPU_MASK_PM 0x00800000 31 32 /* precision control */ 33 #define _FPU_EXTENDED 0x00000000 /* RECOMMENDED */ 34 #define _FPU_DOUBLE 0x20000000 35 #define _FPU_80BIT 0x30000000 36 #define _FPU_SINGLE 0x10000000 /* DO NOT USE */ 37 38 /* rounding control / Sparc */ 39 #define _FPU_RC_DOWN 0xc0000000 40 #define _FPU_RC_UP 0x80000000 41 #define _FPU_RC_ZERO 0x40000000 42 #define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */ 43 44 #define _FPU_RESERVED 0x303e0000 /* Reserved bits in cw */ 45 46 47 /* Now two recommended cw */ 48 49 /* Linux and IEEE default: 50 - extended precision 51 - rounding to nearest 52 - no exceptions */ 53 #define _FPU_DEFAULT 0x0 54 #define _FPU_IEEE 0x0 55 56 /* Type of the control word. */ 57 typedef unsigned long int fpu_control_t; 58 59 #if __WORDSIZE == 64 60 # define _FPU_GETCW(cw) __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (*&cw)) 61 # define _FPU_SETCW(cw) __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (*&cw)) 62 #else 63 # ifdef __leon__ 64 /* Prevent stfsr from being placed directly after other fp instruction. */ 65 # define _FPU_GETCW(cw) __asm__ __volatile__ ("nop; st %%fsr,%0" : "=m" (*&cw)) 66 # else 67 # define _FPU_GETCW(cw) __asm__ __volatile__ ("st %%fsr,%0" : "=m" (*&cw)) 68 # endif 69 # define _FPU_SETCW(cw) __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (*&cw)) 70 #endif 71 72 /* Default control word set at startup. */ 73 extern fpu_control_t __fpu_control; 74 75 #endif /* fpu_control.h */ 76