xref: /reactos/sdk/lib/crt/float/amd64/_statusfp.c (revision 84344399)
1 /*
2  * PROJECT:     ReactOS CRT
3  * LICENSE:     MIT (https://spdx.org/licenses/MIT)
4  * PURPOSE:     x64 implementation of _statusfp
5  * COPYRIGHT:   Copyright 2022 Timo Kreuzer <timo.kreuzer@reactos.org>
6  */
7 
8 #include <float.h>
9 #include <xmmintrin.h>
10 
11 unsigned int __cdecl _statusfp(void)
12 {
13     unsigned int mxcsr, status = 0;
14 
15     /* Get MXCSR */
16     mxcsr = _mm_getcsr();
17 
18     /* Convert to abstract status flags */
19     if (mxcsr & _MM_EXCEPT_INVALID)
20         status |= _SW_INVALID;
21     if (mxcsr & _MM_EXCEPT_DENORM)
22         status |= _SW_DENORMAL;
23     if (mxcsr & _MM_EXCEPT_DIV_ZERO)
24         status |= _SW_ZERODIVIDE;
25     if (mxcsr & _MM_EXCEPT_OVERFLOW)
26         status |= _SW_OVERFLOW;
27     if (mxcsr & _MM_EXCEPT_UNDERFLOW)
28         status |= _SW_UNDERFLOW;
29     if (mxcsr & _MM_EXCEPT_INEXACT)
30         status |= _SW_INEXACT;
31 
32     return status;
33 }
34