1 /***
2 *fpieee.h - Definitions for floating point IEEE exception handling
3 *
4 *           Copyright (c) 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
14 #pragma once
15 #ifndef __midl
16 #ifndef _INC_FPIEEE
17 #define _INC_FPIEEE
18
19 #if defined(_M_CEE_PURE)
20      #error ERROR: This file is not supported in the pure mode!
21 #else
22
23 #include <crtdefs.h>
24
25 #ifndef __assembler        /* MIPS ONLY: Protect from assembler */
26
27 #ifdef  _MSC_VER
28 /*
29  * Currently, all MS C compilers for Win32 platforms default to 8 byte
30  * alignment.
31  */
32 #pragma pack(push,_CRT_PACKING)
33
34 /* Disable C4324: structure was padded due to __declspec(align()) */
35 #pragma warning(push)
36 #pragma warning(disable: 4324)
37 #endif  /* _MSC_VER */
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /*
44  * Define floating point IEEE compare result values.
45  */
46
47 typedef enum {
48       _FpCompareEqual,
49       _FpCompareGreater,
50       _FpCompareLess,
51       _FpCompareUnordered
52 } _FPIEEE_COMPARE_RESULT;
53
54 /*
55  * Define floating point format and result precision values.
56  */
57
58 typedef enum {
59       _FpFormatFp32,
60       _FpFormatFp64,
61       _FpFormatFp80,
62       _FpFormatFp128,
63       _FpFormatI16,
64       _FpFormatI32,
65       _FpFormatI64,
66       _FpFormatU16,
67       _FpFormatU32,
68       _FpFormatU64,
69       _FpFormatBcd80,
70       _FpFormatCompare,
71       _FpFormatString,
72 #if defined(_M_IA64)
73       _FpFormatFp82
74 #endif
75 } _FPIEEE_FORMAT;
76
77 /*
78  * Define operation code values.
79  */
80
81 typedef enum {
82       _FpCodeUnspecified,
83       _FpCodeAdd,
84       _FpCodeSubtract,
85       _FpCodeMultiply,
86       _FpCodeDivide,
87       _FpCodeSquareRoot,
88       _FpCodeRemainder,
89       _FpCodeCompare,
90       _FpCodeConvert,
91       _FpCodeRound,
92       _FpCodeTruncate,
93       _FpCodeFloor,
94       _FpCodeCeil,
95       _FpCodeAcos,
96       _FpCodeAsin,
97       _FpCodeAtan,
98       _FpCodeAtan2,
99       _FpCodeCabs,
100       _FpCodeCos,
101       _FpCodeCosh,
102       _FpCodeExp,
103       _FpCodeFabs,
104       _FpCodeFmod,
105       _FpCodeFrexp,
106       _FpCodeHypot,
107       _FpCodeLdexp,
108       _FpCodeLog,
109       _FpCodeLog10,
110       _FpCodeModf,
111       _FpCodePow,
112       _FpCodeSin,
113       _FpCodeSinh,
114       _FpCodeTan,
115       _FpCodeTanh,
116       _FpCodeY0,
117       _FpCodeY1,
118       _FpCodeYn,
119       _FpCodeLogb,
120       _FpCodeNextafter,
121       _FpCodeNegate, 
122       _FpCodeFmin,               /* XMMI */
123       _FpCodeFmax,               /* XMMI */
124       _FpCodeConvertTrunc, /* XMMI */
125       _XMMIAddps,                /* XMMI */
126       _XMMIAddss,
Lines 127 ... 136 are skipped.
137       _XMMIMinps,
138       _XMMIMinss,
139       _XMMICmpps,
140       _XMMICmpss,
141       _XMMIComiss,
142       _XMMIUComiss,
143       _XMMICvtpi2ps,
144       _XMMICvtsi2ss,
145       _XMMICvtps2pi,
146       _XMMICvtss2si,
147       _XMMICvttps2pi,
148       _XMMICvttss2si,
149       _XMMIAddsubps,           /* XMMI for PNI */
150       _XMMIHaddps,               /* XMMI for PNI */
151       _XMMIHsubps,               /* XMMI for PNI */
152       _XMMIRoundps,             /* 66 0F 3A 08  */ 
153       _XMMIRoundss,             /* 66 0F 3A 0A  */
154       _XMMIDpps,                  /* 66 0F 3A 40  */
155       _XMMI2Addpd,               /* XMMI2 */ 
156       _XMMI2Addsd,
157       _XMMI2Subpd,
158       _XMMI2Subsd,
159       _XMMI2Mulpd,
160       _XMMI2Mulsd,
161       _XMMI2Divpd,
162       _XMMI2Divsd,
163       _XMMI2Sqrtpd,
164       _XMMI2Sqrtsd,
165       _XMMI2Maxpd,
166       _XMMI2Maxsd,
167       _XMMI2Minpd,
168       _XMMI2Minsd,
169       _XMMI2Cmppd,
170       _XMMI2Cmpsd,
171       _XMMI2Comisd,
172       _XMMI2UComisd,
173       _XMMI2Cvtpd2pi,     /* 66 2D */
174       _XMMI2Cvtsd2si,     /* F2 */
175       _XMMI2Cvttpd2pi,  /* 66 2C */
176       _XMMI2Cvttsd2si,  /* F2 */
177       _XMMI2Cvtps2pd,     /* 0F 5A */
178       _XMMI2Cvtss2sd,     /* F3 */
179       _XMMI2Cvtpd2ps,     /* 66 */
180       _XMMI2Cvtsd2ss,     /* F2 */
181       _XMMI2Cvtdq2ps,     /* 0F 5B */
182       _XMMI2Cvttps2dq,  /* F3 */
183       _XMMI2Cvtps2dq,     /* 66 */
184       _XMMI2Cvttpd2dq,  /* 66 0F E6 */
185       _XMMI2Cvtpd2dq,     /* F2 */
186       _XMMI2Addsubpd,     /* 66 0F D0 */
187       _XMMI2Haddpd,        /* 66 0F 7C */
188       _XMMI2Hsubpd,        /* 66 0F 7D */
189       _XMMI2Roundpd,      /* 66 0F 3A 09 */
190       _XMMI2Roundsd,      /* 66 0F 3A 0B */
191       _XMMI2Dppd,           /* 66 0F 3A 41 */
192 #if defined(_M_IA64)
193       _FpCodeFma,
194       _FpCodeFmaSingle,
195       _FpCodeFmaDouble,
196       _FpCodeFms,
197       _FpCodeFmsSingle,
198       _FpCodeFmsDouble,
199       _FpCodeFnma,
200       _FpCodeFnmaSingle,
201       _FpCodeFnmaDouble,
202       _FpCodeFamin,
203       _FpCodeFamax
204 #endif
205 } _FP_OPERATION_CODE;
206
207 #endif  /* #ifndef __assembler */
208
209 /*
210  * Define rounding modes.
211  */
212
213 #ifndef __assembler        /* MIPS ONLY: Protect from assembler */
214
215 typedef enum {
216       _FpRoundNearest,
217       _FpRoundMinusInfinity,
218       _FpRoundPlusInfinity,
219       _FpRoundChopped
220 } _FPIEEE_ROUNDING_MODE;
221
222 typedef enum {
223       _FpPrecisionFull,
224       _FpPrecision53,
225       _FpPrecision24,
226 #if defined(_M_IA64)
227       _FpPrecision64,
228       _FpPrecision113
229 #endif
230 } _FPIEEE_PRECISION;
231
232
233 /*
234  * Define floating point context record
235  */
236
237 typedef float                  _FP32;
238 typedef double                _FP64;
239 typedef short                  _I16;
240 typedef int                     _I32;
241 typedef unsigned short  _U16;
242 typedef unsigned int      _U32;
243 typedef __int64               _Q64;
244
245
246 typedef struct
247 #if defined(_M_IA64)
248       _CRT_ALIGN(16)
249 #endif
250 {
251       unsigned short W[5];
252 } _FP80;
253
254 typedef struct _CRT_ALIGN(16)
255 {
256       unsigned long W[4];
257 } _FP128;
258
259 typedef struct _CRT_ALIGN(8)
260 {
261       unsigned long W[2];
262 } _I64;
263
264 typedef struct _CRT_ALIGN(8)
265 {
266       unsigned long W[2];
267 } _U64;
268
269 typedef struct
270 #if defined(_M_IA64)
271       _CRT_ALIGN(16)
272 #endif
273 {
274       unsigned short W[5];
275 } _BCD80;
276
277 typedef struct _CRT_ALIGN(16)
278 {
279       _Q64 W[2];
280 } _FPQ64;
281
282 typedef struct {
283       union {
284              _FP32             Fp32Value;
285              _FP64             Fp64Value;
286              _FP80             Fp80Value;
287              _FP128           Fp128Value;
288              _I16               I16Value;
289              _I32               I32Value;
290              _I64               I64Value;
291              _U16               U16Value;
292              _U32               U32Value;
293              _U64               U64Value;
294              _BCD80           Bcd80Value;
295              char               *StringValue;
296              int                CompareValue;
297              _Q64               Q64Value;
298              _FPQ64           Fpq64Value;
299       } Value;
300
301       unsigned int OperandValid : 1;
302       unsigned int Format : 4;
303
304 } _FPIEEE_VALUE;
305
306
307 typedef struct {
308       unsigned int Inexact : 1;
309       unsigned int Underflow : 1;
310       unsigned int Overflow : 1;
311       unsigned int ZeroDivide : 1;
312       unsigned int InvalidOperation : 1;
313 } _FPIEEE_EXCEPTION_FLAGS;
314
315
316 typedef struct {
317       unsigned int RoundingMode : 2;
318       unsigned int Precision : 3;
319       unsigned int Operation :12;
320       _FPIEEE_EXCEPTION_FLAGS Cause;
321       _FPIEEE_EXCEPTION_FLAGS Enable;
322       _FPIEEE_EXCEPTION_FLAGS Status;
323       _FPIEEE_VALUE Operand1;
324       _FPIEEE_VALUE Operand2;
325       _FPIEEE_VALUE Result;
326 #if defined(_M_IA64)
327       _FPIEEE_VALUE Operand3;
328 #endif
329 } _FPIEEE_RECORD, *_PFPIEEE_RECORD;
330
331
332 struct _EXCEPTION_POINTERS;
333
334 /*
335  * Floating point IEEE exception filter routine
336  */
337
338 _CRTIMP int __cdecl _fpieee_flt(
339              _In_ unsigned long _ExceptionCode,
340              _In_ struct _EXCEPTION_POINTERS * _PtExceptionPtr,
341              _In_ int (__cdecl * _Handler)(_FPIEEE_RECORD *)
342              );
343
344 #ifdef  __cplusplus
345 }
346 #endif  /* __cplusplus */
347
348 #if _MSC_VER >= 1400 && defined(__cplusplus) && defined(_M_CEE)
349 _MRTIMP int __cdecl _fpieee_flt(
350              _In_ unsigned long _ExceptionCode,
351              _In_ struct _EXCEPTION_POINTERS * _PtExceptionPtr,
352              _In_ int (__clrcall * _Handler)(_FPIEEE_RECORD *)
353              );
354 #endif  /* _MSC_VER >= 1400 && defined(__cplusplus) && defined(_M_CEE) */
355
356 #ifdef  _MSC_VER
357 #pragma warning(pop)
358 #pragma pack(pop)
359 #endif  /* _MSC_VER */
360 #endif  /* #ifndef __assembler */
361
362 #endif /* defined(_M_CEE_PURE) */
363
364 #endif
365 #endif
366