From a30a9380a1a7a72657a4b5e3f86d94411f4df076 Mon Sep 17 00:00:00 2001 From: Hua Meng <161220092@smail.nju.edu.cn> Date: Thu, 2 Aug 2018 23:38:20 +0800 Subject: [PATCH] msvcp90: Add implementation of _Concurrent_vector_Internal_assign. Signed-off-by: Hua Meng <161220092@smail.nju.edu.cn> Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcp90/misc.c | 74 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 12 deletions(-) diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index dcb29d4825c..622888541a1 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -1912,18 +1912,6 @@ void __thiscall _Concurrent_vector_base_v4_dtor( free(this->segment); } -/* ?_Internal_assign@_Concurrent_vector_base_v4@details@Concurrency@@IAEXABV123@IP6AXPAXI@ZP6AX1PBXI@Z4@Z */ -/* ?_Internal_assign@_Concurrent_vector_base_v4@details@Concurrency@@IEAAXAEBV123@_KP6AXPEAX1@ZP6AX2PEBX1@Z5@Z */ -DEFINE_THISCALL_WRAPPER(_Concurrent_vector_base_v4__Internal_assign, 24) -void __thiscall _Concurrent_vector_base_v4__Internal_assign( - _Concurrent_vector_base_v4 *this, const _Concurrent_vector_base_v4 *v, - MSVCP_size_t len, void (__cdecl *func0)(void*, MSVCP_size_t), - void (__cdecl *func1)(void*, const void*, MSVCP_size_t), - void (__cdecl *func2)(void*, const void*, MSVCP_size_t)) -{ - FIXME("(%p %p %ld %p %p %p) stub\n", this, v, len, func0, func1, func2); -} - /* ?_Internal_capacity@_Concurrent_vector_base_v4@details@Concurrency@@IBEIXZ */ /* ?_Internal_capacity@_Concurrent_vector_base_v4@details@Concurrency@@IEBA_KXZ */ DEFINE_THISCALL_WRAPPER(_Concurrent_vector_base_v4__Internal_capacity, 4) @@ -2043,6 +2031,68 @@ void __thiscall _Concurrent_vector_base_v4__Internal_copy( this->early_size = v_size; } +/* ?_Internal_assign@_Concurrent_vector_base_v4@details@Concurrency@@IAEXABV123@IP6AXPAXI@ZP6AX1PBXI@Z4@Z */ +/* ?_Internal_assign@_Concurrent_vector_base_v4@details@Concurrency@@IEAAXAEBV123@_KP6AXPEAX1@ZP6AX2PEBX1@Z5@Z */ +DEFINE_THISCALL_WRAPPER(_Concurrent_vector_base_v4__Internal_assign, 24) +void __thiscall _Concurrent_vector_base_v4__Internal_assign( + _Concurrent_vector_base_v4 *this, const _Concurrent_vector_base_v4 *v, + MSVCP_size_t element_size, void (__cdecl *clear)(void*, MSVCP_size_t), + void (__cdecl *assign)(void*, const void*, MSVCP_size_t), + void (__cdecl *copy)(void*, const void*, MSVCP_size_t)) +{ + MSVCP_size_t v_size, seg_no, v_seg_no, remain_element; + int i; + + TRACE("(%p %p %ld %p %p %p)\n", this, v, element_size, clear, assign, copy); + + v_size = v->early_size; + if(!v_size) { + _Concurrent_vector_base_v4__Internal_clear(this, clear); + return; + } + if(!this->early_size) { + _Concurrent_vector_base_v4__Internal_copy(this, v, element_size, copy); + return; + } + seg_no = _vector_base_v4__Segment_index_of(this->early_size - 1); + v_seg_no = _vector_base_v4__Segment_index_of(v_size - 1); + + for(i = 0; i < min(seg_no, v_seg_no); i++) + assign(this->segment[i], v->segment[i], i ? 1 << i : 2); + remain_element = min(this->early_size, v_size) - (1 << i & ~1); + if(remain_element != 0) + assign(this->segment[i], v->segment[i], remain_element); + + if(this->early_size > v_size) + { + if((i ? 1 << i : 2) - remain_element > 0) + clear((BYTE**)this->segment[i] + element_size * remain_element, + (i ? 1 << i : 2) - remain_element); + if(i < seg_no) + { + for(i++; i < seg_no; i++) + clear(this->segment[i], 1 << i); + clear(this->segment[i], this->early_size - (1 << i)); + } + } + else if(this->early_size < v_size) + { + if((i ? 1 << i : 2) - remain_element > 0) + copy((BYTE**)this->segment[i] + element_size * remain_element, + (BYTE**)v->segment[i] + element_size * remain_element, + (i ? 1 << i : 2) - remain_element); + if(i < v_seg_no) + { + _Concurrent_vector_base_v4__Internal_reserve(this, v_size, + element_size, MSVCP_SIZE_T_MAX / element_size); + for(i++; i < v_seg_no; i++) + copy(this->segment[i], v->segment[i], 1 << i); + copy(this->segment[i], v->segment[i], v->early_size - (1 << i)); + } + } + this->early_size = v_size; +} + /* ?_Internal_grow_by@_Concurrent_vector_base_v4@details@Concurrency@@IAEIIIP6AXPAXPBXI@Z1@Z */ /* ?_Internal_grow_by@_Concurrent_vector_base_v4@details@Concurrency@@IEAA_K_K0P6AXPEAXPEBX0@Z2@Z */ DEFINE_THISCALL_WRAPPER(_Concurrent_vector_base_v4__Internal_grow_by, 20)