mirror of
https://github.com/reactos/reactos.git
synced 2024-12-18 16:43:27 +08:00
8c5b0fbff3
This fixes a few newly added winetests.
176 lines
3.8 KiB
C
176 lines
3.8 KiB
C
#include "k32_vista.h"
|
|
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlInitializeConditionVariable(OUT PRTL_CONDITION_VARIABLE ConditionVariable);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlWakeConditionVariable(IN OUT PRTL_CONDITION_VARIABLE ConditionVariable);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlWakeAllConditionVariable(IN OUT PRTL_CONDITION_VARIABLE ConditionVariable);
|
|
|
|
NTSTATUS
|
|
NTAPI
|
|
RtlSleepConditionVariableCS(IN OUT PRTL_CONDITION_VARIABLE ConditionVariable,
|
|
IN OUT PRTL_CRITICAL_SECTION CriticalSection,
|
|
IN PLARGE_INTEGER TimeOut OPTIONAL);
|
|
|
|
NTSTATUS
|
|
NTAPI
|
|
RtlSleepConditionVariableSRW(IN OUT PRTL_CONDITION_VARIABLE ConditionVariable,
|
|
IN OUT PRTL_SRWLOCK SRWLock,
|
|
IN PLARGE_INTEGER TimeOut OPTIONAL,
|
|
IN ULONG Flags);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlInitializeSRWLock(OUT PRTL_SRWLOCK SRWLock);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlReleaseSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlAcquireSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock);
|
|
|
|
VOID
|
|
NTAPI
|
|
RtlReleaseSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock);
|
|
|
|
|
|
VOID
|
|
WINAPI
|
|
AcquireSRWLockExclusive(PSRWLOCK Lock)
|
|
{
|
|
RtlAcquireSRWLockExclusive((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
AcquireSRWLockShared(PSRWLOCK Lock)
|
|
{
|
|
RtlAcquireSRWLockShared((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
InitializeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
|
|
{
|
|
RtlInitializeConditionVariable((PRTL_CONDITION_VARIABLE)ConditionVariable);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
InitializeSRWLock(PSRWLOCK Lock)
|
|
{
|
|
RtlInitializeSRWLock((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
ReleaseSRWLockExclusive(PSRWLOCK Lock)
|
|
{
|
|
RtlReleaseSRWLockExclusive((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
ReleaseSRWLockShared(PSRWLOCK Lock)
|
|
{
|
|
RtlReleaseSRWLockShared((PRTL_SRWLOCK)Lock);
|
|
}
|
|
|
|
FORCEINLINE
|
|
PLARGE_INTEGER
|
|
GetNtTimeout(PLARGE_INTEGER Time, DWORD Timeout)
|
|
{
|
|
if (Timeout == INFINITE) return NULL;
|
|
Time->QuadPart = (ULONGLONG)Timeout * -10000;
|
|
return Time;
|
|
}
|
|
|
|
BOOL
|
|
WINAPI
|
|
SleepConditionVariableCS(PCONDITION_VARIABLE ConditionVariable, PCRITICAL_SECTION CriticalSection, DWORD Timeout)
|
|
{
|
|
NTSTATUS Status;
|
|
LARGE_INTEGER Time;
|
|
|
|
Status = RtlSleepConditionVariableCS(ConditionVariable, (PRTL_CRITICAL_SECTION)CriticalSection, GetNtTimeout(&Time, Timeout));
|
|
if (!NT_SUCCESS(Status) || Status == STATUS_TIMEOUT)
|
|
{
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL
|
|
WINAPI
|
|
SleepConditionVariableSRW(PCONDITION_VARIABLE ConditionVariable, PSRWLOCK Lock, DWORD Timeout, ULONG Flags)
|
|
{
|
|
NTSTATUS Status;
|
|
LARGE_INTEGER Time;
|
|
|
|
Status = RtlSleepConditionVariableSRW(ConditionVariable, Lock, GetNtTimeout(&Time, Timeout), Flags);
|
|
if (!NT_SUCCESS(Status) || Status == STATUS_TIMEOUT)
|
|
{
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
WakeAllConditionVariable(PCONDITION_VARIABLE ConditionVariable)
|
|
{
|
|
RtlWakeAllConditionVariable((PRTL_CONDITION_VARIABLE)ConditionVariable);
|
|
}
|
|
|
|
VOID
|
|
WINAPI
|
|
WakeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
|
|
{
|
|
RtlWakeConditionVariable((PRTL_CONDITION_VARIABLE)ConditionVariable);
|
|
}
|
|
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection,
|
|
IN DWORD dwSpinCount,
|
|
IN DWORD flags)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
/* FIXME: Flags ignored */
|
|
|
|
/* Initialize the critical section */
|
|
Status = RtlInitializeCriticalSectionAndSpinCount(
|
|
(PRTL_CRITICAL_SECTION)lpCriticalSection,
|
|
dwSpinCount);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
/* Set failure code */
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
return FALSE;
|
|
}
|
|
|
|
/* Success */
|
|
return TRUE;
|
|
}
|
|
|