fenv.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Copyright (C) 2002-2003, George Thanos <george.thanos@gdt.gr>
  2. Yannis Mitsos <yannis.mitsos@gdt.gr>
  3. Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
  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
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the 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. <http://www.gnu.org/licenses/>. */
  15. #ifndef _FENV_H
  16. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  17. #endif
  18. /* Define bits representing the exception. We use the bit positions of
  19. the appropriate bits in the SR. */
  20. enum
  21. {
  22. FE_INEXACT = (1 << 8),
  23. #define FE_INEXACT FE_INEXACT
  24. FE_UNDERFLOW = (1 << 9),
  25. #define FE_UNDERFLOW FE_UNDERFLOW
  26. FE_OVERFLOW = (1 << 10),
  27. #define FE_OVERFLOW FE_OVERFLOW
  28. FE_DIVBYZERO = (1 << 11),
  29. #define FE_DIVBYZERO FE_DIVBYZERO
  30. FE_INVALID = (1 << 12)
  31. #define FE_INVALID FE_INVALID
  32. };
  33. #define FE_ALL_EXCEPT \
  34. (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
  35. /* We support all of the four defined rounding modes. We use
  36. the bit positions in the FPCR Mode Control Byte as the values for the
  37. appropriate macros. */
  38. enum
  39. {
  40. FE_TONEAREST = 0,
  41. #define FE_TONEAREST FE_TONEAREST
  42. FE_TOWARDZERO = 1 << 13 ,
  43. #define FE_TOWARDZERO FE_TOWARDZERO
  44. FE_DOWNWARD = 2 << 13,
  45. #define FE_DOWNWARD FE_DOWNWARD
  46. FE_UPWARD = 3 << 13
  47. #define FE_UPWARD FE_UPWARD
  48. };
  49. /* Type representing exception flags. */
  50. typedef unsigned int fexcept_t;
  51. /* Type representing floating-point environment.*/
  52. typedef struct
  53. {
  54. unsigned int round_mode;
  55. unsigned int trap_enabled;
  56. unsigned int accrued_except;
  57. unsigned int actual_except;
  58. } fenv_t;
  59. #if 0
  60. /* If the default argument is used we use this value. */
  61. const fenv FE_DFL_ENV_OBJ = {0, 0x1C00, 0}
  62. #define FE_DFL_ENV (&FE_DFL_ENV_OBJ)
  63. #ifdef __USE_GNU
  64. /* Floating-point environment where none of the exceptions are masked. */
  65. const fenv_t FE_NOMASK_ENV_OBJ = { 0, 0x1F00, 0 };
  66. # define FE_NOMASK_ENV (&FE_NOMASK_ENV_OBJ)
  67. #endif
  68. #endif
  69. #include <bits/fenvinline.h>