From 8a66af3afe22399e4baf9d9cb84d191234c2cfb1 Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Thu, 26 May 2016 20:52:21 -0700 Subject: [PATCH 4/4] msvcp140: Add _Mtx_init/destroy_in_situ initialize and destroy _Mtx_t in-place Signed-off-by: Daniel Lehman --- dlls/msvcp140/msvcp140.spec | 4 ++-- dlls/msvcp90/misc.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index 922aa9e..4184793 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -3675,10 +3675,10 @@ @ stub _Mtx_clear_owner @ cdecl _Mtx_current_owns(ptr) msvcp110._Mtx_current_owns @ cdecl _Mtx_destroy(ptr) _Mtx_destroy -@ stub _Mtx_destroy_in_situ +@ cdecl _Mtx_destroy_in_situ(ptr) _Mtx_destroy_in_situ @ cdecl _Mtx_getconcrtcs(ptr) _Mtx_getconcrtcs @ cdecl _Mtx_init(ptr long) _Mtx_init -@ stub _Mtx_init_in_situ +@ cdecl _Mtx_init_in_situ(ptr long) _Mtx_init_in_situ @ cdecl _Mtx_lock(ptr) _Mtx_lock @ stub _Mtx_reset_owner @ stub _Mtx_timedlock diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index ab03d2e..d2d2b83 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -478,19 +478,29 @@ typedef _Mtx_t *_Mtx_arg_t; #define MTX_T_TO_ARG(m) (&(m)) #endif -int __cdecl _Mtx_init(_Mtx_t *mtx, int flags) +void __cdecl _Mtx_init_in_situ(_Mtx_t mtx, int flags) { if(flags & ~MTX_MULTI_LOCK) FIXME("unknown flags ignored: %x\n", flags); + mtx->flags = flags; + call_func1(critical_section_ctor, &mtx->cs); + mtx->thread_id = -1; + mtx->count = 0; +} + +int __cdecl _Mtx_init(_Mtx_t *mtx, int flags) +{ *mtx = MSVCRT_operator_new(sizeof(**mtx)); - (*mtx)->flags = flags; - call_func1(critical_section_ctor, &(*mtx)->cs); - (*mtx)->thread_id = -1; - (*mtx)->count = 0; + _Mtx_init_in_situ(*mtx, flags); return 0; } +void __cdecl _Mtx_destroy_in_situ(_Mtx_t mtx) +{ + call_func1(critical_section_dtor, &mtx->cs); +} + void __cdecl _Mtx_destroy(_Mtx_arg_t mtx) { call_func1(critical_section_dtor, &MTX_T_FROM_ARG(mtx)->cs); -- 1.9.5