Leaked source code of windows server 2003
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.

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