mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
66 lines
1.9 KiB
Diff
66 lines
1.9 KiB
Diff
From 49fa193ec777f68372b549752482ef82fb63a7b7 Mon Sep 17 00:00:00 2001
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
|
Date: Sat, 5 Aug 2017 03:38:38 +0200
|
|
Subject: [PATCH] ntdll: Add inline versions of RtlEnterCriticalSection /
|
|
RtlLeaveCriticalSections.
|
|
|
|
---
|
|
dlls/ntdll/ntdll_misc.h | 34 ++++++++++++++++++++++++++++++++++
|
|
1 file changed, 34 insertions(+)
|
|
|
|
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
|
|
index 171ded98c67..54a65e3bae5 100644
|
|
--- a/dlls/ntdll/ntdll_misc.h
|
|
+++ b/dlls/ntdll/ntdll_misc.h
|
|
@@ -29,6 +29,7 @@
|
|
#include "winternl.h"
|
|
#include "rtlsupportapi.h"
|
|
#include "unixlib.h"
|
|
+#include "wine/debug.h"
|
|
#include "wine/asm.h"
|
|
|
|
#define MAX_NT_PATH_LENGTH 277
|
|
@@ -106,6 +107,39 @@ extern void (FASTCALL *pBaseThreadInitThunk)(DWORD,LPTHREAD_START_ROUTINE,void *
|
|
|
|
extern struct _KUSER_SHARED_DATA *user_shared_data;
|
|
|
|
+/* inline version of RtlEnterCriticalSection */
|
|
+static inline void enter_critical_section( RTL_CRITICAL_SECTION *crit )
|
|
+{
|
|
+ if (InterlockedIncrement( &crit->LockCount ))
|
|
+ {
|
|
+ if (crit->OwningThread == ULongToHandle(GetCurrentThreadId()))
|
|
+ {
|
|
+ crit->RecursionCount++;
|
|
+ return;
|
|
+ }
|
|
+ RtlpWaitForCriticalSection( crit );
|
|
+ }
|
|
+ crit->OwningThread = ULongToHandle(GetCurrentThreadId());
|
|
+ crit->RecursionCount = 1;
|
|
+}
|
|
+
|
|
+/* inline version of RtlLeaveCriticalSection */
|
|
+static inline void leave_critical_section( RTL_CRITICAL_SECTION *crit )
|
|
+{
|
|
+ WINE_DECLARE_DEBUG_CHANNEL(ntdll);
|
|
+ if (--crit->RecursionCount)
|
|
+ {
|
|
+ if (crit->RecursionCount > 0) InterlockedDecrement( &crit->LockCount );
|
|
+ else ERR_(ntdll)( "section %p is not acquired\n", crit );
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ crit->OwningThread = 0;
|
|
+ if (InterlockedDecrement( &crit->LockCount ) >= 0)
|
|
+ RtlpUnWaitCriticalSection( crit );
|
|
+ }
|
|
+}
|
|
+
|
|
#ifdef _WIN64
|
|
static inline TEB64 *NtCurrentTeb64(void) { return NULL; }
|
|
#else
|
|
--
|
|
2.43.0
|
|
|