Author: fireball
Date: Tue Oct 5 12:42:55 2010
New Revision: 48994
URL:
http://svn.reactos.org/svn/reactos?rev=48994&view=rev
Log:
[HEAP]
- Move on to using a real HEAP_LOCK structure for a heap lock.
- Implement kernel-mode counterparts of this lock too. Right now these don't introduce
much of a difference, but they are going to be properly used by the new heap manager
code.
Modified:
trunk/reactos/dll/ntdll/rtl/libsupp.c
trunk/reactos/include/ndk/rtltypes.h
trunk/reactos/ntoskrnl/rtl/libsupp.c
Modified: trunk/reactos/dll/ntdll/rtl/libsupp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/rtl/libsupp.c?re…
==============================================================================
--- trunk/reactos/dll/ntdll/rtl/libsupp.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/rtl/libsupp.c [iso-8859-1] Tue Oct 5 12:42:55 2010
@@ -113,33 +113,33 @@
NTSTATUS
NTAPI
RtlDeleteHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- return RtlDeleteCriticalSection(CriticalSection);
+ PHEAP_LOCK Lock)
+{
+ return RtlDeleteCriticalSection(&Lock->CriticalSection);
}
NTSTATUS
NTAPI
RtlEnterHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- return RtlEnterCriticalSection(CriticalSection);
+ PHEAP_LOCK Lock)
+{
+ return RtlEnterCriticalSection(&Lock->CriticalSection);
}
NTSTATUS
NTAPI
RtlInitializeHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- return RtlInitializeCriticalSection(CriticalSection);
+ PHEAP_LOCK Lock)
+{
+ return RtlInitializeCriticalSection(&Lock->CriticalSection);
}
NTSTATUS
NTAPI
RtlLeaveHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- return RtlLeaveCriticalSection(CriticalSection );
+ PHEAP_LOCK Lock)
+{
+ return RtlLeaveCriticalSection(&Lock->CriticalSection);
}
PVOID
Modified: trunk/reactos/include/ndk/rtltypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/rtltypes.h?rev…
==============================================================================
--- trunk/reactos/include/ndk/rtltypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/rtltypes.h [iso-8859-1] Tue Oct 5 12:42:55 2010
@@ -1038,6 +1038,21 @@
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;
#endif
+
+//
+// RTL Private Heap Structures
+//
+typedef struct _HEAP_LOCK
+{
+ union
+ {
+ RTL_CRITICAL_SECTION CriticalSection;
+#ifndef NTOS_MODE_USER
+ ERESOURCE Resource;
+#endif
+ UCHAR Padding[0x68]; /* Max ERESOURCE size for x64 build. Needed because RTL is
built only once */
+ };
+} HEAP_LOCK, *PHEAP_LOCK;
//
// RTL Range List Structures
Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/libsupp.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] Tue Oct 5 12:42:55 2010
@@ -157,36 +157,35 @@
NTSTATUS
NTAPI
RtlDeleteHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- ASSERT(FALSE);
+ PHEAP_LOCK Lock)
+{
+ ExDeleteResource(&Lock->Resource);
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
RtlEnterHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- ASSERT(FALSE);
+ PHEAP_LOCK Lock)
+{
+ return ExAcquireResourceExclusive(&Lock->Resource, TRUE);
+}
+
+NTSTATUS
+NTAPI
+RtlInitializeHeapLock(
+ PHEAP_LOCK Lock)
+{
+ ExInitializeResource(&Lock->Resource);
return STATUS_SUCCESS;
}
NTSTATUS
NTAPI
-RtlInitializeHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- ASSERT(FALSE);
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
RtlLeaveHeapLock(
- PRTL_CRITICAL_SECTION CriticalSection)
-{
- ASSERT(FALSE);
+ PHEAP_LOCK Lock)
+{
+ ExReleaseResource(&Lock->Resource);
return STATUS_SUCCESS;
}