tangled
alpha
login
or
join now
huwcampbell.com
/
reactos
0
fork
atom
Reactos
0
fork
atom
overview
issues
pulls
pipelines
[CRT] Make _controlfp_s portable
Timo Kreuzer
2 years ago
994d5e0a
a17dd3a7
+32
-35
4 changed files
expand all
collapse all
unified
split
sdk
lib
crt
float
_controlfp_s.c
arm
_controlfp.c
float.cmake
i386
cntrlfp.c
+31
sdk/lib/crt/float/_controlfp_s.c
···
1
1
+
/*
2
2
+
* PROJECT: ReactOS CRT library
3
3
+
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4
4
+
* PURPOSE: Implementation of _controlfp_s (adapted from wine msvcrt/math.c)
5
5
+
* COPYRIGHT: Copyright 2000 Jon Griffiths
6
6
+
* Copyright 2010 Piotr Caban
7
7
+
* Copyright 2021 Roman Masanin <36927roma@gmail.com>
8
8
+
*/
9
9
+
10
10
+
#include <precomp.h>
11
11
+
#include <float.h>
12
12
+
13
13
+
#ifdef _M_ARM
14
14
+
#define INVALID_MASK ~(_MCW_EM | _MCW_RC | _MCW_DN)
15
15
+
#else
16
16
+
#define INVALID_MASK ~(_MCW_EM | _MCW_IC | _MCW_RC | _MCW_PC | _MCW_DN)
17
17
+
#endif
18
18
+
19
19
+
int CDECL _controlfp_s(unsigned int* cur, unsigned int newval, unsigned int mask)
20
20
+
{
21
21
+
unsigned int val;
22
22
+
23
23
+
if (!MSVCRT_CHECK_PMT((newval & mask & INVALID_MASK) == 0))
24
24
+
{
25
25
+
if (cur) *cur = _controlfp(0, 0); /* retrieve it anyway */
26
26
+
return EINVAL;
27
27
+
}
28
28
+
val = _controlfp(newval, mask);
29
29
+
if (cur) *cur = val;
30
30
+
return 0;
31
31
+
}
-13
sdk/lib/crt/float/arm/_controlfp.c
···
68
68
return flags;
69
69
}
70
70
71
71
-
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
72
72
-
{
73
73
-
unsigned int val;
74
74
-
75
75
-
if (!MSVCRT_CHECK_PMT( !(newval & mask & ~(_MCW_EM | _MCW_RC | _MCW_DN)) ))
76
76
-
{
77
77
-
if (cur) *cur = _controlfp(0, 0); /* retrieve it anyway */
78
78
-
return EINVAL;
79
79
-
}
80
80
-
val = _controlfp(newval, mask);
81
81
-
if (cur) *cur = val;
82
82
-
return 0;
83
83
-
}
+1
sdk/lib/crt/float/float.cmake
···
6
6
list(APPEND CRT_FLOAT_SOURCE
7
7
${LIBCNTPR_FLOAT_SOURCE}
8
8
float/chgsign.c
9
9
+
float/_controlfp_s.c
9
10
float/copysign.c
10
11
float/fpclass.c
11
12
float/fpecode.c
-22
sdk/lib/crt/float/i386/cntrlfp.c
···
113
113
114
114
return flags;
115
115
}
116
116
-
117
117
-
/*********************************************************************
118
118
-
* _controlfp_s (MSVCRT.@)
119
119
-
*/
120
120
-
int CDECL _controlfp_s(unsigned int *cur, unsigned int newval, unsigned int mask)
121
121
-
{
122
122
-
#ifdef __i386__
123
123
-
unsigned int val;
124
124
-
125
125
-
if (!MSVCRT_CHECK_PMT( !(newval & mask & ~(_MCW_EM | _MCW_IC | _MCW_RC | _MCW_PC | _MCW_DN))))
126
126
-
{
127
127
-
if (cur) *cur = _controlfp( 0, 0 ); /* retrieve it anyway */
128
128
-
return EINVAL;
129
129
-
}
130
130
-
val = _controlfp( newval, mask );
131
131
-
if (cur) *cur = val;
132
132
-
return 0;
133
133
-
#else
134
134
-
FIXME(":Not Implemented!\n");
135
135
-
return 0;
136
136
-
#endif
137
137
-
}