fenv.h 2.6 KB

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