1 /* Copyright (C) 2004-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 /* Define bits representing exceptions in the FPU status word. */ 22 enum 23 { 24 FE_INVALID = 25 #define FE_INVALID 1 26 FE_INVALID, 27 FE_DIVBYZERO = 28 #define FE_DIVBYZERO 2 29 FE_DIVBYZERO, 30 FE_OVERFLOW = 31 #define FE_OVERFLOW 4 32 FE_OVERFLOW, 33 FE_UNDERFLOW = 34 #define FE_UNDERFLOW 8 35 FE_UNDERFLOW, 36 FE_INEXACT = 37 #define FE_INEXACT 16 38 FE_INEXACT, 39 }; 40 41 /* Amount to shift by to convert an exception to a mask bit. */ 42 #define FE_EXCEPT_SHIFT 8 43 44 /* All supported exceptions. */ 45 #define FE_ALL_EXCEPT \ 46 (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) 47 48 /* VFP supports all of the four defined rounding modes. */ 49 enum 50 { 51 FE_TONEAREST = 52 #define FE_TONEAREST 0 53 FE_TONEAREST, 54 FE_UPWARD = 55 #define FE_UPWARD 0x400000 56 FE_UPWARD, 57 FE_DOWNWARD = 58 #define FE_DOWNWARD 0x800000 59 FE_DOWNWARD, 60 FE_TOWARDZERO = 61 #define FE_TOWARDZERO 0xc00000 62 FE_TOWARDZERO 63 }; 64 65 /* Type representing exception flags. */ 66 typedef unsigned int fexcept_t; 67 68 /* Type representing floating-point environment. */ 69 typedef struct 70 { 71 unsigned int __cw; 72 } 73 fenv_t; 74 75 /* If the default argument is used we use this value. */ 76 #define FE_DFL_ENV ((const fenv_t *) -1l) 77 78 #ifdef __USE_GNU 79 /* Floating-point environment where none of the exceptions are masked. */ 80 # define FE_NOMASK_ENV ((const fenv_t *) -2) 81 #endif 82 83 /* Type representing floating-point control modes. */ 84 typedef unsigned int femode_t; 85 86 /* Default floating-point control modes. */ 87 # define FE_DFL_MODE ((const femode_t *) -1L) 88