ReactOS 0.4.16-dev-320-g3bd9ddc
_control87.c File Reference
#include <xmmintrin.h>
#include <float.h>
Include dependency graph for _control87.c:

Go to the source code of this file.

Functions

unsigned int _get_native_fpcw (void)
 
void _set_native_fpcw (unsigned int value)
 
unsigned int _fpcw_native_to_abstract (unsigned int native)
 
unsigned int _fpcw_abstract_to_native (unsigned int abstract)
 
unsigned int __cdecl _control87 (unsigned int newval, unsigned int mask)
 

Function Documentation

◆ _control87()

unsigned int __cdecl _control87 ( unsigned int  newval,
unsigned int  mask 
)

Definition at line 16 of file _control87.c.

17{
18 unsigned int native, oldval, updated;
19
20 /* Sanatize the mask */
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}
unsigned int _fpcw_native_to_abstract(unsigned int native)
Definition: machfpcw.c:23
void _set_native_fpcw(unsigned int value)
Definition: machfpcw.c:18
unsigned int _fpcw_abstract_to_native(unsigned int abstract)
Definition: machfpcw.c:69
unsigned int _get_native_fpcw(void)
Definition: machfpcw.c:13
GLenum GLint GLuint mask
Definition: glext.h:6028
#define _MCW_EM
Definition: float.h:40
#define _MCW_RC
Definition: float.h:42
#define _MCW_DN
Definition: float.h:44

◆ _fpcw_abstract_to_native()

unsigned int _fpcw_abstract_to_native ( unsigned int  abstract)

Definition at line 69 of file machfpcw.c.

70{
71 unsigned int rounding_mask, native = 0;
72
73 /* Handle exception mask */
75 native |= _MM_MASK_INVALID;
77 native |= _MM_MASK_DENORM;
79 native |= _MM_MASK_DIV_ZERO;
81 native |= _MM_MASK_OVERFLOW;
83 native |= _MM_MASK_UNDERFLOW;
85 native |= _MM_MASK_INEXACT;
86
87 /* Handle rounding mode */
88 rounding_mask = (abstract & _MCW_RC);
89 if (rounding_mask == _RC_DOWN)
90 native |= _MM_ROUND_DOWN;
91 else if (rounding_mask == _RC_UP)
92 native |= _MM_ROUND_UP;
93 else if (rounding_mask == _RC_CHOP)
94 native |= _MM_ROUND_TOWARD_ZERO;
95
96 /* Handle Denormal Control */
97 if ((abstract & _MCW_DN) == _DN_FLUSH)
98 {
100 }
102 {
103 native |= _MM_DENORMALS_ARE_ZERO;
104 }
106 {
107 native |= _MM_FLUSH_ZERO_MASK;
108 }
109
110 return native;
111}
#define _DN_SAVE_OPERANDS_FLUSH_RESULTS
Definition: float.h:65
#define _RC_UP
Definition: float.h:56
#define _EM_UNDERFLOW
Definition: float.h:51
#define _EM_ZERODIVIDE
Definition: float.h:49
#define _EM_INEXACT
Definition: float.h:52
#define _EM_OVERFLOW
Definition: float.h:50
#define _EM_INVALID
Definition: float.h:47
#define _DN_FLUSH
Definition: float.h:63
#define _DN_FLUSH_OPERANDS_SAVE_RESULTS
Definition: float.h:64
#define _EM_DENORMAL
Definition: float.h:48
#define _RC_DOWN
Definition: float.h:57
#define _RC_CHOP
Definition: float.h:55
#define _MM_DENORMALS_ARE_ZERO
Definition: machfpcw.c:11
char * abstract
#define _MM_MASK_INVALID
Definition: xmmintrin.h:102
#define _MM_MASK_DENORM
Definition: xmmintrin.h:103
#define _MM_FLUSH_ZERO_MASK
Definition: xmmintrin.h:115
#define _MM_ROUND_DOWN
Definition: xmmintrin.h:111
#define _MM_MASK_DIV_ZERO
Definition: xmmintrin.h:104
#define _MM_ROUND_UP
Definition: xmmintrin.h:112
#define _MM_ROUND_TOWARD_ZERO
Definition: xmmintrin.h:113
#define _MM_MASK_OVERFLOW
Definition: xmmintrin.h:105
#define _MM_MASK_INEXACT
Definition: xmmintrin.h:107
#define _MM_MASK_UNDERFLOW
Definition: xmmintrin.h:106

Referenced by _control87().

◆ _fpcw_native_to_abstract()

unsigned int _fpcw_native_to_abstract ( unsigned int  native)

Definition at line 23 of file machfpcw.c.

24{
25 unsigned int rounding_mask, abstract = 0;
26
27 /* Handle exception mask */
28 if (native & _MM_MASK_INVALID)
30 if (native & _MM_MASK_DENORM)
32 if (native & _MM_MASK_DIV_ZERO)
34 if (native & _MM_MASK_OVERFLOW)
36 if (native & _MM_MASK_UNDERFLOW)
38 if (native & _MM_MASK_INEXACT)
40
41 /* Handle rounding mode */
42 rounding_mask = (native & _MM_ROUND_MASK);
43 if (rounding_mask == _MM_ROUND_DOWN)
45 else if(rounding_mask == _MM_ROUND_UP)
47 else if (rounding_mask == _MM_ROUND_TOWARD_ZERO)
49
50 /* Handle denormal control */
51 if (native & _MM_DENORMALS_ARE_ZERO)
52 {
53 if (native & _MM_FLUSH_ZERO_MASK)
55 else
57 }
58 else
59 {
60 if (native & _MM_FLUSH_ZERO_MASK)
62 else
64 }
65
66 return abstract;
67}
#define _DN_SAVE
Definition: float.h:62
#define _MM_ROUND_MASK
Definition: xmmintrin.h:109

Referenced by _control87().

◆ _get_native_fpcw()

unsigned int _get_native_fpcw ( void  )

Definition at line 13 of file machfpcw.c.

14{
15 return _mm_getcsr();
16}
unsigned int _mm_getcsr(void)
Definition: xmmintrin.h:535

Referenced by _control87().

◆ _set_native_fpcw()

void _set_native_fpcw ( unsigned int  value)

Definition at line 18 of file machfpcw.c.

19{
21}
Definition: pdh_main.c:94
void _mm_setcsr(unsigned int a)
Definition: xmmintrin.h:542

Referenced by _control87().