1 /* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 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 <http://www.gnu.org/licenses/>. */ 17 18 #ifndef _FENV_H 19 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead." 20 #endif 21 22 /* $cs register number for use in kvx builtins */ 23 #define KVX_SFR_CS 4 24 25 /* Each core of the Coolidge processor has a coprocessor. They share 26 the CS register but have distinct bit-fields for their 27 floating-point environment. This implementation synchronizes them 28 in such a way that they cannot be managed separately. */ 29 30 /* Compute Status ($cs) register contains the following bit-fields for 31 floating-point execption flags. 32 33 Bit-field Condition of the IEEE 754 binary floating-point standard 34 --------- -------------------------------------------------------- 35 IO Invalid Operation 36 DZ Divide by Zero 37 OV Overflow 38 UN Underflow 39 IN Inexact 40 XIO Invalid Operation (coprocessor) 41 XDZ Divide by Zero (coprocessor) 42 XOV Overflow (coprocessor) 43 XUN Underflow (coprocessor) 44 XIN Inexact (coprocessor) */ 45 46 #define _FE_INVALID 0x02 47 #define _FE_DIVBYZERO 0x04 48 #define _FE_OVERFLOW 0x08 49 #define _FE_UNDERFLOW 0x10 50 #define _FE_INEXACT 0x20 51 52 #define _FE_X_INVALID 0x0200 53 #define _FE_X_DIVBYZERO 0x0400 54 #define _FE_X_OVERFLOW 0x0800 55 #define _FE_X_UNDERFLOW 0x1000 56 #define _FE_X_INEXACT 0x2000 57 58 #define FE_INVALID (_FE_INVALID | _FE_X_INVALID) 59 #define FE_DIVBYZERO (_FE_DIVBYZERO | _FE_X_DIVBYZERO) 60 #define FE_OVERFLOW (_FE_OVERFLOW | _FE_X_OVERFLOW) 61 #define FE_UNDERFLOW (_FE_UNDERFLOW | _FE_X_UNDERFLOW) 62 #define FE_INEXACT (_FE_INEXACT | _FE_X_INEXACT) 63 64 #define FE_ALL_EXCEPT (FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW|FE_UNDERFLOW|FE_INEXACT) 65 66 /* Compute Status ($cs) register contains the following bit-fields for 67 floating-point rounding modes. 68 69 Following table describes both the RM and XRM (coproc) bit-fields. 70 71 Value Rounding Mode of the IEEE 754 binary floating-point standard 72 ----- ------------------------------------------------------------ 73 0b00 to nearest even 74 0b01 toward +inf 75 0b10 toward -inf 76 0b11 toward zero */ 77 78 #define _FE_TONEAREST 0 79 #define _FE_UPWARD 1 80 #define _FE_DOWNWARD 2 81 #define _FE_TOWARDZERO 3 82 83 #define _FE_X_TONEAREST 0 84 #define _FE_X_UPWARD 1 85 #define _FE_X_DOWNWARD 2 86 #define _FE_X_TOWARDZERO 3 87 88 89 #define FE_TONEAREST ((_FE_TONEAREST << 16) | (_FE_X_TONEAREST << 20)) 90 #define FE_UPWARD ((_FE_UPWARD << 16) | (_FE_X_UPWARD << 20)) 91 #define FE_DOWNWARD ((_FE_DOWNWARD << 16) | (_FE_X_DOWNWARD << 20)) 92 #define FE_TOWARDZERO ((_FE_TOWARDZERO << 16) | (_FE_X_TOWARDZERO << 20)) 93 94 #define FE_RND_MASK FE_TOWARDZERO 95 96 /* The type representing all floating-point status flags collectively. 97 The environment is simply a copy from the FPU related bits in the 98 CS register, but can be improved in the future. */ 99 typedef unsigned int fexcept_t; 100 /* The type representing the entire floating-point environment. The 101 environment is simply a copy from the FPU related bits in the CS 102 register. */ 103 typedef unsigned int fenv_t; 104 105 extern const fenv_t __fe_dfl_env; 106 #define FE_DFL_ENV __fe_dfl_env 107