1 /* Copyright (C) 1998-2025 Free Software Foundation, Inc. 2 3 The GNU C Library is free software; you can redistribute it and/or 4 modify it under the terms of the GNU Lesser General Public 5 License as published by the Free Software Foundation; either 6 version 2.1 of the License, or (at your option) any later version. 7 8 The GNU C Library is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public 14 License along with the GNU C Library. If not, see 15 <https://www.gnu.org/licenses/>. */ 16 17 #ifndef _FENV_H 18 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead." 19 #endif 20 21 22 #ifdef __mips_hard_float 23 24 /* Define bits representing the exception. We use the bit positions 25 of the appropriate bits in the FPU control word. */ 26 enum 27 { 28 FE_INEXACT = 29 # define FE_INEXACT 0x04 30 FE_INEXACT, 31 FE_UNDERFLOW = 32 # define FE_UNDERFLOW 0x08 33 FE_UNDERFLOW, 34 FE_OVERFLOW = 35 # define FE_OVERFLOW 0x10 36 FE_OVERFLOW, 37 FE_DIVBYZERO = 38 # define FE_DIVBYZERO 0x20 39 FE_DIVBYZERO, 40 FE_INVALID = 41 # define FE_INVALID 0x40 42 FE_INVALID, 43 }; 44 45 # define FE_ALL_EXCEPT \ 46 (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID) 47 48 /* The MIPS FPU supports all of the four defined rounding modes. We 49 use again the bit positions in the FPU control word as the values 50 for the appropriate macros. */ 51 enum 52 { 53 FE_TONEAREST = 54 # define FE_TONEAREST 0x0 55 FE_TONEAREST, 56 FE_TOWARDZERO = 57 # define FE_TOWARDZERO 0x1 58 FE_TOWARDZERO, 59 FE_UPWARD = 60 # define FE_UPWARD 0x2 61 FE_UPWARD, 62 FE_DOWNWARD = 63 # define FE_DOWNWARD 0x3 64 FE_DOWNWARD 65 }; 66 67 #else 68 69 /* In the soft-float case, only rounding to nearest is supported, with 70 no exceptions. */ 71 72 enum 73 { 74 __FE_UNDEFINED = -1, 75 76 FE_TONEAREST = 77 # define FE_TONEAREST 0x0 78 FE_TONEAREST 79 }; 80 81 # define FE_ALL_EXCEPT 0 82 83 #endif 84 85 86 /* Type representing exception flags. */ 87 typedef unsigned short int fexcept_t; 88 89 90 /* Type representing floating-point environment. This function corresponds 91 to the layout of the block written by the `fstenv'. */ 92 typedef struct 93 { 94 unsigned int __fp_control_register; 95 } 96 fenv_t; 97 98 /* If the default argument is used we use this value. */ 99 #define FE_DFL_ENV ((const fenv_t *) -1) 100 101 #if defined __USE_GNU && defined __mips_hard_float 102 /* Floating-point environment where none of the exception is masked. */ 103 # define FE_NOMASK_ENV ((const fenv_t *) -2) 104 #endif 105 106 /* Type representing floating-point control modes. */ 107 typedef unsigned int femode_t; 108 109 /* Default floating-point control modes. */ 110 # define FE_DFL_MODE ((const femode_t *) -1L) 111