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.

558 lines
13 KiB

  1. /***
  2. *fpieee.h - Definitions for floating point IEEE exception handling
  3. *
  4. * Copyright (c) 1991-2001, 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. *Revision History:
  13. * 03-01-92 GDP written
  14. * 04-05-92 GDP calling convention macros
  15. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  16. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  17. * 09-01-93 GJF Merged Cuda and NT SDK versions.
  18. * 09-24-93 GJF Removed dummy args from _fpieee_flt prototype.
  19. * 01-13-94 RDL Added #ifndef _LANGUAGE_ASSEMBLY for asm includes.
  20. * 01-24-94 GJF Merged in 01-13 change above (from crt32 tree on
  21. * \\orville\razzle).
  22. * 11-03-94 GJF Ensure 8 byte alignment.
  23. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  24. * 02-14-95 CFW Clean up Mac merge.
  25. * 12-14-95 JWM Add "#pragma once".
  26. * 02-21-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  27. * Also, detab-ed.
  28. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  29. * 10-07-97 RDL Added IA64.
  30. * 09-11-98 JWM Added Katmai exception support.
  31. * 05-13-99 PML Remove _CRTAPI1
  32. * 05-17-99 PML Remove all Macintosh support.
  33. * 03-01-00 PML Add WNI exception support.
  34. * 09-14-00 PML Add alignment for 64-bit, 128-bit types (vs7#160260).
  35. * 03-24-01 PML Enable 64-bit/128-bit type alignment on x86.
  36. *
  37. ****/
  38. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  39. #pragma once
  40. #endif
  41. #ifndef _INC_FPIEEE
  42. #define _INC_FPIEEE
  43. #if !defined(_WIN32)
  44. #error ERROR: Only Win32 target supported!
  45. #endif
  46. #ifndef _CRTBLD
  47. /* This version of the header files is NOT for user programs.
  48. * It is intended for use when building the C runtimes ONLY.
  49. * The version intended for public use will not have this message.
  50. */
  51. #error ERROR: Use of C runtime library internal header file.
  52. #endif /* _CRTBLD */
  53. #ifndef __assembler /* MIPS ONLY: Protect from assembler */
  54. #ifdef _MSC_VER
  55. /*
  56. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  57. * alignment.
  58. */
  59. #pragma pack(push,8)
  60. #endif /* _MSC_VER */
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64. #ifndef _INTERNAL_IFSTRIP_
  65. #include <cruntime.h>
  66. #endif /* _INTERNAL_IFSTRIP_ */
  67. /* Define _CRTIMP */
  68. #ifndef _CRTIMP
  69. #ifdef CRTDLL
  70. #define _CRTIMP __declspec(dllexport)
  71. #else /* ndef CRTDLL */
  72. #ifdef _DLL
  73. #define _CRTIMP __declspec(dllimport)
  74. #else /* ndef _DLL */
  75. #define _CRTIMP
  76. #endif /* _DLL */
  77. #endif /* CRTDLL */
  78. #endif /* _CRTIMP */
  79. /* Define __cdecl for non-Microsoft compilers */
  80. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  81. #define __cdecl
  82. #endif
  83. /*
  84. * Define floating point IEEE compare result values.
  85. */
  86. typedef enum {
  87. _FpCompareEqual,
  88. _FpCompareGreater,
  89. _FpCompareLess,
  90. _FpCompareUnordered
  91. } _FPIEEE_COMPARE_RESULT;
  92. /*
  93. * Define floating point format and result precision values.
  94. */
  95. typedef enum {
  96. _FpFormatFp32,
  97. _FpFormatFp64,
  98. _FpFormatFp80,
  99. _FpFormatFp128,
  100. _FpFormatI16,
  101. _FpFormatI32,
  102. _FpFormatI64,
  103. _FpFormatU16,
  104. _FpFormatU32,
  105. _FpFormatU64,
  106. _FpFormatBcd80,
  107. _FpFormatCompare,
  108. _FpFormatString,
  109. #if defined(_M_IA64)
  110. _FpFormatFp82
  111. #endif
  112. } _FPIEEE_FORMAT;
  113. /*
  114. * Define operation code values.
  115. */
  116. typedef enum {
  117. _FpCodeUnspecified,
  118. _FpCodeAdd,
  119. _FpCodeSubtract,
  120. _FpCodeMultiply,
  121. _FpCodeDivide,
  122. _FpCodeSquareRoot,
  123. _FpCodeRemainder,
  124. _FpCodeCompare,
  125. _FpCodeConvert,
  126. _FpCodeRound,
  127. _FpCodeTruncate,
  128. _FpCodeFloor,
  129. _FpCodeCeil,
  130. _FpCodeAcos,
  131. _FpCodeAsin,
  132. _FpCodeAtan,
  133. _FpCodeAtan2,
  134. _FpCodeCabs,
  135. _FpCodeCos,
  136. _FpCodeCosh,
  137. _FpCodeExp,
  138. _FpCodeFabs,
  139. _FpCodeFmod,
  140. _FpCodeFrexp,
  141. _FpCodeHypot,
  142. _FpCodeLdexp,
  143. _FpCodeLog,
  144. _FpCodeLog10,
  145. _FpCodeModf,
  146. _FpCodePow,
  147. _FpCodeSin,
  148. _FpCodeSinh,
  149. _FpCodeTan,
  150. _FpCodeTanh,
  151. _FpCodeY0,
  152. _FpCodeY1,
  153. _FpCodeYn,
  154. _FpCodeLogb,
  155. _FpCodeNextafter,
  156. _FpCodeNegate,
  157. _FpCodeFmin, //XMMI
  158. _FpCodeFmax, //XMMI
  159. _FpCodeConvertTrunc, //XMMI
  160. _XMMIAddps, //XMMI
  161. _XMMIAddss,
  162. _XMMISubps,
  163. _XMMISubss,
  164. _XMMIMulps,
  165. _XMMIMulss,
  166. _XMMIDivps,
  167. _XMMIDivss,
  168. _XMMISqrtps,
  169. _XMMISqrtss,
  170. _XMMIMaxps,
  171. _XMMIMaxss,
  172. _XMMIMinps,
  173. _XMMIMinss,
  174. _XMMICmpps,
  175. _XMMICmpss,
  176. _XMMIComiss,
  177. _XMMIUComiss,
  178. _XMMICvtpi2ps,
  179. _XMMICvtsi2ss,
  180. _XMMICvtps2pi,
  181. _XMMICvtss2si,
  182. _XMMICvttps2pi,
  183. _XMMICvttss2si,
  184. _XMMI2Addpd, //XMMI2
  185. _XMMI2Addsd,
  186. _XMMI2Subpd,
  187. _XMMI2Subsd,
  188. _XMMI2Mulpd,
  189. _XMMI2Mulsd,
  190. _XMMI2Divpd,
  191. _XMMI2Divsd,
  192. _XMMI2Sqrtpd,
  193. _XMMI2Sqrtsd,
  194. _XMMI2Maxpd,
  195. _XMMI2Maxsd,
  196. _XMMI2Minpd,
  197. _XMMI2Minsd,
  198. _XMMI2Cmppd,
  199. _XMMI2Cmpsd,
  200. _XMMI2Comisd,
  201. _XMMI2UComisd,
  202. _XMMI2Cvtpd2pi, //66 2D
  203. _XMMI2Cvtsd2si, //F2
  204. _XMMI2Cvttpd2pi, //66 2C
  205. _XMMI2Cvttsd2si, //F2
  206. _XMMI2Cvtps2pd, //0F 5A
  207. _XMMI2Cvtss2sd, //F3
  208. _XMMI2Cvtpd2ps, //66
  209. _XMMI2Cvtsd2ss, //F2
  210. _XMMI2Cvtdq2ps, //0F 5B
  211. _XMMI2Cvttps2dq, //F3
  212. _XMMI2Cvtps2dq, //66
  213. _XMMI2Cvttpd2dq, //66 0F E6
  214. _XMMI2Cvtpd2dq, //F2
  215. #if defined(_M_IA64)
  216. _FpCodeFma,
  217. _FpCodeFmaSingle,
  218. _FpCodeFmaDouble,
  219. _FpCodeFms,
  220. _FpCodeFmsSingle,
  221. _FpCodeFmsDouble,
  222. _FpCodeFnma,
  223. _FpCodeFnmaSingle,
  224. _FpCodeFnmaDouble,
  225. _FpCodeFamin,
  226. _FpCodeFamax
  227. #endif
  228. } _FP_OPERATION_CODE;
  229. #endif /* #ifndef __assembler */
  230. #ifndef _INTERNAL_IFSTRIP_
  231. #ifndef __assembler /* MIPS ONLY: Protect from assembler */
  232. #define OP_UNSPEC _FpCodeUnspecified
  233. #define OP_ADD _FpCodeAdd
  234. #define OP_SUB _FpCodeSubtract
  235. #define OP_MUL _FpCodeMultiply
  236. #define OP_DIV _FpCodeDivide
  237. #define OP_REM _FpCodeRemainder
  238. #define OP_COMP _FpCodeCompare
  239. #define OP_CVT _FpCodeConvert
  240. #define OP_RND _FpCodeRound
  241. #define OP_TRUNC _FpCodeTruncate
  242. #define OP_EXP _FpCodeExp
  243. #define OP_POW _FpCodePow
  244. #define OP_LOG _FpCodeLog
  245. #define OP_LOG10 _FpCodeLog10
  246. #define OP_SINH _FpCodeSinh
  247. #define OP_COSH _FpCodeCosh
  248. #define OP_TANH _FpCodeTanh
  249. #define OP_ASIN _FpCodeAsin
  250. #define OP_ACOS _FpCodeAcos
  251. #define OP_ATAN _FpCodeAtan
  252. #define OP_ATAN2 _FpCodeAtan2
  253. #define OP_SQRT _FpCodeSquareRoot
  254. #define OP_SIN _FpCodeSin
  255. #define OP_COS _FpCodeCos
  256. #define OP_TAN _FpCodeTan
  257. #define OP_CEIL _FpCodeCeil
  258. #define OP_FLOOR _FpCodeFloor
  259. #define OP_ABS _FpCodeFabs
  260. #define OP_MODF _FpCodeModf
  261. #define OP_LDEXP _FpCodeLdexp
  262. #define OP_CABS _FpCodeCabs
  263. #define OP_HYPOT _FpCodeHypot
  264. #define OP_FMOD _FpCodeFmod
  265. #define OP_FREXP _FpCodeFrexp
  266. #define OP_Y0 _FpCodeY0
  267. #define OP_Y1 _FpCodeY1
  268. #define OP_YN _FpCodeYn
  269. #define OP_LOGB _FpCodeLogb
  270. #define OP_NEXTAFTER _FpCodeNextafter
  271. //XMMI
  272. #define OP_ADDPS _XMMIAddps
  273. #define OP_ADDSS _XMMIAddss
  274. #define OP_SUBPS _XMMISubps
  275. #define OP_SUBSS _XMMISubss
  276. #define OP_MULPS _XMMIMulps
  277. #define OP_MULSS _XMMIMulss
  278. #define OP_DIVPS _XMMIDivps
  279. #define OP_DIVSS _XMMIDivss
  280. #define OP_SQRTPS _XMMISqrtps
  281. #define OP_SQRTSS _XMMISqrtss
  282. #define OP_MAXPS _XMMIMaxps
  283. #define OP_MAXSS _XMMIMaxss
  284. #define OP_MINPS _XMMIMinps
  285. #define OP_MINSS _XMMIMinss
  286. #define OP_CMPPS _XMMICmpps
  287. #define OP_CMPSS _XMMICmpss
  288. #define OP_COMISS _XMMIComiss
  289. #define OP_UCOMISS _XMMIUComiss
  290. #define OP_CVTPI2PS _XMMICvtpi2ps
  291. #define OP_CVTSI2SS _XMMICvtsi2ss
  292. #define OP_CVTPS2PI _XMMICvtps2pi
  293. #define OP_CVTSS2SI _XMMICvtss2si
  294. #define OP_CVTTPS2PI _XMMICvttps2pi
  295. #define OP_CVTTSS2SI _XMMICvttss2si
  296. //XMMI
  297. //XMMI2
  298. #define OP_ADDPD _XMMI2Addpd //XMMI2
  299. #define OP_ADDSD _XMMI2Addsd
  300. #define OP_SUBPD _XMMI2Subpd
  301. #define OP_SUBSD _XMMI2Subsd
  302. #define OP_MULPD _XMMI2Mulpd
  303. #define OP_MULSD _XMMI2Mulsd
  304. #define OP_DIVPD _XMMI2Divpd
  305. #define OP_DIVSD _XMMI2Divsd
  306. #define OP_SQRTPD _XMMI2Sqrtpd
  307. #define OP_SQRTSD _XMMI2Sqrtsd
  308. #define OP_MAXPD _XMMI2Maxpd
  309. #define OP_MAXSD _XMMI2Maxsd
  310. #define OP_MINPD _XMMI2Minpd
  311. #define OP_MINSD _XMMI2Minsd
  312. #define OP_CMPPD _XMMI2Cmppd
  313. #define OP_CMPSD _XMMI2Cmpsd
  314. #define OP_COMISD _XMMI2Comisd
  315. #define OP_UCOMISD _XMMI2UComisd
  316. #define OP_CVTPD2PI _XMMI2Cvtpd2pi //66 2D
  317. #define OP_CVTSD2SI _XMMI2Cvtsd2si //F2
  318. #define OP_CVTTPD2PI _XMMI2Cvttpd2pi //66 2C
  319. #define OP_CVTTSD2SI _XMMI2Cvttsd2si //F2
  320. #define OP_CVTPS2PD _XMMI2Cvtps2pd //0F 5A
  321. #define OP_CVTSS2SD _XMMI2Cvtss2sd //F3
  322. #define OP_CVTPD2PS _XMMI2Cvtpd2ps //66
  323. #define OP_CVTSD2SS _XMMI2Cvtsd2ss //F2
  324. #define OP_CVTDQ2PS _XMMI2Cvtdq2ps //0F 5B
  325. #define OP_CVTTPS2DQ _XMMI2Cvttps2dq //F3
  326. #define OP_CVTPS2DQ _XMMI2Cvtps2dq //66
  327. #define OP_CVTTPD2DQ _XMMI2Cvttpd2dq //66 0F E6
  328. #define OP_CVTPD2DQ _XMMI2Cvtpd2dq //F2
  329. //XMMI2
  330. #else /* #ifndef __assembler */
  331. /* This must be the same as the enumerator _FP_OPERATION_CODE ! */
  332. #define OP_UNSPEC 0
  333. #define OP_ADD 1
  334. #define OP_SUB 2
  335. #define OP_MUL 3
  336. #define OP_DIV 4
  337. #define OP_SQRT 5
  338. #define OP_REM 6
  339. #define OP_COMP 7
  340. #define OP_CVT 8
  341. #define OP_RND 9
  342. #define OP_TRUNC 10
  343. #define OP_FLOOR 11
  344. #define OP_CEIL 12
  345. #define OP_ACOS 13
  346. #define OP_ASIN 14
  347. #define OP_ATAN 15
  348. #define OP_ATAN2 16
  349. #define OP_CABS 17
  350. #define OP_COS 18
  351. #define OP_COSH 19
  352. #define OP_EXP 20
  353. #define OP_ABS 21 /* same as OP_FABS */
  354. #define OP_FABS 21 /* same as OP_ABS */
  355. #define OP_FMOD 22
  356. #define OP_FREXP 23
  357. #define OP_HYPOT 24
  358. #define OP_LDEXP 25
  359. #define OP_LOG 26
  360. #define OP_LOG10 27
  361. #define OP_MODF 28
  362. #define OP_POW 29
  363. #define OP_SIN 30
  364. #define OP_SINH 31
  365. #define OP_TAN 32
  366. #define OP_TANH 33
  367. #define OP_Y0 34
  368. #define OP_Y1 35
  369. #define OP_YN 36
  370. #define OP_LOGB 37
  371. #define OP_NEXTAFTER 38
  372. #define OP_NEG 39
  373. #endif /* #ifndef __assembler */
  374. #endif /* _INTERNAL_IFSTRIP_ */
  375. /*
  376. * Define rounding modes.
  377. */
  378. #ifndef __assembler /* MIPS ONLY: Protect from assembler */
  379. typedef enum {
  380. _FpRoundNearest,
  381. _FpRoundMinusInfinity,
  382. _FpRoundPlusInfinity,
  383. _FpRoundChopped
  384. } _FPIEEE_ROUNDING_MODE;
  385. typedef enum {
  386. _FpPrecisionFull,
  387. _FpPrecision53,
  388. _FpPrecision24,
  389. #if defined(_M_IA64)
  390. _FpPrecision64,
  391. _FpPrecision113
  392. #endif
  393. } _FPIEEE_PRECISION;
  394. /*
  395. * Define floating point context record
  396. */
  397. typedef float _FP32;
  398. typedef double _FP64;
  399. typedef short _I16;
  400. typedef int _I32;
  401. typedef unsigned short _U16;
  402. typedef unsigned int _U32;
  403. typedef __int64 _Q64;
  404. #ifndef _INTERNAL_IFSTRIP_
  405. typedef struct {
  406. unsigned long W[4];
  407. } _U32ARRAY;
  408. #endif /* _INTERNAL_IFSTRIP_ */
  409. typedef struct
  410. #if defined(_M_IA64)
  411. __declspec(align(16))
  412. #endif
  413. {
  414. unsigned short W[5];
  415. } _FP80;
  416. typedef struct __declspec(align(16))
  417. {
  418. unsigned long W[4];
  419. } _FP128;
  420. typedef struct __declspec(align(8))
  421. {
  422. unsigned long W[2];
  423. } _I64;
  424. typedef struct __declspec(align(8))
  425. {
  426. unsigned long W[2];
  427. } _U64;
  428. typedef struct
  429. #if defined(_M_IA64)
  430. __declspec(align(16))
  431. #endif
  432. {
  433. unsigned short W[5];
  434. } _BCD80;
  435. typedef struct __declspec(align(16))
  436. {
  437. _Q64 W[2];
  438. } _FPQ64;
  439. typedef struct {
  440. union {
  441. _FP32 Fp32Value;
  442. _FP64 Fp64Value;
  443. _FP80 Fp80Value;
  444. _FP128 Fp128Value;
  445. _I16 I16Value;
  446. _I32 I32Value;
  447. _I64 I64Value;
  448. _U16 U16Value;
  449. _U32 U32Value;
  450. _U64 U64Value;
  451. _BCD80 Bcd80Value;
  452. char *StringValue;
  453. int CompareValue;
  454. #ifndef _INTERNAL_IFSTRIP_
  455. _U32ARRAY U32ArrayValue;
  456. #endif /* _INTERNAL_IFSTRIP_ */
  457. _Q64 Q64Value;
  458. _FPQ64 Fpq64Value;
  459. } Value;
  460. unsigned int OperandValid : 1;
  461. unsigned int Format : 4;
  462. } _FPIEEE_VALUE;
  463. typedef struct {
  464. unsigned int Inexact : 1;
  465. unsigned int Underflow : 1;
  466. unsigned int Overflow : 1;
  467. unsigned int ZeroDivide : 1;
  468. unsigned int InvalidOperation : 1;
  469. } _FPIEEE_EXCEPTION_FLAGS;
  470. typedef struct {
  471. unsigned int RoundingMode : 2;
  472. unsigned int Precision : 3;
  473. unsigned int Operation :12;
  474. _FPIEEE_EXCEPTION_FLAGS Cause;
  475. _FPIEEE_EXCEPTION_FLAGS Enable;
  476. _FPIEEE_EXCEPTION_FLAGS Status;
  477. _FPIEEE_VALUE Operand1;
  478. _FPIEEE_VALUE Operand2;
  479. _FPIEEE_VALUE Result;
  480. #if defined(_M_IA64)
  481. _FPIEEE_VALUE Operand3;
  482. #endif
  483. } _FPIEEE_RECORD, *_PFPIEEE_RECORD;
  484. struct _EXCEPTION_POINTERS;
  485. /*
  486. * Floating point IEEE exception filter routine
  487. */
  488. _CRTIMP int __cdecl _fpieee_flt(
  489. unsigned long,
  490. struct _EXCEPTION_POINTERS *,
  491. int (__cdecl *)(_FPIEEE_RECORD *)
  492. );
  493. #ifdef __cplusplus
  494. }
  495. #endif
  496. #ifdef _MSC_VER
  497. #pragma pack(pop)
  498. #endif /* _MSC_VER */
  499. #endif /* #ifndef __assembler */
  500. #endif /* _INC_FPIEEE */