fenv.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* Copyright (C) 1999-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  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. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _FENV_H
  15. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  16. #endif
  17. /* Define bits representing the exception. We use the bit positions of
  18. the appropriate bits in the FPSR... (Tahoe EAS 2.4 5-4)*/
  19. enum
  20. {
  21. FE_INEXACT =
  22. #define FE_INEXACT (1 << 5)
  23. FE_INEXACT,
  24. FE_UNDERFLOW =
  25. #define FE_UNDERFLOW (1 << 4)
  26. FE_UNDERFLOW,
  27. FE_OVERFLOW =
  28. #define FE_OVERFLOW (1 << 3)
  29. FE_OVERFLOW,
  30. FE_DIVBYZERO =
  31. #define FE_DIVBYZERO (1 << 2)
  32. FE_DIVBYZERO,
  33. FE_UNNORMAL =
  34. #define FE_UNNORMAL (1 << 1)
  35. FE_UNNORMAL,
  36. FE_INVALID =
  37. #define FE_INVALID (1 << 0)
  38. FE_INVALID,
  39. FE_ALL_EXCEPT =
  40. #define FE_ALL_EXCEPT (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | FE_DIVBYZERO | FE_UNNORMAL | FE_INVALID)
  41. FE_ALL_EXCEPT
  42. };
  43. enum
  44. {
  45. FE_TOWARDZERO =
  46. #define FE_TOWARDZERO 3
  47. FE_TOWARDZERO,
  48. FE_UPWARD =
  49. #define FE_UPWARD 2
  50. FE_UPWARD,
  51. FE_DOWNWARD =
  52. #define FE_DOWNWARD 1
  53. FE_DOWNWARD,
  54. FE_TONEAREST =
  55. #define FE_TONEAREST 0
  56. FE_TONEAREST,
  57. };
  58. /* Type representing exception flags. */
  59. typedef unsigned long int fexcept_t;
  60. /* Type representing floating-point environment. */
  61. typedef unsigned long int fenv_t;
  62. /* If the default argument is used we use this value. */
  63. #define FE_DFL_ENV ((const fenv_t *) 0xc009804c0270033fUL)
  64. #ifdef __USE_GNU
  65. /* Floating-point environment where only FE_UNNORMAL is masked since this
  66. exception is not generally supported by glibc. */
  67. # define FE_NOMASK_ENV ((const fenv_t *) 0xc009804c02700302UL)
  68. /* Floating-point environment with (processor-dependent) non-IEEE
  69. floating point. In this case, turning on flush-to-zero mode for
  70. s0, s2, and s3. */
  71. # define FE_NONIEEE_ENV ((const fenv_t *) 0xc009a04d0270037fUL)
  72. #endif
  73. #if __GLIBC_USE (IEC_60559_BFP_EXT)
  74. /* Type representing floating-point control modes. */
  75. typedef unsigned long int femode_t;
  76. /* Default floating-point control modes. */
  77. # define FE_DFL_MODE ((const femode_t *) 0xc009804c0270033fUL)
  78. #endif