fenv.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Copyright (C) 2004-2012 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 License as
  4. published by the Free Software Foundation; either version 2.1 of the
  5. 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. <http://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 FPCSR status word. */
  17. enum
  18. {
  19. FE_INVALID =
  20. #define FE_INVALID 0x4
  21. FE_INVALID,
  22. FE_DIVBYZERO =
  23. #define FE_DIVBYZERO 0x8
  24. FE_DIVBYZERO,
  25. FE_OVERFLOW =
  26. #define FE_OVERFLOW 0x10
  27. FE_OVERFLOW,
  28. FE_UNDERFLOW =
  29. #define FE_UNDERFLOW 0x20
  30. FE_UNDERFLOW,
  31. FE_INEXACT =
  32. #define FE_INEXACT 0x40
  33. FE_INEXACT,
  34. };
  35. /* All supported exceptions. */
  36. #define FE_ALL_EXCEPT \
  37. (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
  38. /* Define bits representing rounding modes in the FPCSR RM field. */
  39. enum
  40. {
  41. FE_TONEAREST =
  42. #define FE_TONEAREST 0x0
  43. FE_TONEAREST,
  44. FE_UPWARD =
  45. #define FE_UPWARD 0x1
  46. FE_UPWARD,
  47. FE_DOWNWARD =
  48. #define FE_DOWNWARD 0x2
  49. FE_DOWNWARD,
  50. FE_TOWARDZERO =
  51. #define FE_TOWARDZERO 0x3
  52. FE_TOWARDZERO
  53. };
  54. /* Type representing exception flags. */
  55. typedef unsigned int fexcept_t;
  56. /* Type representing floating-point environment. */
  57. typedef struct
  58. {
  59. unsigned int __fpcsr;
  60. }
  61. fenv_t;
  62. /* If the default argument is used we use this value. */
  63. #define FE_DFL_ENV ((const fenv_t *) -1l)
  64. #ifdef __USE_GNU
  65. /* Floating-point environment where none of the exceptions are masked. */
  66. # define FE_NOMASK_ENV ((const fenv_t *) -2)
  67. #endif