2023-11-15 16:07:12 -08:00
|
|
|
From 4dd82c635bcf8c2c7d070d6c5786787ff2d7d887 Mon Sep 17 00:00:00 2001
|
2017-08-05 21:14:42 -07:00
|
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
|
|
|
Date: Sat, 5 Aug 2017 03:38:38 +0200
|
2019-05-14 15:00:59 -07:00
|
|
|
Subject: [PATCH] ntdll: Add inline versions of RtlEnterCriticalSection /
|
2017-08-05 21:14:42 -07:00
|
|
|
RtlLeaveCriticalSections.
|
|
|
|
|
|
|
|
---
|
2020-06-30 15:11:27 -07:00
|
|
|
dlls/ntdll/ntdll_misc.h | 34 ++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 34 insertions(+)
|
2017-08-05 21:14:42 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
|
2023-11-15 16:07:12 -08:00
|
|
|
index a7967a6c242..8b088f9d3c3 100644
|
2017-08-05 21:14:42 -07:00
|
|
|
--- a/dlls/ntdll/ntdll_misc.h
|
|
|
|
+++ b/dlls/ntdll/ntdll_misc.h
|
2023-11-15 16:07:12 -08:00
|
|
|
@@ -28,6 +28,7 @@
|
2017-08-05 21:14:42 -07:00
|
|
|
#include "winnt.h"
|
|
|
|
#include "winternl.h"
|
2020-05-14 17:00:49 -07:00
|
|
|
#include "unixlib.h"
|
2017-08-05 21:14:42 -07:00
|
|
|
+#include "wine/debug.h"
|
2019-05-14 15:00:59 -07:00
|
|
|
#include "wine/asm.h"
|
2017-08-05 21:14:42 -07:00
|
|
|
|
2021-02-16 14:56:43 -08:00
|
|
|
#define DECLARE_CRITICAL_SECTION(cs) \
|
2023-11-15 16:07:12 -08:00
|
|
|
@@ -94,6 +95,39 @@ extern struct _KUSER_SHARED_DATA *user_shared_data;
|
|
|
|
extern int CDECL NTDLL__vsnprintf( char *str, SIZE_T len, const char *format, va_list args );
|
|
|
|
extern int CDECL NTDLL__vsnwprintf( WCHAR *str, SIZE_T len, const WCHAR *format, va_list args );
|
2017-08-05 21:14:42 -07:00
|
|
|
|
|
|
|
+/* inline version of RtlEnterCriticalSection */
|
|
|
|
+static inline void enter_critical_section( RTL_CRITICAL_SECTION *crit )
|
|
|
|
+{
|
2020-05-04 16:11:37 -07:00
|
|
|
+ if (InterlockedIncrement( &crit->LockCount ))
|
2017-08-05 21:14:42 -07:00
|
|
|
+ {
|
|
|
|
+ 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)
|
|
|
|
+ {
|
2020-05-04 16:11:37 -07:00
|
|
|
+ if (crit->RecursionCount > 0) InterlockedDecrement( &crit->LockCount );
|
2017-08-05 21:14:42 -07:00
|
|
|
+ else ERR_(ntdll)( "section %p is not acquired\n", crit );
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ crit->OwningThread = 0;
|
2020-05-04 16:11:37 -07:00
|
|
|
+ if (InterlockedDecrement( &crit->LockCount ) >= 0)
|
2017-08-05 21:14:42 -07:00
|
|
|
+ RtlpUnWaitCriticalSection( crit );
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2021-04-19 16:11:23 -07:00
|
|
|
struct dllredirect_data
|
|
|
|
{
|
|
|
|
ULONG size;
|
2017-08-05 21:14:42 -07:00
|
|
|
--
|
2023-11-15 16:07:12 -08:00
|
|
|
2.42.0
|
2017-08-05 21:14:42 -07:00
|
|
|
|