ReactOS  0.4.15-dev-5496-g599ba9c
_control87.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS CRT
3  * LICENSE: MIT (https://spdx.org/licenses/MIT)
4  * PURPOSE: Implementation of _control87
5  * COPYRIGHT: Copyright 2022 Timo Kreuzer <timo.kreuzer@reactos.org>
6  */
7 
8 #include <xmmintrin.h>
9 #include <float.h>
10 
11 unsigned int _get_native_fpcw(void);
12 void _set_native_fpcw(unsigned int value);
13 unsigned int _fpcw_native_to_abstract(unsigned int native);
14 unsigned int _fpcw_abstract_to_native(unsigned int abstract);
15 
16 unsigned int __cdecl _control87(unsigned int newval, unsigned int mask)
17 {
18  unsigned int native, oldval, updated;
19 
20  /* Sanatize the mask */
21  mask &= _MCW_DN | _MCW_EM | _MCW_RC;
22 
23  /* Get native control word */
24  native = _get_native_fpcw();
25 
26  /* Convert to abstract */
27  oldval = _fpcw_native_to_abstract(native);
28 
29  /* Update it according to the given parameters */
30  updated = (oldval & ~mask) | (newval & mask);
31 
32  /* Convert back to native */
33  native = _fpcw_abstract_to_native(updated);
34 
35  /* Set the native value */
36  _set_native_fpcw(native);
37 
38  return updated;
39 }
Definition: pdh_main.c:93
#define __cdecl
Definition: accygwin.h:79
unsigned int _fpcw_native_to_abstract(unsigned int native)
Definition: machfpcw.c:23
#define _MCW_EM
Definition: float.h:40
GLenum GLint GLuint mask
Definition: glext.h:6028
unsigned int _fpcw_abstract_to_native(unsigned int abstract)
Definition: machfpcw.c:69
unsigned int __cdecl _control87(unsigned int newval, unsigned int mask)
Definition: _control87.c:16
unsigned int _get_native_fpcw(void)
Definition: machfpcw.c:13
void _set_native_fpcw(unsigned int value)
Definition: machfpcw.c:18
#define _MCW_DN
Definition: float.h:44
#define _MCW_RC
Definition: float.h:42