fenv.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (C) 2004-2025 Free Software Foundation, Inc.
  2. The GNU C Library is free software; you can redistribute it and/or
  3. modify it under the terms of the GNU Lesser General Public
  4. License as published by the Free Software Foundation; either
  5. version 2.1 of the License, or (at your option) any later version.
  6. The GNU C Library is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9. Lesser General Public License for more details.
  10. You should have received a copy of the GNU Lesser General Public
  11. License along with the GNU C Library. If not, see
  12. <https://www.gnu.org/licenses/>. */
  13. #ifndef _FENV_H
  14. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  15. #endif
  16. /* Define bits representing exceptions in the FPU status word. */
  17. enum
  18. {
  19. FE_INVALID =
  20. #define FE_INVALID 1
  21. FE_INVALID,
  22. FE_DIVBYZERO =
  23. #define FE_DIVBYZERO 2
  24. FE_DIVBYZERO,
  25. FE_OVERFLOW =
  26. #define FE_OVERFLOW 4
  27. FE_OVERFLOW,
  28. FE_UNDERFLOW =
  29. #define FE_UNDERFLOW 8
  30. FE_UNDERFLOW,
  31. FE_INEXACT =
  32. #define FE_INEXACT 16
  33. FE_INEXACT,
  34. };
  35. /* Amount to shift by to convert an exception to a mask bit. */
  36. #define FE_EXCEPT_SHIFT 8
  37. /* All supported exceptions. */
  38. #define FE_ALL_EXCEPT \
  39. (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
  40. /* VFP supports all of the four defined rounding modes. */
  41. enum
  42. {
  43. FE_TONEAREST =
  44. #define FE_TONEAREST 0
  45. FE_TONEAREST,
  46. FE_UPWARD =
  47. #define FE_UPWARD 0x400000
  48. FE_UPWARD,
  49. FE_DOWNWARD =
  50. #define FE_DOWNWARD 0x800000
  51. FE_DOWNWARD,
  52. FE_TOWARDZERO =
  53. #define FE_TOWARDZERO 0xc00000
  54. FE_TOWARDZERO
  55. };
  56. /* Type representing exception flags. */
  57. typedef unsigned int fexcept_t;
  58. /* Type representing floating-point environment. */
  59. typedef struct
  60. {
  61. unsigned int __cw;
  62. }
  63. fenv_t;
  64. /* If the default argument is used we use this value. */
  65. #define FE_DFL_ENV ((const fenv_t *) -1l)
  66. #ifdef __USE_GNU
  67. /* Floating-point environment where none of the exceptions are masked. */
  68. # define FE_NOMASK_ENV ((const fenv_t *) -2)
  69. #endif
  70. /* Type representing floating-point control modes. */
  71. typedef unsigned int femode_t;
  72. /* Default floating-point control modes. */
  73. # define FE_DFL_MODE ((const femode_t *) -1L)