mirror of
https://github.com/reactos/reactos.git
synced 2025-01-11 16:51:06 +00:00
c424146e2c
svn path=/branches/cmake-bringup/; revision=48236
84 lines
2 KiB
C
84 lines
2 KiB
C
/*
|
|
* PROJECT: ReactOS Win32 Base API
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
* FILE: dll/win32/kernel32/synch/critical.c
|
|
* PURPOSE: Wrappers for the RTL Critical Section Implementation
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
*/
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
#include <k32.h>
|
|
|
|
#define NDEBUG
|
|
#include <debug.h>
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
VOID
|
|
WINAPI
|
|
InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
/* Initialize the critical section and raise an exception if we failed */
|
|
Status = RtlInitializeCriticalSection(
|
|
(PRTL_CRITICAL_SECTION)lpCriticalSection);
|
|
if (!NT_SUCCESS(Status)) RtlRaiseStatus(Status);
|
|
}
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
BOOL
|
|
WINAPI
|
|
InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection,
|
|
IN DWORD dwSpinCount)
|
|
{
|
|
NTSTATUS Status;
|
|
|
|
/* Initialize the critical section */
|
|
Status = RtlInitializeCriticalSectionAndSpinCount(
|
|
(PRTL_CRITICAL_SECTION)lpCriticalSection,
|
|
dwSpinCount);
|
|
if (!NT_SUCCESS(Status))
|
|
{
|
|
/* Set failure code */
|
|
SetLastErrorByStatus(Status);
|
|
return FALSE;
|
|
}
|
|
|
|
/* Success */
|
|
return TRUE;
|
|
}
|
|
|
|
/*
|
|
* @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 */
|
|
SetLastErrorByStatus(Status);
|
|
return FALSE;
|
|
}
|
|
|
|
/* Success */
|
|
return TRUE;
|
|
}
|
|
|
|
/* EOF */
|