fenv.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright (C) 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by David Huggins-Daines <dhd@debian.org>
  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 values of the
  19. appropriate enable bits in the FPU status word (which,
  20. coincidentally, are the same as the flag bits, but shifted right by
  21. 27 bits). */
  22. enum
  23. {
  24. FE_INVALID = 1<<4, /* V */
  25. #define FE_INVALID FE_INVALID
  26. FE_DIVBYZERO = 1<<3, /* Z */
  27. #define FE_DIVBYZERO FE_DIVBYZERO
  28. FE_OVERFLOW = 1<<2, /* O */
  29. #define FE_OVERFLOW FE_OVERFLOW
  30. FE_UNDERFLOW = 1<<1, /* U */
  31. #define FE_UNDERFLOW FE_UNDERFLOW
  32. FE_INEXACT = 1<<0, /* I */
  33. #define FE_INEXACT FE_INEXACT
  34. };
  35. #define FE_ALL_EXCEPT \
  36. (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
  37. /* The PA-RISC FPU supports all of the four defined rounding modes.
  38. We use the values of the RM field in the floating point status
  39. register for the appropriate macros. */
  40. enum
  41. {
  42. FE_TONEAREST = 0 << 9,
  43. #define FE_TONEAREST FE_TONEAREST
  44. FE_TOWARDZERO = 1 << 9,
  45. #define FE_TOWARDZERO FE_TOWARDZERO
  46. FE_UPWARD = 2 << 9,
  47. #define FE_UPWARD FE_UPWARD
  48. FE_DOWNWARD = 3 << 9,
  49. #define FE_DOWNWARD FE_DOWNWARD
  50. };
  51. /* Type representing exception flags. */
  52. typedef unsigned int fexcept_t;
  53. /* Type representing floating-point environment. This structure
  54. corresponds to the layout of the status and exception words in the
  55. register file. */
  56. typedef struct
  57. {
  58. unsigned int __status_word;
  59. unsigned int __exception[7];
  60. } fenv_t;
  61. /* If the default argument is used we use this value. */
  62. #define FE_DFL_ENV ((fenv_t *) -1)
  63. #ifdef __USE_GNU
  64. /* Floating-point environment where none of the exceptions are masked. */
  65. # define FE_NOMASK_ENV ((fenv_t *) -2)
  66. #endif