[3/6] ntdll: Implement RtlIsCriticalSectionLocked[ByThread].
Sebastian Lackner
sebastian at fds-team.de
Fri Oct 9 22:39:50 CDT 2015
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
dlls/ntdll/critsection.c | 37 +++++++++++++++++++++++++++++++++++++
dlls/ntdll/ntdll.spec | 2 ++
dlls/ntdll/tests/rtl.c | 2 +-
include/winternl.h | 2 ++
4 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index 6e0332b..e2eb364 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -610,6 +610,43 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit )
/***********************************************************************
+ * RtlIsCriticalSectionLocked (NTDLL.@)
+ *
+ * Checks if the critical section is locked by any thread.
+ *
+ * PARAMS
+ * crit [I/O] Critical section to check.
+ *
+ * RETURNS
+ * Success: TRUE. The critical section is locked.
+ * Failure: FALSE. The critical section is not locked.
+ */
+BOOL WINAPI RtlIsCriticalSectionLocked( RTL_CRITICAL_SECTION *crit )
+{
+ return crit->RecursionCount != 0;
+}
+
+
+/***********************************************************************
+ * RtlIsCriticalSectionLockedByThread (NTDLL.@)
+ *
+ * Checks if the critical section is locked by the current thread.
+ *
+ * PARAMS
+ * crit [I/O] Critical section to check.
+ *
+ * RETURNS
+ * Success: TRUE. The critical section is locked.
+ * Failure: FALSE. The critical section is not locked.
+ */
+BOOL WINAPI RtlIsCriticalSectionLockedByThread( RTL_CRITICAL_SECTION *crit )
+{
+ return crit->OwningThread == ULongToHandle(GetCurrentThreadId()) &&
+ crit->RecursionCount;
+}
+
+
+/***********************************************************************
* RtlLeaveCriticalSection (NTDLL.@)
*
* Leaves a critical section.
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 6b3fc65..7f07b14 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -719,6 +719,8 @@
# @ stub RtlIpv6StringToAddressExW
# @ stub RtlIpv6StringToAddressW
@ stdcall RtlIsActivationContextActive(ptr)
+@ stdcall RtlIsCriticalSectionLocked(ptr)
+@ stdcall RtlIsCriticalSectionLockedByThread(ptr)
@ stdcall RtlIsDosDeviceName_U(wstr)
@ stub RtlIsGenericTableEmpty
# @ stub RtlIsGenericTableEmptyAvl
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 4ab3d1e..0f79f7d 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -2008,7 +2008,7 @@ static void test_RtlIsCriticalSectionLocked(void)
if (!pRtlIsCriticalSectionLocked || !pRtlIsCriticalSectionLockedByThread)
{
- skip("skipping RtlIsCriticalSectionLocked tests, required functions not available\n");
+ win_skip("skipping RtlIsCriticalSectionLocked tests, required functions not available\n");
return;
}
diff --git a/include/winternl.h b/include/winternl.h
index 3e64b4d..e76114e 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -2483,6 +2483,8 @@ NTSYSAPI NTSTATUS WINAPI RtlInt64ToUnicodeString(ULONGLONG,ULONG,UNICODE_STRING
NTSYSAPI NTSTATUS WINAPI RtlIntegerToChar(ULONG,ULONG,ULONG,PCHAR);
NTSYSAPI NTSTATUS WINAPI RtlIntegerToUnicodeString(ULONG,ULONG,UNICODE_STRING *);
NTSYSAPI BOOLEAN WINAPI RtlIsActivationContextActive(HANDLE);
+NTSYSAPI BOOL WINAPI RtlIsCriticalSectionLocked(RTL_CRITICAL_SECTION *);
+NTSYSAPI BOOL WINAPI RtlIsCriticalSectionLockedByThread(RTL_CRITICAL_SECTION *);
NTSYSAPI ULONG WINAPI RtlIsDosDeviceName_U(PCWSTR);
NTSYSAPI BOOLEAN WINAPI RtlIsNameLegalDOS8Dot3(const UNICODE_STRING*,POEM_STRING,PBOOLEAN);
NTSYSAPI BOOLEAN WINAPI RtlIsTextUnicode(LPCVOID,INT,INT *);
--
2.6.0
More information about the wine-patches
mailing list