474a5d6c5432b241eb685f2f1e54de52dcab5bf4
[reactos.git] / reactos / dll / win32 / kernel32 / synch / critical.c
1 /*
2 * PROJECT: ReactOS Win32 Base API
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/kernel32/synch/critical.c
5 * PURPOSE: Wrappers for the RTL Critical Section Implementation
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #include <k32.h>
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS *****************************************************************/
17
18 /*
19 * @implemented
20 */
21 VOID
22 WINAPI
23 InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
24 {
25 NTSTATUS Status;
26
27 /* Initialize the critical section and raise an exception if we failed */
28 Status = RtlInitializeCriticalSection(
29 (PRTL_CRITICAL_SECTION)lpCriticalSection);
30 if (!NT_SUCCESS(Status)) RtlRaiseStatus(Status);
31 }
32
33 /*
34 * @implemented
35 */
36 BOOL
37 WINAPI
38 InitializeCriticalSectionAndSpinCount(OUT LPCRITICAL_SECTION lpCriticalSection,
39 IN DWORD dwSpinCount)
40 {
41 NTSTATUS Status;
42
43 /* Initialize the critical section */
44 Status = RtlInitializeCriticalSectionAndSpinCount(
45 (PRTL_CRITICAL_SECTION)lpCriticalSection,
46 dwSpinCount);
47 if (!NT_SUCCESS(Status))
48 {
49 /* Set failure code */
50 SetLastErrorByStatus(Status);
51 return FALSE;
52 }
53
54 /* Success */
55 return TRUE;
56 }
57
58 /* EOF */