fenv.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _FENV_H
  17. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  18. #endif
  19. /* Define bits representing the exception. We use the bit positions of
  20. the appropriate bits in the SR. */
  21. enum
  22. {
  23. FE_INEXACT = (1 << 8),
  24. #define FE_INEXACT FE_INEXACT
  25. FE_UNDERFLOW = (1 << 9),
  26. #define FE_UNDERFLOW FE_UNDERFLOW
  27. FE_OVERFLOW = (1 << 10),
  28. #define FE_OVERFLOW FE_OVERFLOW
  29. FE_DIVBYZERO = (1 << 11),
  30. #define FE_DIVBYZERO FE_DIVBYZERO
  31. FE_INVALID = (1 << 12)
  32. #define FE_INVALID FE_INVALID
  33. };
  34. #define FE_ALL_EXCEPT \
  35. (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
  36. /* We support all of the four defined rounding modes. We use
  37. the bit positions in the FPCR Mode Control Byte as the values for the
  38. appropriate macros. */
  39. enum
  40. {
  41. FE_TONEAREST = 0,
  42. #define FE_TONEAREST FE_TONEAREST
  43. FE_TOWARDZERO = 1 << 13 ,
  44. #define FE_TOWARDZERO FE_TOWARDZERO
  45. FE_DOWNWARD = 2 << 13,
  46. #define FE_DOWNWARD FE_DOWNWARD
  47. FE_UPWARD = 3 << 13
  48. #define FE_UPWARD FE_UPWARD
  49. };
  50. /* Type representing exception flags. */
  51. typedef unsigned int fexcept_t;
  52. /* Type representing floating-point environment.*/
  53. typedef struct
  54. {
  55. unsigned int round_mode;
  56. unsigned int trap_enabled;
  57. unsigned int accrued_except;
  58. unsigned int actual_except;
  59. } fenv_t;
  60. #if 0
  61. /* If the default argument is used we use this value. */
  62. const fenv FE_DFL_ENV_OBJ = {0, 0x1C00, 0}
  63. #define FE_DFL_ENV (&FE_DFL_ENV_OBJ)
  64. #ifdef __USE_GNU
  65. /* Floating-point environment where none of the exceptions are masked. */
  66. const fenv_t FE_NOMASK_ENV_OBJ = { 0, 0x1F00, 0 };
  67. # define FE_NOMASK_ENV (&FE_NOMASK_ENV_OBJ)
  68. #endif
  69. #endif
  70. #include <bits/fenvinline.h>