You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
Rebase against 7de36f8e98b2cbbdcc360bdba96a5fe83e815d1a.
This commit is contained in:
@@ -1,219 +1,74 @@
|
||||
From 50e78099e8c5fbd74131e339b8e48488e1581c74 Mon Sep 17 00:00:00 2001
|
||||
From cad538b5197b0488f50d10eb58fa1b220e7d05dc Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Sat, 5 Aug 2017 03:39:23 +0200
|
||||
Subject: [PATCH] ntdll: Use fast CS functions for heap locking.
|
||||
|
||||
---
|
||||
dlls/ntdll/heap.c | 50 +++++++++++++++++++++++------------------------
|
||||
1 file changed, 25 insertions(+), 25 deletions(-)
|
||||
dlls/ntdll/heap.c | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c
|
||||
index af2a489b727..178f81006d0 100644
|
||||
index d7ac44a4247..3fd02770b7b 100644
|
||||
--- a/dlls/ntdll/heap.c
|
||||
+++ b/dlls/ntdll/heap.c
|
||||
@@ -1338,7 +1338,7 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */
|
||||
flags |= heapPtr->flags;
|
||||
/* calling HeapLock may result in infinite recursion, so do the critsect directly */
|
||||
if (!(flags & HEAP_NO_SERIALIZE))
|
||||
- RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ enter_critical_section( &heapPtr->critSection );
|
||||
|
||||
if (block) /* only check this single memory block */
|
||||
{
|
||||
@@ -1384,7 +1384,7 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, /* [in] ptr to the heap */
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
return ret;
|
||||
@@ -340,13 +340,13 @@ static inline ULONG heap_get_flags( const HEAP *heap, ULONG flags )
|
||||
static void heap_lock( HEAP *heap, ULONG flags )
|
||||
{
|
||||
if (heap_get_flags( heap, flags ) & HEAP_NO_SERIALIZE) return;
|
||||
- RtlEnterCriticalSection( &heap->cs );
|
||||
+ enter_critical_section( &heap->cs );
|
||||
}
|
||||
|
||||
@@ -1558,9 +1558,9 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c
|
||||
static void heap_unlock( HEAP *heap, ULONG flags )
|
||||
{
|
||||
if (heap_get_flags( heap, flags ) & HEAP_NO_SERIALIZE) return;
|
||||
- RtlLeaveCriticalSection( &heap->cs );
|
||||
+ leave_critical_section( &heap->cs );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
@@ -1583,9 +1583,9 @@ HANDLE WINAPI RtlCreateHeap( ULONG flags, PVOID addr, SIZE_T totalSize, SIZE_T c
|
||||
if (processHeap)
|
||||
{
|
||||
HEAP *heapPtr = subheap->heap;
|
||||
- RtlEnterCriticalSection( &processHeap->critSection );
|
||||
+ enter_critical_section( &processHeap->critSection );
|
||||
- RtlEnterCriticalSection( &processHeap->cs );
|
||||
+ enter_critical_section( &processHeap->cs );
|
||||
list_add_head( &processHeap->entry, &heapPtr->entry );
|
||||
- RtlLeaveCriticalSection( &processHeap->critSection );
|
||||
+ leave_critical_section( &processHeap->critSection );
|
||||
- RtlLeaveCriticalSection( &processHeap->cs );
|
||||
+ leave_critical_section( &processHeap->cs );
|
||||
}
|
||||
else if (!addr)
|
||||
{
|
||||
@@ -1598,9 +1598,9 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
|
||||
@@ -1629,9 +1629,9 @@ HANDLE WINAPI RtlDestroyHeap( HANDLE heap )
|
||||
if (heap == processHeap) return heap; /* cannot delete the main process heap */
|
||||
|
||||
/* remove it from the per-process list */
|
||||
- RtlEnterCriticalSection( &processHeap->critSection );
|
||||
+ enter_critical_section( &processHeap->critSection );
|
||||
- RtlEnterCriticalSection( &processHeap->cs );
|
||||
+ enter_critical_section( &processHeap->cs );
|
||||
list_remove( &heapPtr->entry );
|
||||
- RtlLeaveCriticalSection( &processHeap->critSection );
|
||||
+ leave_critical_section( &processHeap->critSection );
|
||||
- RtlLeaveCriticalSection( &processHeap->cs );
|
||||
+ leave_critical_section( &processHeap->cs );
|
||||
|
||||
heapPtr->critSection.DebugInfo->Spare[0] = 0;
|
||||
RtlDeleteCriticalSection( &heapPtr->critSection );
|
||||
@@ -1673,12 +1673,12 @@ void * WINAPI DECLSPEC_HOTPATCH RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_
|
||||
}
|
||||
if (rounded_size < HEAP_MIN_DATA_SIZE) rounded_size = HEAP_MIN_DATA_SIZE;
|
||||
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) enter_critical_section( &heapPtr->critSection );
|
||||
|
||||
if (rounded_size >= HEAP_MIN_LARGE_BLOCK_SIZE && (flags & HEAP_GROWABLE))
|
||||
{
|
||||
void *ret = allocate_large_block( heap, flags, size );
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
if (!ret && (flags & HEAP_GENERATE_EXCEPTIONS)) RtlRaiseStatus( STATUS_NO_MEMORY );
|
||||
TRACE("(%p,%08x,%08lx): returning %p\n", heap, flags, size, ret );
|
||||
return ret;
|
||||
@@ -1690,7 +1690,7 @@ void * WINAPI DECLSPEC_HOTPATCH RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_
|
||||
{
|
||||
TRACE("(%p,%08x,%08lx): returning NULL\n",
|
||||
heap, flags, size );
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
if (flags & HEAP_GENERATE_EXCEPTIONS) RtlRaiseStatus( STATUS_NO_MEMORY );
|
||||
return NULL;
|
||||
}
|
||||
@@ -1716,7 +1716,7 @@ void * WINAPI DECLSPEC_HOTPATCH RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_
|
||||
notify_alloc( pInUse + 1, size, flags & HEAP_ZERO_MEMORY );
|
||||
initialize_block( pInUse + 1, size, pInUse->unused_bytes, flags );
|
||||
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
|
||||
TRACE("(%p,%08x,%08lx): returning %p\n", heap, flags, size, pInUse + 1 );
|
||||
return pInUse + 1;
|
||||
@@ -1756,7 +1756,7 @@ BOOLEAN WINAPI DECLSPEC_HOTPATCH RtlFreeHeap( HANDLE heap, ULONG flags, void *pt
|
||||
|
||||
flags &= HEAP_NO_SERIALIZE;
|
||||
flags |= heapPtr->flags;
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) enter_critical_section( &heapPtr->critSection );
|
||||
|
||||
/* Inform valgrind we are trying to free memory, so it can throw up an error message */
|
||||
notify_free( ptr );
|
||||
@@ -1770,12 +1770,12 @@ BOOLEAN WINAPI DECLSPEC_HOTPATCH RtlFreeHeap( HANDLE heap, ULONG flags, void *pt
|
||||
else
|
||||
HEAP_MakeInUseBlockFree( subheap, pInUse );
|
||||
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
TRACE("(%p,%08x,%p): returning TRUE\n", heap, flags, ptr );
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER );
|
||||
TRACE("(%p,%08x,%p): returning FALSE\n", heap, flags, ptr );
|
||||
return FALSE;
|
||||
@@ -1817,7 +1817,7 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size
|
||||
flags &= HEAP_GENERATE_EXCEPTIONS | HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY |
|
||||
HEAP_REALLOC_IN_PLACE_ONLY;
|
||||
flags |= heapPtr->flags;
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) enter_critical_section( &heapPtr->critSection );
|
||||
|
||||
rounded_size = ROUND_SIZE(size) + HEAP_TAIL_EXTRA_SIZE(flags);
|
||||
if (rounded_size < size) goto oom; /* overflow */
|
||||
@@ -1911,19 +1911,19 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size
|
||||
|
||||
ret = pArena + 1;
|
||||
done:
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
TRACE("(%p,%08x,%p,%08lx): returning %p\n", heap, flags, ptr, size, ret );
|
||||
return ret;
|
||||
|
||||
oom:
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
if (flags & HEAP_GENERATE_EXCEPTIONS) RtlRaiseStatus( STATUS_NO_MEMORY );
|
||||
RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_NO_MEMORY );
|
||||
TRACE("(%p,%08x,%p,%08lx): returning NULL\n", heap, flags, ptr, size );
|
||||
return NULL;
|
||||
|
||||
error:
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
RtlSetLastWin32ErrorAndNtStatusFromNtStatus( STATUS_INVALID_PARAMETER );
|
||||
TRACE("(%p,%08x,%p,%08lx): returning NULL\n", heap, flags, ptr, size );
|
||||
return NULL;
|
||||
@@ -1969,7 +1969,7 @@ BOOLEAN WINAPI RtlLockHeap( HANDLE heap )
|
||||
{
|
||||
HEAP *heapPtr = HEAP_GetPtr( heap );
|
||||
if (!heapPtr) return FALSE;
|
||||
- RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ enter_critical_section( &heapPtr->critSection );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1990,7 +1990,7 @@ BOOLEAN WINAPI RtlUnlockHeap( HANDLE heap )
|
||||
{
|
||||
HEAP *heapPtr = HEAP_GetPtr( heap );
|
||||
if (!heapPtr) return FALSE;
|
||||
- RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ leave_critical_section( &heapPtr->critSection );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -2026,7 +2026,7 @@ SIZE_T WINAPI RtlSizeHeap( HANDLE heap, ULONG flags, const void *ptr )
|
||||
}
|
||||
flags &= HEAP_NO_SERIALIZE;
|
||||
flags |= heapPtr->flags;
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) enter_critical_section( &heapPtr->critSection );
|
||||
|
||||
pArena = (const ARENA_INUSE *)ptr - 1;
|
||||
if (!validate_block_pointer( heapPtr, &subheap, pArena ))
|
||||
@@ -2043,7 +2043,7 @@ SIZE_T WINAPI RtlSizeHeap( HANDLE heap, ULONG flags, const void *ptr )
|
||||
{
|
||||
ret = (pArena->size & ARENA_SIZE_MASK) - pArena->unused_bytes;
|
||||
}
|
||||
- if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
|
||||
TRACE("(%p,%08x,%p): returning %08lx\n", heap, flags, ptr, ret );
|
||||
return ret;
|
||||
@@ -2090,7 +2090,7 @@ NTSTATUS WINAPI RtlWalkHeap( HANDLE heap, PVOID entry_ptr )
|
||||
|
||||
if (!heapPtr || !entry) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
- if (!(heapPtr->flags & HEAP_NO_SERIALIZE)) RtlEnterCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(heapPtr->flags & HEAP_NO_SERIALIZE)) enter_critical_section( &heapPtr->critSection );
|
||||
|
||||
/* FIXME: enumerate large blocks too */
|
||||
|
||||
@@ -2195,7 +2195,7 @@ NTSTATUS WINAPI RtlWalkHeap( HANDLE heap, PVOID entry_ptr )
|
||||
if (TRACE_ON(heap)) HEAP_DumpEntry(entry);
|
||||
|
||||
HW_end:
|
||||
- if (!(heapPtr->flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection );
|
||||
+ if (!(heapPtr->flags & HEAP_NO_SERIALIZE)) leave_critical_section( &heapPtr->critSection );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2218,7 +2218,7 @@ ULONG WINAPI RtlGetProcessHeaps( ULONG count, HANDLE *heaps )
|
||||
heapPtr->cs.DebugInfo->Spare[0] = 0;
|
||||
RtlDeleteCriticalSection( &heapPtr->cs );
|
||||
@@ -2242,7 +2242,7 @@ ULONG WINAPI RtlGetProcessHeaps( ULONG count, HANDLE *heaps )
|
||||
ULONG total = 1; /* main heap */
|
||||
struct list *ptr;
|
||||
|
||||
- RtlEnterCriticalSection( &processHeap->critSection );
|
||||
+ enter_critical_section( &processHeap->critSection );
|
||||
- RtlEnterCriticalSection( &processHeap->cs );
|
||||
+ enter_critical_section( &processHeap->cs );
|
||||
LIST_FOR_EACH( ptr, &processHeap->entry ) total++;
|
||||
if (total <= count)
|
||||
{
|
||||
@@ -2226,7 +2226,7 @@ ULONG WINAPI RtlGetProcessHeaps( ULONG count, HANDLE *heaps )
|
||||
@@ -2250,7 +2250,7 @@ ULONG WINAPI RtlGetProcessHeaps( ULONG count, HANDLE *heaps )
|
||||
LIST_FOR_EACH( ptr, &processHeap->entry )
|
||||
*heaps++ = LIST_ENTRY( ptr, HEAP, entry );
|
||||
}
|
||||
- RtlLeaveCriticalSection( &processHeap->critSection );
|
||||
+ leave_critical_section( &processHeap->critSection );
|
||||
- RtlLeaveCriticalSection( &processHeap->cs );
|
||||
+ leave_critical_section( &processHeap->cs );
|
||||
return total;
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
2.35.1
|
||||
|
||||
|
Reference in New Issue
Block a user