Rebase against 4e2ad334b5881af7661be4d6df3c51aae92ca4a2

This commit is contained in:
Alistair Leslie-Hughes
2020-05-05 09:11:37 +10:00
committed by Zebediah Figura
parent d4918b4305
commit 76ba9d2387
27 changed files with 209 additions and 302 deletions

View File

@@ -1,90 +0,0 @@
From 334c3d93fc14f11be5b750c539f61a9ae88a943f Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 5 Aug 2017 03:37:47 +0200
Subject: [PATCH] include: Move interlocked_inc/dec to port.h.
---
dlls/ntdll/critsection.c | 10 ----------
dlls/ntdll/threadpool.c | 10 ----------
include/wine/port.h | 14 +++++++++++++-
3 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index 1892d3abcb7..95acc321240 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -40,16 +40,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
WINE_DECLARE_DEBUG_CHANNEL(relay);
-static inline LONG interlocked_inc( PLONG dest )
-{
- return interlocked_xchg_add( dest, 1 ) + 1;
-}
-
-static inline LONG interlocked_dec( PLONG dest )
-{
- return interlocked_xchg_add( dest, -1 ) - 1;
-}
-
static inline void small_pause(void)
{
#ifdef __i386__
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index 215a5e9c53a..6ee739b9c02 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -378,16 +378,6 @@ static void tp_object_prepare_shutdown( struct threadpool_object *object );
static BOOL tp_object_release( struct threadpool_object *object );
static struct threadpool *default_threadpool = NULL;
-static inline LONG interlocked_inc( PLONG dest )
-{
- return interlocked_xchg_add( dest, 1 ) + 1;
-}
-
-static inline LONG interlocked_dec( PLONG dest )
-{
- return interlocked_xchg_add( dest, -1 ) - 1;
-}
-
static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
{
unsigned int new_capacity, max_capacity;
diff --git a/include/wine/port.h b/include/wine/port.h
index 8514a4a43bf..60c95af6cb5 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -479,6 +479,16 @@ static inline __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int6
extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
#endif
+static inline int interlocked_inc( int *dest )
+{
+ return interlocked_xchg_add( dest, 1 ) + 1;
+}
+
+static inline int interlocked_dec( int *dest )
+{
+ return interlocked_xchg_add( dest, -1 ) - 1;
+}
+
#else /* NO_LIBWINE_PORT */
#define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
@@ -489,9 +499,11 @@ extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compa
#define getopt_long_only __WINE_NOT_PORTABLE(getopt_long_only)
#define interlocked_cmpxchg __WINE_NOT_PORTABLE(interlocked_cmpxchg)
#define interlocked_cmpxchg_ptr __WINE_NOT_PORTABLE(interlocked_cmpxchg_ptr)
+#define interlocked_dec __WINE_NOT_PORTABLE(interlocked_dec)
+#define interlocked_inc __WINE_NOT_PORTABLE(interlocked_inc)
#define interlocked_xchg __WINE_NOT_PORTABLE(interlocked_xchg)
-#define interlocked_xchg_ptr __WINE_NOT_PORTABLE(interlocked_xchg_ptr)
#define interlocked_xchg_add __WINE_NOT_PORTABLE(interlocked_xchg_add)
+#define interlocked_xchg_ptr __WINE_NOT_PORTABLE(interlocked_xchg_ptr)
#define lstat __WINE_NOT_PORTABLE(lstat)
#define pread __WINE_NOT_PORTABLE(pread)
#define pwrite __WINE_NOT_PORTABLE(pwrite)
--
2.26.0

View File

@@ -29,7 +29,7 @@ index 84866721a07..303cad1764a 100644
+/* inline version of RtlEnterCriticalSection */
+static inline void enter_critical_section( RTL_CRITICAL_SECTION *crit )
+{
+ if (interlocked_inc( &crit->LockCount ))
+ if (InterlockedIncrement( &crit->LockCount ))
+ {
+ if (crit->OwningThread == ULongToHandle(GetCurrentThreadId()))
+ {
@@ -48,13 +48,13 @@ index 84866721a07..303cad1764a 100644
+ WINE_DECLARE_DEBUG_CHANNEL(ntdll);
+ if (--crit->RecursionCount)
+ {
+ if (crit->RecursionCount > 0) interlocked_dec( &crit->LockCount );
+ if (crit->RecursionCount > 0) InterlockedDecrement( &crit->LockCount );
+ else ERR_(ntdll)( "section %p is not acquired\n", crit );
+ }
+ else
+ {
+ crit->OwningThread = 0;
+ if (interlocked_dec( &crit->LockCount ) >= 0)
+ if (InterlockedDecrement( &crit->LockCount ) >= 0)
+ RtlpUnWaitCriticalSection( crit );
+ }
+}

View File

@@ -1,4 +1,4 @@
From 7fb74639d7598c653bbd70fef5c58c9a1c1541d3 Mon Sep 17 00:00:00 2001
From 7dcc94642b6771f949fa2ff747a2f992e862157d Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 5 Aug 2017 03:39:37 +0200
Subject: [PATCH] ntdll: Use fast CS functions for threadpool locking.
@@ -8,7 +8,7 @@ Subject: [PATCH] ntdll: Use fast CS functions for threadpool locking.
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index 6ee739b9c02..94d6efced9e 100644
index 451d441f5725..253a13002950 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -1279,7 +1279,7 @@ static void CALLBACK timerqueue_thread_proc( void *param )
@@ -176,7 +176,7 @@ index 6ee739b9c02..94d6efced9e 100644
@@ -2125,10 +2125,10 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa
struct threadpool_group *group = object->group;
interlocked_inc( &group->refcount );
InterlockedIncrement( &group->refcount );
- RtlEnterCriticalSection( &group->cs );
+ enter_critical_section( &group->cs );
@@ -413,5 +413,5 @@ index 6ee739b9c02..94d6efced9e 100644
if (submit_wait)
tp_object_submit( this, FALSE );
--
2.26.0
2.26.2