Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

282 lines
4.8 KiB

  1. /***
  2. *fpieee.h - Definitions for floating point IEEE exception handling
  3. *
  4. * Copyright (c) 1991-1995, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains constant and type definitions for handling
  8. * floating point exceptions [ANSI/IEEE std. 754]
  9. *
  10. * [Public]
  11. *
  12. ****/
  13. #ifndef _INC_FPIEEE
  14. #define _INC_FPIEEE
  15. #if !defined(_WIN32) && !defined(_MAC)
  16. #error ERROR: Only Mac or Win32 targets supported!
  17. #endif
  18. #ifndef __assembler /* MIPS ONLY: Protect from assembler */
  19. #ifdef _MSC_VER
  20. /*
  21. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  22. * alignment.
  23. */
  24. #pragma pack(push,8)
  25. #endif /* _MSC_VER */
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  30. #ifndef _CRTAPI1
  31. #if _MSC_VER >= 800 && _M_IX86 >= 300
  32. #define _CRTAPI1 __cdecl
  33. #else
  34. #define _CRTAPI1
  35. #endif
  36. #endif
  37. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  38. #ifndef _CRTAPI2
  39. #if _MSC_VER >= 800 && _M_IX86 >= 300
  40. #define _CRTAPI2 __cdecl
  41. #else
  42. #define _CRTAPI2
  43. #endif
  44. #endif
  45. /* Define _CRTIMP */
  46. #ifndef _CRTIMP
  47. #ifdef _NTSDK
  48. /* definition compatible with NT SDK */
  49. #define _CRTIMP
  50. #else /* ndef _NTSDK */
  51. /* current definition */
  52. #ifdef _DLL
  53. #define _CRTIMP __declspec(dllimport)
  54. #else /* ndef _DLL */
  55. #define _CRTIMP
  56. #endif /* _DLL */
  57. #endif /* _NTSDK */
  58. #endif /* _CRTIMP */
  59. /* Define __cdecl for non-Microsoft compilers */
  60. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  61. #define __cdecl
  62. #endif
  63. /*
  64. * Define floating point IEEE compare result values.
  65. */
  66. typedef enum {
  67. _FpCompareEqual,
  68. _FpCompareGreater,
  69. _FpCompareLess,
  70. _FpCompareUnordered
  71. } _FPIEEE_COMPARE_RESULT;
  72. /*
  73. * Define floating point format and result precision values.
  74. */
  75. typedef enum {
  76. _FpFormatFp32,
  77. _FpFormatFp64,
  78. _FpFormatFp80,
  79. _FpFormatFp128,
  80. _FpFormatI16,
  81. _FpFormatI32,
  82. _FpFormatI64,
  83. _FpFormatU16,
  84. _FpFormatU32,
  85. _FpFormatU64,
  86. _FpFormatBcd80,
  87. _FpFormatCompare,
  88. _FpFormatString
  89. } _FPIEEE_FORMAT;
  90. /*
  91. * Define operation code values.
  92. */
  93. typedef enum {
  94. _FpCodeUnspecified,
  95. _FpCodeAdd,
  96. _FpCodeSubtract,
  97. _FpCodeMultiply,
  98. _FpCodeDivide,
  99. _FpCodeSquareRoot,
  100. _FpCodeRemainder,
  101. _FpCodeCompare,
  102. _FpCodeConvert,
  103. _FpCodeRound,
  104. _FpCodeTruncate,
  105. _FpCodeFloor,
  106. _FpCodeCeil,
  107. _FpCodeAcos,
  108. _FpCodeAsin,
  109. _FpCodeAtan,
  110. _FpCodeAtan2,
  111. _FpCodeCabs,
  112. _FpCodeCos,
  113. _FpCodeCosh,
  114. _FpCodeExp,
  115. _FpCodeFabs,
  116. _FpCodeFmod,
  117. _FpCodeFrexp,
  118. _FpCodeHypot,
  119. _FpCodeLdexp,
  120. _FpCodeLog,
  121. _FpCodeLog10,
  122. _FpCodeModf,
  123. _FpCodePow,
  124. _FpCodeSin,
  125. _FpCodeSinh,
  126. _FpCodeTan,
  127. _FpCodeTanh,
  128. _FpCodeY0,
  129. _FpCodeY1,
  130. _FpCodeYn,
  131. _FpCodeLogb,
  132. _FpCodeNextafter,
  133. _FpCodeNegate
  134. } _FP_OPERATION_CODE;
  135. #endif /* #ifndef __assembler */
  136. /*
  137. * Define rounding modes.
  138. */
  139. #ifndef __assembler /* MIPS ONLY: Protect from assembler */
  140. typedef enum {
  141. _FpRoundNearest,
  142. _FpRoundMinusInfinity,
  143. _FpRoundPlusInfinity,
  144. _FpRoundChopped
  145. } _FPIEEE_ROUNDING_MODE;
  146. typedef enum {
  147. _FpPrecisionFull,
  148. _FpPrecision53,
  149. _FpPrecision24
  150. } _FPIEEE_PRECISION;
  151. /*
  152. * Define floating point context record
  153. */
  154. typedef float _FP32;
  155. typedef double _FP64;
  156. typedef short _I16;
  157. typedef int _I32;
  158. typedef unsigned short _U16;
  159. typedef unsigned int _U32;
  160. typedef struct {
  161. unsigned short W[5];
  162. } _FP80;
  163. typedef struct {
  164. unsigned long W[4];
  165. } _FP128;
  166. typedef struct {
  167. unsigned long W[2];
  168. } _I64;
  169. typedef struct {
  170. unsigned long W[2];
  171. } _U64;
  172. typedef struct {
  173. unsigned short W[5];
  174. } _BCD80;
  175. typedef struct {
  176. union {
  177. _FP32 Fp32Value;
  178. _FP64 Fp64Value;
  179. _FP80 Fp80Value;
  180. _FP128 Fp128Value;
  181. _I16 I16Value;
  182. _I32 I32Value;
  183. _I64 I64Value;
  184. _U16 U16Value;
  185. _U32 U32Value;
  186. _U64 U64Value;
  187. _BCD80 Bcd80Value;
  188. char *StringValue;
  189. int CompareValue;
  190. } Value;
  191. unsigned int OperandValid : 1;
  192. unsigned int Format : 4;
  193. } _FPIEEE_VALUE;
  194. typedef struct {
  195. unsigned int Inexact : 1;
  196. unsigned int Underflow : 1;
  197. unsigned int Overflow : 1;
  198. unsigned int ZeroDivide : 1;
  199. unsigned int InvalidOperation : 1;
  200. } _FPIEEE_EXCEPTION_FLAGS;
  201. typedef struct {
  202. unsigned int RoundingMode : 2;
  203. unsigned int Precision : 3;
  204. unsigned int Operation :12;
  205. _FPIEEE_EXCEPTION_FLAGS Cause;
  206. _FPIEEE_EXCEPTION_FLAGS Enable;
  207. _FPIEEE_EXCEPTION_FLAGS Status;
  208. _FPIEEE_VALUE Operand1;
  209. _FPIEEE_VALUE Operand2;
  210. _FPIEEE_VALUE Result;
  211. } _FPIEEE_RECORD;
  212. struct _EXCEPTION_POINTERS;
  213. /*
  214. * Floating point IEEE exception filter routine
  215. */
  216. _CRTIMP int __cdecl _fpieee_flt(
  217. unsigned long,
  218. struct _EXCEPTION_POINTERS *,
  219. int (__cdecl *)(_FPIEEE_RECORD *)
  220. );
  221. #ifdef __cplusplus
  222. }
  223. #endif
  224. #ifdef _MSC_VER
  225. #pragma pack(pop)
  226. #endif /* _MSC_VER */
  227. #endif /* #ifndef __assembler */
  228. #endif /* _INC_FPIEEE */