tangled
alpha
login
or
join now
huwcampbell.com
/
reactos
0
fork
atom
Reactos
0
fork
atom
overview
issues
pulls
pipelines
[UCRT] Fix/improve __crt_state_management
Timo Kreuzer
1 year ago
e2ffc358
c2b1271d
+49
-10
1 changed file
expand all
collapse all
unified
split
sdk
lib
ucrt
inc
corecrt_internal_state_isolation.h
+49
-10
sdk/lib/ucrt/inc/corecrt_internal_state_isolation.h
···
15
15
{
16
16
namespace __crt_state_management
17
17
{
18
18
+
#ifdef _CRT_GLOBAL_STATE_ISOLATION
19
19
+
#error FIXME: Global state isolation is not implemented yet
18
20
constexpr size_t state_index_count = 2;
21
21
+
#else
22
22
+
constexpr size_t state_index_count = 1;
23
23
+
#endif
24
24
+
19
25
struct scoped_global_state_reset
20
26
{
21
27
scoped_global_state_reset() throw() { }
22
28
~scoped_global_state_reset() throw() { }
23
23
-
}; // FIXME: Implement this
29
29
+
};
30
30
+
24
31
template <typename T>
25
32
class dual_state_global
26
33
{
27
27
-
T _value[2];
34
34
+
T _value[state_index_count];
35
35
+
28
36
public:
37
37
+
38
38
+
// Implemented in corecrt_internal_ptd_propagation.h
29
39
T& value(__crt_cached_ptd_host& ptd) throw();
30
40
T const& value(__crt_cached_ptd_host& ptd) const throw();
31
31
-
T& value(void) throw() { return _value[0]; }
32
32
-
T value_explicit(size_t index) throw() { return _value[index]; }
33
33
-
T* dangerous_get_state_array() throw() { return _value; }
34
34
-
void initialize(T) throw() { }
35
35
-
template<typename T2> void uninitialize(T2) throw() { }
36
36
-
template<typename T2, size_t N> void initialize_from_array(T2 const (&values)[N]) throw() { }
41
41
+
42
42
+
T& value(void) throw()
43
43
+
{
44
44
+
return _value[0];
45
45
+
}
46
46
+
47
47
+
T value_explicit(size_t index) throw()
48
48
+
{
49
49
+
return _value[index];
50
50
+
}
51
51
+
52
52
+
T* dangerous_get_state_array() throw()
53
53
+
{
54
54
+
return _value;
55
55
+
}
56
56
+
57
57
+
void initialize(T x) throw()
58
58
+
{
59
59
+
_value[0] = x;
60
60
+
}
61
61
+
62
62
+
template<typename T2>
63
63
+
void uninitialize(T2 Lambda) throw()
64
64
+
{
65
65
+
Lambda(_value[0]);
66
66
+
}
67
67
+
68
68
+
template<typename T2>
69
69
+
void initialize_from_array(T2 (&values)[state_index_count]) throw()
70
70
+
{
71
71
+
for (size_t i = 0; i < state_index_count; i++)
72
72
+
{
73
73
+
_value[i] = values[i];
74
74
+
}
75
75
+
}
37
76
};
38
77
39
39
-
inline int get_current_state_index(__crt_scoped_get_last_error_reset const &last_error_reset)
78
78
+
inline size_t get_current_state_index(__crt_scoped_get_last_error_reset const &last_error_reset)
40
79
{
41
80
return 0;
42
81
}
43
82
44
44
-
inline int get_current_state_index(void)
83
83
+
inline size_t get_current_state_index(void)
45
84
{
46
85
return 0;
47
86
}