Reactos

[UCRT] Fix/improve __crt_state_management

+49 -10
+49 -10
sdk/lib/ucrt/inc/corecrt_internal_state_isolation.h
··· 15 15 { 16 16 namespace __crt_state_management 17 17 { 18 + #ifdef _CRT_GLOBAL_STATE_ISOLATION 19 + #error FIXME: Global state isolation is not implemented yet 18 20 constexpr size_t state_index_count = 2; 21 + #else 22 + constexpr size_t state_index_count = 1; 23 + #endif 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 - }; // FIXME: Implement this 29 + }; 30 + 24 31 template <typename T> 25 32 class dual_state_global 26 33 { 27 - T _value[2]; 34 + T _value[state_index_count]; 35 + 28 36 public: 37 + 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 - T& value(void) throw() { return _value[0]; } 32 - T value_explicit(size_t index) throw() { return _value[index]; } 33 - T* dangerous_get_state_array() throw() { return _value; } 34 - void initialize(T) throw() { } 35 - template<typename T2> void uninitialize(T2) throw() { } 36 - template<typename T2, size_t N> void initialize_from_array(T2 const (&values)[N]) throw() { } 41 + 42 + T& value(void) throw() 43 + { 44 + return _value[0]; 45 + } 46 + 47 + T value_explicit(size_t index) throw() 48 + { 49 + return _value[index]; 50 + } 51 + 52 + T* dangerous_get_state_array() throw() 53 + { 54 + return _value; 55 + } 56 + 57 + void initialize(T x) throw() 58 + { 59 + _value[0] = x; 60 + } 61 + 62 + template<typename T2> 63 + void uninitialize(T2 Lambda) throw() 64 + { 65 + Lambda(_value[0]); 66 + } 67 + 68 + template<typename T2> 69 + void initialize_from_array(T2 (&values)[state_index_count]) throw() 70 + { 71 + for (size_t i = 0; i < state_index_count; i++) 72 + { 73 + _value[i] = values[i]; 74 + } 75 + } 37 76 }; 38 77 39 - inline int get_current_state_index(__crt_scoped_get_last_error_reset const &last_error_reset) 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 - inline int get_current_state_index(void) 83 + inline size_t get_current_state_index(void) 45 84 { 46 85 return 0; 47 86 }