fenv.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Floating point environment, OpenRISC version.
  2. Copyright (C) 2022-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  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. 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. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _FENV_H
  16. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  17. #endif
  18. #ifdef __or1k_hard_float__
  19. /* Define bits representing exceptions in the FPCSR status word. */
  20. enum
  21. {
  22. FE_OVERFLOW =
  23. #define FE_OVERFLOW (1 << 3)
  24. FE_OVERFLOW,
  25. FE_UNDERFLOW =
  26. #define FE_UNDERFLOW (1 << 4)
  27. FE_UNDERFLOW,
  28. FE_INEXACT =
  29. #define FE_INEXACT (1 << 8)
  30. FE_INEXACT,
  31. FE_INVALID =
  32. #define FE_INVALID (1 << 9)
  33. FE_INVALID,
  34. FE_DIVBYZERO =
  35. #define FE_DIVBYZERO (1 << 11)
  36. FE_DIVBYZERO,
  37. };
  38. /* All supported exceptions. */
  39. #define FE_ALL_EXCEPT \
  40. (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
  41. /* Define bits representing rounding modes in the FPCSR Rmode field. */
  42. #define FE_TONEAREST (0x0 << 1)
  43. #define FE_TOWARDZERO (0x1 << 1)
  44. #define FE_UPWARD (0x2 << 1)
  45. #define FE_DOWNWARD (0x3 << 1)
  46. #else
  47. /* In the soft-float case only rounding to nearest is supported, with
  48. no exceptions. */
  49. enum
  50. {
  51. __FE_UNDEFINED = -1,
  52. FE_TONEAREST =
  53. # define FE_TONEAREST 0x0
  54. FE_TONEAREST
  55. };
  56. # define FE_ALL_EXCEPT 0
  57. #endif /* __or1k_hard_float__ */
  58. /* Type representing exception flags. */
  59. typedef unsigned int fexcept_t;
  60. /* Type representing floating-point environment. */
  61. typedef unsigned int fenv_t;
  62. /* If the default argument is used we use this value. */
  63. #define FE_DFL_ENV ((const fenv_t *) -1l)
  64. #if __GLIBC_USE (IEC_60559_BFP_EXT_C23)
  65. /* Type representing floating-point control modes. */
  66. typedef unsigned int femode_t;
  67. /* Default floating-point control modes. */
  68. # define FE_DFL_MODE ((const femode_t *) -1L)
  69. #endif