Commit 1ad733e4 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

ntdll: Implement [Rtl]InitializeCriticalSectionEx.

parent cd8b30f1
...@@ -712,6 +712,7 @@ ...@@ -712,6 +712,7 @@
@ stdcall InitAtomTable(long) @ stdcall InitAtomTable(long)
@ stdcall InitializeCriticalSection(ptr) @ stdcall InitializeCriticalSection(ptr)
@ stdcall InitializeCriticalSectionAndSpinCount(ptr long) @ stdcall InitializeCriticalSectionAndSpinCount(ptr long)
@ stdcall InitializeCriticalSectionEx(ptr long long)
@ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead @ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead
@ stdcall InterlockedCompareExchange (ptr long long) @ stdcall InterlockedCompareExchange (ptr long long)
@ stdcall InterlockedDecrement(ptr) @ stdcall InterlockedDecrement(ptr)
......
...@@ -350,8 +350,7 @@ DWORD WINAPI SignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectToWaitOn ...@@ -350,8 +350,7 @@ DWORD WINAPI SignalObjectAndWait( HANDLE hObjectToSignal, HANDLE hObjectToWaitOn
*/ */
void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit ) void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
{ {
NTSTATUS ret = RtlInitializeCriticalSection( crit ); InitializeCriticalSectionEx( crit, 0, 0 );
if (ret) RtlRaiseStatus( ret );
} }
/*********************************************************************** /***********************************************************************
...@@ -372,7 +371,29 @@ void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit ) ...@@ -372,7 +371,29 @@ void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
*/ */
BOOL WINAPI InitializeCriticalSectionAndSpinCount( CRITICAL_SECTION *crit, DWORD spincount ) BOOL WINAPI InitializeCriticalSectionAndSpinCount( CRITICAL_SECTION *crit, DWORD spincount )
{ {
NTSTATUS ret = RtlInitializeCriticalSectionAndSpinCount( crit, spincount ); return InitializeCriticalSectionEx( crit, spincount, 0 );
}
/***********************************************************************
* InitializeCriticalSectionEx (KERNEL32.@)
*
* Initialise a critical section with a spin count and flags.
*
* PARAMS
* crit [O] Critical section to initialise.
* spincount [I] Number of times to spin upon contention.
* flags [I] CRITICAL_SECTION_ flags from winbase.h.
*
* RETURNS
* Success: TRUE.
* Failure: Nothing. If the function fails an exception is raised.
*
* NOTES
* spincount is ignored on uni-processor systems.
*/
BOOL WINAPI InitializeCriticalSectionEx( CRITICAL_SECTION *crit, DWORD spincount, DWORD flags )
{
NTSTATUS ret = RtlInitializeCriticalSectionEx( crit, spincount, flags );
if (ret) RtlRaiseStatus( ret ); if (ret) RtlRaiseStatus( ret );
return !ret; return !ret;
} }
......
...@@ -247,13 +247,14 @@ static inline NTSTATUS wait_semaphore( RTL_CRITICAL_SECTION *crit, int timeout ) ...@@ -247,13 +247,14 @@ static inline NTSTATUS wait_semaphore( RTL_CRITICAL_SECTION *crit, int timeout )
* STATUS_SUCCESS. * STATUS_SUCCESS.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSectionAndSpinCount(), RtlDeleteCriticalSection(), * RtlInitializeCriticalSectionAndSpinCount(), RtlDeleteCriticalSection(),
* RtlEnterCriticalSection(), RtlLeaveCriticalSection(), * RtlEnterCriticalSection(), RtlLeaveCriticalSection(),
* RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount() * RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount()
*/ */
NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit )
{ {
return RtlInitializeCriticalSectionAndSpinCount( crit, 0 ); return RtlInitializeCriticalSectionEx( crit, 0, 0 );
} }
/*********************************************************************** /***********************************************************************
...@@ -272,13 +273,53 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -272,13 +273,53 @@ NTSTATUS WINAPI RtlInitializeCriticalSection( RTL_CRITICAL_SECTION *crit )
* Available on NT4 SP3 or later. * Available on NT4 SP3 or later.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlDeleteCriticalSection(), * RtlInitializeCriticalSection(), RtlDeleteCriticalSection(),
* RtlEnterCriticalSection(), RtlLeaveCriticalSection(), * RtlEnterCriticalSection(), RtlLeaveCriticalSection(),
* RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount() * RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount()
*/ */
NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount ) NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *crit, ULONG spincount )
{ {
return RtlInitializeCriticalSectionEx( crit, spincount, 0 );
}
/***********************************************************************
* RtlInitializeCriticalSectionEx (NTDLL.@)
*
* Initialises a new critical section with a given spin count and flags.
*
* PARAMS
* crit [O] Critical section to initialise.
* spincount [I] Number of times to spin upon contention.
* flags [I] RTL_CRITICAL_SECTION_FLAG_ flags from winnt.h.
*
* RETURNS
* STATUS_SUCCESS.
*
* NOTES
* Available on Vista or later.
*
* SEE
* RtlInitializeCriticalSection(), RtlDeleteCriticalSection(),
* RtlEnterCriticalSection(), RtlLeaveCriticalSection(),
* RtlTryEnterCriticalSection(), RtlSetCriticalSectionSpinCount()
*/
NTSTATUS WINAPI RtlInitializeCriticalSectionEx( RTL_CRITICAL_SECTION *crit, ULONG spincount, ULONG flags )
{
if (flags & (RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN|RTL_CRITICAL_SECTION_FLAG_STATIC_INIT))
FIXME("(%p,%u,0x%08x) semi-stub\n", crit, spincount, flags);
/* FIXME: if RTL_CRITICAL_SECTION_FLAG_STATIC_INIT is given, we should use
* memory from a static pool to hold the debug info. Then heap.c could pass
* this flag rather than initialising the process heap CS by hand. If this
* is done, then debug info should be managed through Rtlp[Allocate|Free]DebugInfo
* so (e.g.) MakeCriticalSectionGlobal() doesn't free it using HeapFree().
*/
if (flags & RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO)
crit->DebugInfo = NULL;
else
crit->DebugInfo = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_CRITICAL_SECTION_DEBUG)); crit->DebugInfo = RtlAllocateHeap(GetProcessHeap(), 0, sizeof(RTL_CRITICAL_SECTION_DEBUG));
if (crit->DebugInfo) if (crit->DebugInfo)
{ {
crit->DebugInfo->Type = 0; crit->DebugInfo->Type = 0;
...@@ -315,6 +356,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION * ...@@ -315,6 +356,7 @@ NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount( RTL_CRITICAL_SECTION *
* If the system is not SMP, spincount is ignored and set to 0. * If the system is not SMP, spincount is ignored and set to 0.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(), * RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection() * RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
...@@ -339,6 +381,7 @@ ULONG WINAPI RtlSetCriticalSectionSpinCount( RTL_CRITICAL_SECTION *crit, ULONG s ...@@ -339,6 +381,7 @@ ULONG WINAPI RtlSetCriticalSectionSpinCount( RTL_CRITICAL_SECTION *crit, ULONG s
* STATUS_SUCCESS. * STATUS_SUCCESS.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(), * RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection() * RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
...@@ -380,6 +423,7 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -380,6 +423,7 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit )
* faster. * faster.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(), * RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection() * RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
...@@ -442,6 +486,7 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -442,6 +486,7 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
* faster. * faster.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(), * RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection() * RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
...@@ -473,6 +518,7 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -473,6 +518,7 @@ NTSTATUS WINAPI RtlpUnWaitCriticalSection( RTL_CRITICAL_SECTION *crit )
* STATUS_SUCCESS. The critical section is held by the caller. * STATUS_SUCCESS. The critical section is held by the caller.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlSetCriticalSectionSpinCount(), * RtlDeleteCriticalSection(), RtlSetCriticalSectionSpinCount(),
* RtlLeaveCriticalSection(), RtlTryEnterCriticalSection() * RtlLeaveCriticalSection(), RtlTryEnterCriticalSection()
...@@ -526,6 +572,7 @@ done: ...@@ -526,6 +572,7 @@ done:
* Failure: FALSE. The critical section is currently held by another thread. * Failure: FALSE. The critical section is currently held by another thread.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(), * RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlLeaveCriticalSection(), RtlSetCriticalSectionSpinCount() * RtlLeaveCriticalSection(), RtlSetCriticalSectionSpinCount()
...@@ -561,6 +608,7 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) ...@@ -561,6 +608,7 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
* STATUS_SUCCESS. * STATUS_SUCCESS.
* *
* SEE * SEE
* RtlInitializeCriticalSectionEx(),
* RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(), * RtlInitializeCriticalSection(), RtlInitializeCriticalSectionAndSpinCount(),
* RtlDeleteCriticalSection(), RtlEnterCriticalSection(), * RtlDeleteCriticalSection(), RtlEnterCriticalSection(),
* RtlSetCriticalSectionSpinCount(), RtlTryEnterCriticalSection() * RtlSetCriticalSectionSpinCount(), RtlTryEnterCriticalSection()
......
...@@ -664,6 +664,7 @@ ...@@ -664,6 +664,7 @@
@ stub RtlInitializeContext @ stub RtlInitializeContext
@ stdcall RtlInitializeCriticalSection(ptr) @ stdcall RtlInitializeCriticalSection(ptr)
@ stdcall RtlInitializeCriticalSectionAndSpinCount(ptr long) @ stdcall RtlInitializeCriticalSectionAndSpinCount(ptr long)
@ stdcall RtlInitializeCriticalSectionEx(ptr long long)
@ stdcall RtlInitializeGenericTable(ptr ptr ptr ptr ptr) @ stdcall RtlInitializeGenericTable(ptr ptr ptr ptr ptr)
# @ stub RtlInitializeGenericTableAvl # @ stub RtlInitializeGenericTableAvl
@ stdcall RtlInitializeHandleTable(long long ptr) @ stdcall RtlInitializeHandleTable(long long ptr)
......
...@@ -54,6 +54,8 @@ typedef RTL_CRITICAL_SECTION_DEBUG CRITICAL_SECTION_DEBUG; ...@@ -54,6 +54,8 @@ typedef RTL_CRITICAL_SECTION_DEBUG CRITICAL_SECTION_DEBUG;
typedef PRTL_CRITICAL_SECTION_DEBUG PCRITICAL_SECTION_DEBUG; typedef PRTL_CRITICAL_SECTION_DEBUG PCRITICAL_SECTION_DEBUG;
typedef PRTL_CRITICAL_SECTION_DEBUG LPCRITICAL_SECTION_DEBUG; typedef PRTL_CRITICAL_SECTION_DEBUG LPCRITICAL_SECTION_DEBUG;
#define CRITICAL_SECTION_NO_DEBUG_INFO RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO
typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK; typedef WAITORTIMERCALLBACKFUNC WAITORTIMERCALLBACK;
#define EXCEPTION_DEBUG_EVENT 1 #define EXCEPTION_DEBUG_EVENT 1
...@@ -1777,6 +1779,7 @@ WINBASEAPI BOOL WINAPI InitAtomTable(DWORD); ...@@ -1777,6 +1779,7 @@ WINBASEAPI BOOL WINAPI InitAtomTable(DWORD);
WINADVAPI BOOL WINAPI InitializeAcl(PACL,DWORD,DWORD); WINADVAPI BOOL WINAPI InitializeAcl(PACL,DWORD,DWORD);
WINBASEAPI void WINAPI InitializeCriticalSection(CRITICAL_SECTION *lpCrit); WINBASEAPI void WINAPI InitializeCriticalSection(CRITICAL_SECTION *lpCrit);
WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION *,DWORD); WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount(CRITICAL_SECTION *,DWORD);
WINBASEAPI BOOL WINAPI InitializeCriticalSectionEx(CRITICAL_SECTION *,DWORD,DWORD);
WINADVAPI BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR,DWORD); WINADVAPI BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR,DWORD);
WINADVAPI BOOL WINAPI InitializeSid(PSID,PSID_IDENTIFIER_AUTHORITY,BYTE); WINADVAPI BOOL WINAPI InitializeSid(PSID,PSID_IDENTIFIER_AUTHORITY,BYTE);
WINBASEAPI VOID WINAPI InitializeSListHead(PSLIST_HEADER); WINBASEAPI VOID WINAPI InitializeSListHead(PSLIST_HEADER);
......
...@@ -4700,6 +4700,12 @@ typedef struct _RTL_CRITICAL_SECTION { ...@@ -4700,6 +4700,12 @@ typedef struct _RTL_CRITICAL_SECTION {
ULONG_PTR SpinCount; ULONG_PTR SpinCount;
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION; } RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
#define RTL_CRITICAL_SECTION_FLAG_NO_DEBUG_INFO 0x1000000
#define RTL_CRITICAL_SECTION_FLAG_DYNAMIC_SPIN 0x2000000
#define RTL_CRITICAL_SECTION_FLAG_STATIC_INIT 0x4000000
#define RTL_CRITICAL_SECTION_ALL_FLAG_BITS 0xFF000000
#define RTL_CRITICAL_SECTION_FLAG_RESERVED (RTL_CRITICAL_SECTION_ALL_FLAG_BITS & ~0x7000000)
typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN ); typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID ); typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
......
...@@ -2219,7 +2219,8 @@ NTSYSAPI NTSTATUS WINAPI RtlInitAnsiStringEx(PANSI_STRING,PCSZ); ...@@ -2219,7 +2219,8 @@ NTSYSAPI NTSTATUS WINAPI RtlInitAnsiStringEx(PANSI_STRING,PCSZ);
NTSYSAPI void WINAPI RtlInitUnicodeString(PUNICODE_STRING,PCWSTR); NTSYSAPI void WINAPI RtlInitUnicodeString(PUNICODE_STRING,PCWSTR);
NTSYSAPI NTSTATUS WINAPI RtlInitUnicodeStringEx(PUNICODE_STRING,PCWSTR); NTSYSAPI NTSTATUS WINAPI RtlInitUnicodeStringEx(PUNICODE_STRING,PCWSTR);
NTSYSAPI NTSTATUS WINAPI RtlInitializeCriticalSection(RTL_CRITICAL_SECTION *); NTSYSAPI NTSTATUS WINAPI RtlInitializeCriticalSection(RTL_CRITICAL_SECTION *);
NTSYSAPI NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount(RTL_CRITICAL_SECTION *,DWORD); NTSYSAPI NTSTATUS WINAPI RtlInitializeCriticalSectionAndSpinCount(RTL_CRITICAL_SECTION *,ULONG);
NTSYSAPI NTSTATUS WINAPI RtlInitializeCriticalSectionEx(RTL_CRITICAL_SECTION *,ULONG,ULONG);
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP,PULONG,ULONG); NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP,PULONG,ULONG);
NTSYSAPI void WINAPI RtlInitializeHandleTable(ULONG,ULONG,RTL_HANDLE_TABLE *); NTSYSAPI void WINAPI RtlInitializeHandleTable(ULONG,ULONG,RTL_HANDLE_TABLE *);
NTSYSAPI void WINAPI RtlInitializeResource(LPRTL_RWLOCK); NTSYSAPI void WINAPI RtlInitializeResource(LPRTL_RWLOCK);
......
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