fenv.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 1999-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 the exception. We use the bit positions
  17. of the appropriate bits in the FPU control word. */
  18. enum
  19. {
  20. FE_INEXACT =
  21. #define FE_INEXACT 0x04
  22. FE_INEXACT,
  23. FE_UNDERFLOW =
  24. #define FE_UNDERFLOW 0x08
  25. FE_UNDERFLOW,
  26. FE_OVERFLOW =
  27. #define FE_OVERFLOW 0x10
  28. FE_OVERFLOW,
  29. FE_DIVBYZERO =
  30. #define FE_DIVBYZERO 0x20
  31. FE_DIVBYZERO,
  32. FE_INVALID =
  33. #define FE_INVALID 0x40
  34. FE_INVALID,
  35. };
  36. #define FE_ALL_EXCEPT \
  37. (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
  38. /* The SH FPU supports two of the four defined rounding modes: round to nearest
  39. and round to zero. We use again the bit positions in the FPU control word
  40. as the values for the appropriate macros. */
  41. enum
  42. {
  43. __FE_UNDEFINED = -1,
  44. FE_TONEAREST =
  45. #define FE_TONEAREST 0x0
  46. FE_TONEAREST,
  47. FE_TOWARDZERO =
  48. #define FE_TOWARDZERO 0x1
  49. FE_TOWARDZERO,
  50. };
  51. /* Type representing exception flags. */
  52. typedef unsigned short int fexcept_t;
  53. /* Type representing floating-point environment. This function corresponds
  54. to the layout of the block written by the `fstenv'. */
  55. typedef struct
  56. {
  57. unsigned int __fpscr;
  58. }
  59. fenv_t;
  60. /* If the default argument is used we use this value. */
  61. #define FE_DFL_ENV ((const fenv_t *) -1)
  62. /* Type representing floating-point control modes. */
  63. typedef unsigned int femode_t;
  64. /* Default floating-point control modes. */
  65. # define FE_DFL_MODE ((const femode_t *) -1L)