From 26d30c63154c5fb3258fd6d24959c12052999c7f Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 28 Feb 2017 11:21:12 +0100 Subject: [PATCH] msvcr110: Add _Lock_shared_ptr_spin_lock implementation. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcr110/msvcr110.spec | 4 ++-- dlls/msvcrt/lock.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index aba09196584..4897d796ed4 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -854,7 +854,7 @@ @ cdecl _Gettnames() @ extern _HUGE MSVCRT__HUGE @ cdecl _IsExceptionObjectToBeDestroyed(ptr) -@ stub _Lock_shared_ptr_spin_lock +@ cdecl _Lock_shared_ptr_spin_lock() @ stub -arch=i386 _NLG_Dispatch2 @ stub -arch=arm,win64 __NLG_Dispatch2 @ stub -arch=i386 _NLG_Return @@ -863,7 +863,7 @@ @ stub -arch=win64 _SetImageBase @ stub -arch=win64 _SetThrowImageBase @ cdecl _Strftime(str long str ptr ptr) -@ stub _Unlock_shared_ptr_spin_lock +@ cdecl _Unlock_shared_ptr_spin_lock() @ cdecl _W_Getdays() @ cdecl _W_Getmonths() @ cdecl _W_Gettnames() diff --git a/dlls/msvcrt/lock.c b/dlls/msvcrt/lock.c index 7e14ef9a6c0..3153ae1562c 100644 --- a/dlls/msvcrt/lock.c +++ b/dlls/msvcrt/lock.c @@ -1018,6 +1018,27 @@ MSVCRT_bool __thiscall _ReentrantBlockingLock__TryAcquire(_ReentrantBlockingLock } #endif +#if _MSVCR_VER == 110 +static LONG shared_ptr_lock; + +void __cdecl _Lock_shared_ptr_spin_lock(void) +{ + LONG l = 0; + + while(InterlockedCompareExchange(&shared_ptr_lock, 1, 0) != 0) { + if(l++ == 1000) { + Sleep(0); + l = 0; + } + } +} + +void __cdecl _Unlock_shared_ptr_spin_lock(void) +{ + shared_ptr_lock = 0; +} +#endif + /********************************************************************** * msvcrt_free_locks (internal) *