1 /* Floating point environment, OpenRISC version. 2 Copyright (C) 2022-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 License as 6 published by the Free Software Foundation; either version 2.1 of the 7 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 _FENV_H 19 # error "Never use <bits/fenv.h> directly; include <fenv.h> instead." 20 #endif 21 22 #ifdef __or1k_hard_float__ 23 /* Define bits representing exceptions in the FPCSR status word. */ 24 enum 25 { 26 FE_OVERFLOW = 27 #define FE_OVERFLOW (1 << 3) 28 FE_OVERFLOW, 29 FE_UNDERFLOW = 30 #define FE_UNDERFLOW (1 << 4) 31 FE_UNDERFLOW, 32 FE_INEXACT = 33 #define FE_INEXACT (1 << 8) 34 FE_INEXACT, 35 FE_INVALID = 36 #define FE_INVALID (1 << 9) 37 FE_INVALID, 38 FE_DIVBYZERO = 39 #define FE_DIVBYZERO (1 << 11) 40 FE_DIVBYZERO, 41 }; 42 43 /* All supported exceptions. */ 44 #define FE_ALL_EXCEPT \ 45 (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) 46 47 /* Define bits representing rounding modes in the FPCSR Rmode field. */ 48 #define FE_TONEAREST (0x0 << 1) 49 #define FE_TOWARDZERO (0x1 << 1) 50 #define FE_UPWARD (0x2 << 1) 51 #define FE_DOWNWARD (0x3 << 1) 52 53 #else 54 55 /* In the soft-float case only rounding to nearest is supported, with 56 no exceptions. */ 57 58 enum 59 { 60 __FE_UNDEFINED = -1, 61 62 FE_TONEAREST = 63 # define FE_TONEAREST 0x0 64 FE_TONEAREST 65 }; 66 67 # define FE_ALL_EXCEPT 0 68 69 #endif /* __or1k_hard_float__ */ 70 71 /* Type representing exception flags. */ 72 typedef unsigned int fexcept_t; 73 74 /* Type representing floating-point environment. */ 75 typedef unsigned int fenv_t; 76 77 /* If the default argument is used we use this value. */ 78 #define FE_DFL_ENV ((const fenv_t *) -1l) 79 80 /* Type representing floating-point control modes. */ 81 typedef unsigned int femode_t; 82 83 /* Default floating-point control modes. */ 84 # define FE_DFL_MODE ((const femode_t *) -1L) 85