Rebase against 5e75310837e5ec77ebc361d689ea3279fa49ebac.

This commit is contained in:
Zebediah Figura
2020-04-13 18:10:11 -05:00
parent 4c160ec82a
commit 437038604a
8 changed files with 130 additions and 132 deletions

View File

@@ -1,4 +1,4 @@
From 32fbaef5e77e1fbe08ad35c933ff4ed7f61217f8 Mon Sep 17 00:00:00 2001
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.
@@ -10,7 +10,7 @@ Subject: [PATCH] include: Move interlocked_inc/dec to port.h.
3 files changed, 13 insertions(+), 21 deletions(-)
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index 42e432c8f65..6b17cebe058 100644
index 1892d3abcb7..95acc321240 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -40,16 +40,6 @@
@@ -31,10 +31,10 @@ index 42e432c8f65..6b17cebe058 100644
{
#ifdef __i386__
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index bf7449cdfa6..b8dc8273702 100644
index 215a5e9c53a..6ee739b9c02 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -331,16 +331,6 @@ static void tp_object_prepare_shutdown( struct threadpool_object *object );
@@ -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;
@@ -48,14 +48,14 @@ index bf7449cdfa6..b8dc8273702 100644
- return interlocked_xchg_add( dest, -1 ) - 1;
-}
-
static void CALLBACK process_rtl_work_item( TP_CALLBACK_INSTANCE *instance, void *userdata )
static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
{
struct rtl_work_item *item = userdata;
unsigned int new_capacity, max_capacity;
diff --git a/include/wine/port.h b/include/wine/port.h
index e32818e5455..470ba66cb50 100644
index 8514a4a43bf..60c95af6cb5 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -501,6 +501,16 @@ static inline __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int6
@@ -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
@@ -72,7 +72,7 @@ index e32818e5455..470ba66cb50 100644
#else /* NO_LIBWINE_PORT */
#define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable
@@ -511,9 +521,11 @@ extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compa
@@ -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)
@@ -86,5 +86,5 @@ index e32818e5455..470ba66cb50 100644
#define pread __WINE_NOT_PORTABLE(pread)
#define pwrite __WINE_NOT_PORTABLE(pwrite)
--
2.20.1
2.26.0

View File

