Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /**
  2.  * This file has no copyright assigned and is placed in the Public Domain.
  3.  * This file is part of the w64 mingw-runtime package.
  4.  * No warranty is given; refer to the file DISCLAIMER within this package.
  5.  */
  6. #ifndef _FENV_H_
  7. #define _FENV_H_
  8.  
  9. #include <_mingw.h>
  10.  
  11. /* FPU status word exception flags */
  12. #define FE_INVALID      0x01
  13. #define FE_DENORMAL     0x02
  14. #define FE_DIVBYZERO    0x04
  15. #define FE_OVERFLOW     0x08
  16. #define FE_UNDERFLOW    0x10
  17. #define FE_INEXACT      0x20
  18. #define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \
  19.                        | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT)
  20.  
  21. /* FPU control word rounding flags */
  22. #define FE_TONEAREST    0x0000
  23. #define FE_DOWNWARD     0x0400
  24. #define FE_UPWARD       0x0800
  25. #define FE_TOWARDZERO   0x0c00
  26.  
  27. /* The MXCSR exception flags are the same as the
  28.    FE flags. */
  29. #define __MXCSR_EXCEPT_FLAG_SHIFT 0
  30.  
  31. /* How much to shift FE status word exception flags
  32.    to get MXCSR rounding flags,  */
  33. #define __MXCSR_ROUND_FLAG_SHIFT 3
  34.  
  35. #ifndef RC_INVOKED
  36. /*
  37.   For now, support only for the basic abstraction of flags that are
  38.   either set or clear. fexcept_t could be  structure that holds more
  39.   info about the fp environment.
  40. */
  41. typedef unsigned short fexcept_t;
  42.  
  43. /* This 32-byte struct represents the entire floating point
  44.    environment as stored by fnstenv or fstenv, augmented by
  45.    the  contents of the MXCSR register, as stored by stmxcsr
  46.    (if CPU supports it). */
  47. typedef struct
  48. {
  49.   unsigned short __control_word;
  50.   unsigned short __unused0;
  51.   unsigned short __status_word;
  52.   unsigned short __unused1;
  53.   unsigned short __tag_word;
  54.   unsigned short __unused2;  
  55.   unsigned int   __ip_offset;    /* instruction pointer offset */
  56.   unsigned short __ip_selector;  
  57.   unsigned short __opcode;
  58.   unsigned int   __data_offset;
  59.   unsigned short __data_selector;  
  60.   unsigned short __unused3;
  61.   unsigned int   __mxcsr; /* contents of the MXCSR register  */
  62. } fenv_t;
  63.  
  64.  
  65. /*The C99 standard (7.6.9) allows us to define implementation-specific macros for
  66.   different fp environments */
  67.  
  68. /* The default Intel x87 floating point environment (64-bit mantissa) */
  69. #define FE_PC64_ENV ((const fenv_t *)-1)
  70.  
  71. /* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
  72. #define FE_PC53_ENV ((const fenv_t *)-2)
  73.  
  74. /* The FE_DFL_ENV macro is required by standard.
  75.   fesetenv will use the environment set at app startup.*/
  76. #define FE_DFL_ENV ((const fenv_t *) 0)
  77.  
  78. #ifdef __cplusplus
  79. extern "C" {
  80. #endif
  81.  
  82. /*TODO: Some of these could be inlined */
  83. /* 7.6.2 Exception */
  84.  
  85. extern int __cdecl feclearexcept (int);
  86. extern int __cdecl fegetexceptflag (fexcept_t * flagp, int excepts);
  87. extern int __cdecl feraiseexcept (int excepts );
  88. extern int __cdecl fesetexceptflag (const fexcept_t *, int);
  89. extern int __cdecl fetestexcept (int excepts);
  90.  
  91. /* 7.6.3 Rounding */
  92.  
  93. extern int __cdecl fegetround (void);
  94. extern int __cdecl fesetround (int mode);
  95.  
  96. /* 7.6.4 Environment */
  97.  
  98. extern int __cdecl fegetenv(fenv_t * envp);
  99. extern int __cdecl fesetenv(const fenv_t * );
  100. extern int __cdecl feupdateenv(const fenv_t *);
  101. extern int __cdecl feholdexcept(fenv_t *);
  102.  
  103. #ifdef __cplusplus
  104. }
  105. #endif
  106. #endif  /* Not RC_INVOKED */
  107.  
  108. #endif /* ndef _FENV_H */
  109.