xref: /reactos/sdk/lib/crt/float/i386/statfp.c (revision 1734f297)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/sdk/crt/float/i386/statfp.c
5  * PURPOSE:     Unknown
6  * PROGRAMER:   Unknown
7  * UPDATE HISTORY:
8  *              25/11/05: Added license header
9  */
10 
11 #include <precomp.h>
12 #include "float.h"
13 
14 //WTF IS HAPPENING WITH float.h !??!?!
15 #define _SW_INVALID    0x00000010 /* invalid */
16 #define _SW_ZERODIVIDE 0x00000008 /* zero divide */
17 #define _SW_UNDERFLOW  0x00000002 /* underflow */
18 #define _SW_OVERFLOW   0x00000004 /* overflow */
19 #define _SW_INEXACT    0x00000001 /* inexact (precision) */
20 #define _SW_DENORMAL    0x00080000 /* denormal status bit */
21 
22 /**********************************************************************
23  *		_statusfp (MSVCRT.@)
24  */
25 unsigned int CDECL _statusfp(void)
26 {
27   unsigned int retVal = 0;
28   unsigned short fpword;
29 
30 #ifdef _M_AMD64
31     fpword = _mm_getcsr();
32 #elif defined(__GNUC__)
33   __asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
34 #else // _MSC_VER
35   __asm fstsw [fpword];
36 #endif
37   if (fpword & 0x1)  retVal |= _SW_INVALID;
38   if (fpword & 0x2)  retVal |= _SW_DENORMAL;
39   if (fpword & 0x4)  retVal |= _SW_ZERODIVIDE;
40   if (fpword & 0x8)  retVal |= _SW_OVERFLOW;
41   if (fpword & 0x10) retVal |= _SW_UNDERFLOW;
42   if (fpword & 0x20) retVal |= _SW_INEXACT;
43   return retVal;
44 }
45