Commit 4b155749 authored by Alexandre Julliard's avatar Alexandre Julliard

Implemented RtlpWaitForCriticalSection and RtlpUnWaitCriticalSection.

parent c4a26442
......@@ -550,8 +550,8 @@ type win32
@ stub RtlpNtOpenKey
@ stub RtlpNtQueryValueKey
@ stub RtlpNtSetValueKey
@ stub RtlpUnWaitCriticalSection
@ stub RtlpWaitForCriticalSection
@ stdcall RtlpUnWaitCriticalSection(ptr) RtlpUnWaitCriticalSection
@ stdcall RtlpWaitForCriticalSection(ptr) RtlpWaitForCriticalSection
@ stdcall RtlxAnsiStringToUnicodeSize(ptr) RtlAnsiStringToUnicodeSize
@ stdcall RtlxOemStringToUnicodeSize(ptr) RtlOemStringToUnicodeSize
@ stdcall RtlxUnicodeStringToAnsiSize(ptr) RtlUnicodeStringToAnsiSize
......
......@@ -65,19 +65,10 @@ void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
/***********************************************************************
* EnterCriticalSection (KERNEL32.195) (NTDLL.344)
* RtlpWaitForCriticalSection (NTDLL.@)
*/
void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
void WINAPI RtlpWaitForCriticalSection( CRITICAL_SECTION *crit )
{
if (InterlockedIncrement( &crit->LockCount ))
{
if (crit->OwningThread == GetCurrentThreadId())
{
crit->RecursionCount++;
return;
}
/* Now wait for it */
for (;;)
{
EXCEPTION_RECORD rec;
......@@ -104,6 +95,34 @@ void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
rec.ExceptionInformation[0] = (DWORD)crit;
RtlRaiseException( &rec );
}
}
/***********************************************************************
* RtlpUnWaitCriticalSection (NTDLL.@)
*/
void WINAPI RtlpUnWaitCriticalSection( CRITICAL_SECTION *crit )
{
HANDLE sem = get_semaphore( crit );
ReleaseSemaphore( sem, 1, NULL );
}
/***********************************************************************
* EnterCriticalSection (KERNEL32.195) (NTDLL.344)
*/
void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
{
if (InterlockedIncrement( &crit->LockCount ))
{
if (crit->OwningThread == GetCurrentThreadId())
{
crit->RecursionCount++;
return;
}
/* Now wait for it */
RtlpWaitForCriticalSection( crit );
}
crit->OwningThread = GetCurrentThreadId();
crit->RecursionCount = 1;
......@@ -149,8 +168,7 @@ void WINAPI LeaveCriticalSection( CRITICAL_SECTION *crit )
if (InterlockedDecrement( &crit->LockCount ) >= 0)
{
/* Someone is waiting */
HANDLE sem = get_semaphore( crit );
ReleaseSemaphore( sem, 1, NULL );
RtlpUnWaitCriticalSection( crit );
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment