fenv.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _FENV_H
  2. # error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
  3. #endif
  4. /* Define bits representing the exception. We use the bit positions of
  5. the appropriate bits in the FPSR Accrued Exception Byte. */
  6. enum
  7. {
  8. FE_INEXACT = 1 << 3,
  9. #define FE_INEXACT FE_INEXACT
  10. FE_DIVBYZERO = 1 << 4,
  11. #define FE_DIVBYZERO FE_DIVBYZERO
  12. FE_UNDERFLOW = 1 << 5,
  13. #define FE_UNDERFLOW FE_UNDERFLOW
  14. FE_OVERFLOW = 1 << 6,
  15. #define FE_OVERFLOW FE_OVERFLOW
  16. FE_INVALID = 1 << 7
  17. #define FE_INVALID FE_INVALID
  18. };
  19. #define FE_ALL_EXCEPT \
  20. (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
  21. /* The csky FPU supports all of the four defined rounding modes. We use
  22. the bit positions in the FPCR Mode Control Byte as the values for the
  23. appropriate macros. */
  24. enum
  25. {
  26. FE_TONEAREST = 0,
  27. #define FE_TONEAREST FE_TONEAREST
  28. FE_TOWARDZERO = 1 << 4,
  29. #define FE_TOWARDZERO FE_TOWARDZERO
  30. FE_DOWNWARD = 2 << 4,
  31. #define FE_DOWNWARD FE_DOWNWARD
  32. FE_UPWARD = 3 << 4
  33. #define FE_UPWARD FE_UPWARD
  34. };
  35. /* Type representing exception flags. */
  36. typedef unsigned int fexcept_t;
  37. /* Type representing floating-point environment. This structure
  38. corresponds to the layout of the block written by `fmovem'. */
  39. typedef struct
  40. {
  41. unsigned int __control_register;
  42. unsigned int __status_register;
  43. unsigned int __instruction_address;
  44. }
  45. fenv_t;
  46. /* If the default argument is used we use this value. */
  47. #define FE_DFL_ENV ((__const fenv_t *) -1)
  48. #ifdef __USE_GNU
  49. /* Floating-point environment where none of the exceptions are masked. */
  50. # define FE_NOMASK_ENV ((__const fenv_t *) -2)
  51. #endif