fenv.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _FENV_H
  15. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  16. #endif
  17. /* Define bits representing the exception. We use the bit positions
  18. of the appropriate bits in the FPU control word. */
  19. enum
  20. {
  21. FE_INVALID = 0x01,
  22. #define FE_INVALID FE_INVALID
  23. __FE_DENORM = 0x02,
  24. FE_DIVBYZERO = 0x04,
  25. #define FE_DIVBYZERO FE_DIVBYZERO
  26. FE_OVERFLOW = 0x08,
  27. #define FE_OVERFLOW FE_OVERFLOW
  28. FE_UNDERFLOW = 0x10,
  29. #define FE_UNDERFLOW FE_UNDERFLOW
  30. FE_INEXACT = 0x20
  31. #define FE_INEXACT FE_INEXACT
  32. };
  33. #define FE_ALL_EXCEPT \
  34. (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
  35. /* The ix87 FPU supports all of the four defined rounding modes. We
  36. use again the bit positions in the FPU control word as the values
  37. for the appropriate macros. */
  38. enum
  39. {
  40. FE_TONEAREST = 0,
  41. #define FE_TONEAREST FE_TONEAREST
  42. FE_DOWNWARD = 0x400,
  43. #define FE_DOWNWARD FE_DOWNWARD
  44. FE_UPWARD = 0x800,
  45. #define FE_UPWARD FE_UPWARD
  46. FE_TOWARDZERO = 0xc00
  47. #define FE_TOWARDZERO FE_TOWARDZERO
  48. };
  49. /* Type representing exception flags. */
  50. typedef unsigned short int fexcept_t;
  51. /* Type representing floating-point environment. This function corresponds
  52. to the layout of the block written by the `fstenv'. */
  53. typedef struct
  54. {
  55. unsigned short int __control_word;
  56. unsigned short int __uclibc_unused1;
  57. unsigned short int __status_word;
  58. unsigned short int __uclibc_unused2;
  59. unsigned short int __tags;
  60. unsigned short int __uclibc_unused3;
  61. unsigned int __eip;
  62. unsigned short int __cs_selector;
  63. unsigned int __opcode:11;
  64. unsigned int __uclibc_unused4:5;
  65. unsigned int __data_offset;
  66. unsigned short int __data_selector;
  67. unsigned short int __uclibc_unused5;
  68. }
  69. fenv_t;
  70. /* If the default argument is used we use this value. */
  71. #define FE_DFL_ENV ((const fenv_t *) -1)
  72. #ifdef __USE_GNU
  73. /* Floating-point environment where none of the exception is masked. */
  74. # define FE_NOMASK_ENV ((const fenv_t *) -2)
  75. #endif