@@ -1,17 +1,17 @@
From 858272e45212c9bbcbd121b6a5fc7f25358cd40f Mon Sep 17 00:00:00 2001
From 7fb74639d7598c653bbd70fef5c58c9a1c1541d3 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.
---
dlls/ntdll/threadpool.c | 96 ++++++++++++++++++++++++-------------------------
dlls/ntdll/threadpool.c | 96 ++++++++++++++++++++---------------------
1 file changed, 48 insertions(+), 48 deletions(-)
diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c
index db7391b..639e032 100644
index 6ee739b9c02..94d6efced9e 100644
--- a/dlls/ntdll/threadpool.c
+++ b/dlls/ntdll/threadpool.c
@@ -1206,7 +1206,7 @@ static void CALLBACK timerqueue_thread_proc( void *param )
@@ -1279,7 +1279,7 @@ static void CALLBACK timerqueue_thread_proc( void *param )
TRACE( "starting timer queue thread\n" );
@@ -20,7 +20,7 @@ index db7391b..639e032 100644
for (;;)
{
NtQuerySystemTime( &now );
@@ -1280,7 +1280,7 @@ static void CALLBACK timerqueue_thread_proc( void *param )
@@ -1353,7 +1353,7 @@ static void CALLBACK timerqueue_thread_proc( void *param )
}
timerqueue.thread_running = FALSE;
@@ -29,7 +29,7 @@ index db7391b..639e032 100644
TRACE( "terminating timer queue thread\n" );
RtlExitUserThread( 0 );
@@ -1326,7 +1326,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
@@ -1399,7 +1399,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
timer->u.timer.period = 0;
timer->u.timer.window_length = 0;
@@ -38,7 +38,7 @@ index db7391b..639e032 100644
/* Make sure that the timerqueue thread is running. */
if (!timerqueue.thread_running)
@@ -1347,7 +1347,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
@@ -1420,7 +1420,7 @@ static NTSTATUS tp_timerqueue_lock( struct threadpool_object *timer )
timerqueue.objcount++;
}
@@ -47,7 +47,7 @@ index db7391b..639e032 100644
return status;
}
@@ -1360,7 +1360,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
@@ -1433,7 +1433,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
{
assert( timer->type == TP_OBJECT_TYPE_TIMER );
@@ -56,7 +56,7 @@ index db7391b..639e032 100644
if (timer->u.timer.timer_initialized)
{
/* If timer was pending, remove it. */
@@ -1379,7 +1379,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
@@ -1452,7 +1452,7 @@ static void tp_timerqueue_unlock( struct threadpool_object *timer )
timer->u.timer.timer_initialized = FALSE;
}
@@ -65,7 +65,7 @@ index db7391b..639e032 100644
}
/***********************************************************************
@@ -1397,7 +1397,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1470,7 +1470,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
TRACE( "starting wait queue thread\n" );
@@ -74,7 +74,7 @@ index db7391b..639e032 100644
for (;;)
{
@@ -1434,10 +1434,10 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1507,10 +1507,10 @@ static void CALLBACK waitqueue_thread_proc( void *param )
/* All wait objects have been destroyed, if no new wait objects are created
* within some amount of time, then we can shutdown this thread. */
assert( num_handles == 0 );
@@ -87,7 +87,7 @@ index db7391b..639e032 100644
if (status == STATUS_TIMEOUT && !bucket->objcount)
break;
@@ -1445,9 +1445,9 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1518,9 +1518,9 @@ static void CALLBACK waitqueue_thread_proc( void *param )
else
{
handles[num_handles] = bucket->update_event;
@@ -99,7 +99,7 @@ index db7391b..639e032 100644
if (status >= STATUS_WAIT_0 && status < STATUS_WAIT_0 + num_handles)
{
@@ -1520,7 +1520,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
@@ -1593,7 +1593,7 @@ static void CALLBACK waitqueue_thread_proc( void *param )
if (!--waitqueue.num_buckets)
assert( list_empty( &waitqueue.buckets ) );
@@ -108,7 +108,7 @@ index db7391b..639e032 100644
TRACE( "terminating wait queue thread\n" );
@@ -1549,7 +1549,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
@@ -1622,7 +1622,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
wait->u.wait.timeout = 0;
wait->u.wait.handle = INVALID_HANDLE_VALUE;
@@ -117,7 +117,7 @@ index db7391b..639e032 100644
/* Try to assign to existing bucket if possible. */
LIST_FOR_EACH_ENTRY( bucket, &waitqueue.buckets, struct waitqueue_bucket, bucket_entry )
@@ -1605,7 +1605,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
@@ -1678,7 +1678,7 @@ static NTSTATUS tp_waitqueue_lock( struct threadpool_object *wait )
}
out:
@@ -126,7 +126,7 @@ index db7391b..639e032 100644
return status;
}
@@ -1616,7 +1616,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
@@ -1689,7 +1689,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
{
assert( wait->type == TP_OBJECT_TYPE_WAIT );
@@ -135,7 +135,7 @@ index db7391b..639e032 100644
if (wait->u.wait.bucket)
{
struct waitqueue_bucket *bucket = wait->u.wait.bucket;
@@ -1628,7 +1628,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
@@ -1701,7 +1701,7 @@ static void tp_waitqueue_unlock( struct threadpool_object *wait )
NtSetEvent( bucket->update_event, NULL );
}
@@ -143,8 +143,8 @@ index db7391b..639e032 100644
+ leave_critical_section( &waitqueue.cs );
}
/***********************************************************************
@@ -1759,7 +1759,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
static void CALLBACK ioqueue_thread_proc( void *param )
@@ -1956,7 +1956,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
pool = default_threadpool;
}
@@ -153,7 +153,7 @@ index db7391b..639e032 100644
/* Make sure that the threadpool has at least one thread. */
if (!pool->num_workers)
@@ -1773,7 +1773,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
@@ -1970,7 +1970,7 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
pool->objcount++;
}
@@ -162,7 +162,7 @@ index db7391b..639e032 100644
if (status != STATUS_SUCCESS)
return status;
@@ -1789,9 +1789,9 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
@@ -1986,9 +1986,9 @@ static NTSTATUS tp_threadpool_lock( struct threadpool **out, TP_CALLBACK_ENVIRON
*/
static void tp_threadpool_unlock( struct threadpool *pool )
{
@@ -174,7 +174,7 @@ index db7391b..639e032 100644
tp_threadpool_release( pool );
}
@@ -1928,10 +1928,10 @@ static void tp_object_initialize( struct threadpool_object *object, struct threa
@@ -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 );
@@ -187,7 +187,7 @@ index db7391b..639e032 100644
}
if (is_simple_callback)
@@ -1957,7 +1957,7 @@ static void tp_object_submit( struct threadpool_object *object, BOOL signaled )
@@ -2154,7 +2154,7 @@ static void tp_object_submit( struct threadpool_object *object, BOOL signaled )
assert( !object->shutdown );
assert( !pool->shutdown );
@@ -196,7 +196,7 @@ index db7391b..639e032 100644
/* Start new worker threads if required. */
if (pool->num_busy_workers >= pool->num_workers &&
@@ -1980,7 +1980,7 @@ static void tp_object_submit( struct threadpool_object *object, BOOL signaled )
@@ -2177,7 +2177,7 @@ static void tp_object_submit( struct threadpool_object *object, BOOL signaled )
RtlWakeConditionVariable( &pool->update_event );
}
@@ -205,7 +205,7 @@ index db7391b..639e032 100644
}
/***********************************************************************
@@ -1993,7 +1993,7 @@ static void tp_object_cancel( struct threadpool_object *object )
@@ -2190,7 +2190,7 @@ static void tp_object_cancel( struct threadpool_object *object )
struct threadpool *pool = object->pool;
LONG pending_callbacks = 0;
@@ -214,26 +214,26 @@ index db7391b..639e032 100644
if (object->num_pending_callbacks)
{
pending_callbacks = object->num_pending_callbacks;
@@ -2003,7 +2003,7 @@ static void tp_object_cancel( struct threadpool_object *object )
if (object->type == TP_OBJECT_TYPE_WAIT)
object->u.wait.signaled = 0;
@@ -2202,7 +2202,7 @@ static void tp_object_cancel( struct threadpool_object *object )
}
if (object->type == TP_OBJECT_TYPE_IO)
object->u.io.pending_count = 0;
- RtlLeaveCriticalSection( &pool->cs );
+ leave_critical_section( &pool->cs );
while (pending_callbacks--)
tp_object_release( object );
@@ -2019,7 +2019,7 @@ static void tp_object_wait( struct threadpool_object *object, BOOL group_wait )
@@ -2231,7 +2231,7 @@ static void tp_object_wait( struct threadpool_object *object, BOOL group_wait )
{
struct threadpool *pool = object->pool;
- RtlEnterCriticalSection( &pool->cs );
+ enter_critical_section( &pool->cs );
if (group_wait)
while (!object_is_finished( object, group_wait ))
{
while (object->num_pending_callbacks || object->num_running_callbacks)
@@ -2030,7 +2030,7 @@ static void tp_object_wait( struct threadpool_object *object, BOOL group_wait )
while (object->num_pending_callbacks || object->num_associated_callbacks)
if (group_wait)
@@ -2239,7 +2239,7 @@ static void tp_object_wait( struct threadpool_object *object, BOOL group_wait )
else
RtlSleepConditionVariableCS( &object->finished_event, &pool->cs, NULL );
}
- RtlLeaveCriticalSection( &pool->cs );
@@ -241,7 +241,7 @@ index db7391b..639e032 100644
}
/***********************************************************************
@@ -2068,13 +2068,13 @@ static BOOL tp_object_release( struct threadpool_object *object )
@@ -2279,13 +2279,13 @@ static BOOL tp_object_release( struct threadpool_object *object )
{
struct threadpool_group *group = object->group;
@@ -257,7 +257,7 @@ index db7391b..639e032 100644
tp_group_release( group );
}
@@ -2117,7 +2117,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
@@ -2329,7 +2329,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
TRACE( "starting worker thread for pool %p\n", pool );
@@ -266,7 +266,7 @@ index db7391b..639e032 100644
pool->num_busy_workers--;
for (;;)
{
@@ -2143,7 +2143,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
@@ -2361,7 +2361,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
object->num_associated_callbacks++;
object->num_running_callbacks++;
pool->num_busy_workers++;
@@ -275,7 +275,7 @@ index db7391b..639e032 100644
/* Initialize threadpool instance struct. */
callback_instance = (TP_CALLBACK_INSTANCE *)&instance;
@@ -2236,7 +2236,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
@@ -2465,7 +2465,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
}
skip_cleanup:
@@ -284,7 +284,7 @@ index db7391b..639e032 100644
pool->num_busy_workers--;
/* Simple callbacks are automatically shutdown after execution. */
@@ -2278,7 +2278,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
@@ -2507,7 +2507,7 @@ static void CALLBACK threadpool_worker_proc( void *param )
}
}
pool->num_workers--;
@@ -293,7 +293,7 @@ index db7391b..639e032 100644
TRACE( "terminating worker thread for pool %p\n", pool );
tp_threadpool_release( pool );
@@ -2454,7 +2454,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
@@ -2747,7 +2747,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
return STATUS_SUCCESS;
pool = object->pool;
@@ -302,7 +302,7 @@ index db7391b..639e032 100644
/* Start new worker threads if required. */
if (pool->num_busy_workers >= pool->num_workers)
@@ -2469,7 +2469,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
@@ -2762,7 +2762,7 @@ NTSTATUS WINAPI TpCallbackMayRunLong( TP_CALLBACK_INSTANCE *instance )
}
}
@@ -311,7 +311,7 @@ index db7391b..639e032 100644
this->may_run_long = TRUE;
return status;
}
@@ -2550,13 +2550,13 @@ VOID WINAPI TpDisassociateCallback( TP_CALLBACK_INSTANCE *instance )
@@ -2843,13 +2843,13 @@ VOID WINAPI TpDisassociateCallback( TP_CALLBACK_INSTANCE *instance )
return;
pool = object->pool;
@@ -319,7 +319,7 @@ index db7391b..639e032 100644
+ enter_critical_section( &pool->cs );
object->num_associated_callbacks--;
if (!object->num_pending_callbacks && !object->num_associated_callbacks)
if (object_is_finished( object, FALSE ))
RtlWakeAllConditionVariable( &object->finished_event );
- RtlLeaveCriticalSection( &pool->cs );
@@ -327,7 +327,7 @@ index db7391b..639e032 100644
this->associated = FALSE;
}
@@ -2608,7 +2608,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
@@ -2901,7 +2901,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
TRACE( "%p %u %p\n", group, cancel_pending, userdata );
@@ -336,7 +336,7 @@ index db7391b..639e032 100644
/* Unset group, increase references, and mark objects for shutdown */
LIST_FOR_EACH_ENTRY_SAFE( object, next, &this->members, struct threadpool_object, group_entry )
@@ -2634,7 +2634,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
@@ -2927,7 +2927,7 @@ VOID WINAPI TpReleaseCleanupGroupMembers( TP_CLEANUP_GROUP *group, BOOL cancel_p
list_init( &members );
list_move_tail( &members, &this->members );
@@ -345,7 +345,7 @@ index db7391b..639e032 100644
/* Cancel pending callbacks if requested */
if (cancel_pending)
@@ -2734,10 +2734,10 @@ VOID WINAPI TpSetPoolMaxThreads( TP_POOL *pool, DWORD maximum )
@@ -3041,10 +3041,10 @@ VOID WINAPI TpSetPoolMaxThreads( TP_POOL *pool, DWORD maximum )
TRACE( "%p %u\n", pool, maximum );
@@ -358,7 +358,7 @@ index db7391b..639e032 100644
}
/***********************************************************************
@@ -2750,7 +2750,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
@@ -3057,7 +3057,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
TRACE( "%p %u\n", pool, minimum );
@@ -367,7 +367,7 @@ index db7391b..639e032 100644
while (this->num_workers < minimum)
{
@@ -2765,7 +2765,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
@@ -3072,7 +3072,7 @@ BOOL WINAPI TpSetPoolMinThreads( TP_POOL *pool, DWORD minimum )
this->max_workers = max( this->min_workers, this->max_workers );
}
@@ -376,7 +376,7 @@ index db7391b..639e032 100644
return !status;
}
@@ -2781,7 +2781,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
@@ -3088,7 +3088,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
TRACE( "%p %p %u %u\n", timer, timeout, period, window_length );
@@ -385,7 +385,7 @@ index db7391b..639e032 100644
assert( this->u.timer.timer_initialized );
this->u.timer.timer_set = timeout != NULL;
@@ -2841,7 +2841,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
@@ -3148,7 +3148,7 @@ VOID WINAPI TpSetTimer( TP_TIMER *timer, LARGE_INTEGER *timeout, LONG period, LO
this->u.timer.timer_pending = TRUE;
}
@@ -394,7 +394,7 @@ index db7391b..639e032 100644
if (submit_timer)
tp_object_submit( this, FALSE );
@@ -2858,7 +2858,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
@@ -3165,7 +3165,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
TRACE( "%p %p %p\n", wait, handle, timeout );
@@ -403,7 +403,7 @@ index db7391b..639e032 100644
assert( this->u.wait.bucket );
this->u.wait.handle = handle;
@@ -2902,7 +2902,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
@@ -3209,7 +3209,7 @@ VOID WINAPI TpSetWait( TP_WAIT *wait, HANDLE handle, LARGE_INTEGER *timeout )
NtSetEvent( bucket->update_event, NULL );
}
@@ -413,5 +413,5 @@ index db7391b..639e032 100644
if (submit_wait)
tp_object_submit( this, FALSE );
--
1.9.1
2.26.0