diff --git a/reactos/lib/kernel32/kernel32.edf b/reactos/lib/kernel32/kernel32.edf index 2aa0e21a2f1..b8bbd68a2f9 100644 --- a/reactos/lib/kernel32/kernel32.edf +++ b/reactos/lib/kernel32/kernel32.edf @@ -1,4 +1,4 @@ -; $Id: kernel32.edf,v 1.9 2001/01/05 05:39:18 phreak Exp $ +; $Id: kernel32.edf,v 1.10 2001/02/17 00:02:32 ekohl Exp $ ; ; kernel32.edf ; @@ -109,7 +109,7 @@ DebugBreak=DebugBreak@0 DefineDosDeviceA=DefineDosDeviceA@12 DefineDosDeviceW=DefineDosDeviceW@12 DeleteAtom=DeleteAtom@4 -DeleteCriticalSection=DeleteCriticalSection@4 +DeleteCriticalSection=NTDLL.RtlDeleteCriticalSection DeleteFiber=DeleteFiber@4 DeleteFileA=DeleteFileA@4 DeleteFileW=DeleteFileW@4 @@ -121,7 +121,7 @@ DuplicateConsoleHandle=DuplicateConsoleHandle@16 DuplicateHandle=DuplicateHandle@28 EndUpdateResourceA=EndUpdateResourceA@8 EndUpdateResourceW=EndUpdateResourceW@8 -EnterCriticalSection=EnterCriticalSection@4 +EnterCriticalSection=NTDLL.RtlEnterCriticalSection EnumCalendarInfoA=EnumCalendarInfoA@16 EnumCalendarInfoW=EnumCalendarInfoW@16 EnumDateFormatsA=EnumDateFormatsA@12 @@ -385,17 +385,17 @@ GlobalUnWire=GlobalUnWire@4 GlobalUnfix=GlobalUnfix@4 GlobalUnlock=GlobalUnlock@4 GlobalWire=GlobalWire@4 -HeapAlloc=HeapAlloc@12 +HeapAlloc=NTDLL.RtlAllocateHeap HeapCompact=HeapCompact@8 HeapCreate=HeapCreate@12 HeapCreateTagsW=HeapCreateTagsW@16 HeapDestroy=HeapDestroy@4 HeapExtend=HeapExtend@16 -HeapFree=HeapFree@12 +HeapFree=NTDLL.RtlFreeHeap HeapLock=HeapLock@4 HeapQueryTagW=HeapQueryTagW@20 -HeapReAlloc=HeapReAlloc@16 -HeapSize=HeapSize@12 +HeapReAlloc=NTDLL.RtlReAllocateHeap +HeapSize=NTDLL.RtlSizeHeap HeapSummary=HeapSummary@12 HeapUnlock=HeapUnlock@4 HeapUsage=HeapUsage@20 @@ -423,7 +423,7 @@ IsValidCodePage=IsValidCodePage@4 IsValidLocale=IsValidLocale@8 LCMapStringA=LCMapStringA@24 LCMapStringW=LCMapStringW@24 -LeaveCriticalSection=LeaveCriticalSection@4 +LeaveCriticalSection=NTDLL.RtlLeaveCriticalSection LoadLibraryA=LoadLibraryA@4 LoadLibraryExA=LoadLibraryExA@12 LoadLibraryExW=LoadLibraryExW@12 @@ -503,10 +503,10 @@ RemoveDirectoryA=RemoveDirectoryA@4 RemoveDirectoryW=RemoveDirectoryW@4 ResetEvent=ResetEvent@4 ResumeThread=ResumeThread@4 -RtlFillMemory=RtlFillMemory@12 -RtlMoveMemory=RtlMoveMemory@12 -RtlUnwind=RtlUnwind@16 -RtlZeroMemory=RtlZeroMemory@8 +RtlFillMemory=NTDLL.RtlFillMemory +RtlMoveMemory=NTDLL.RtlMoveMemory +RtlUnwind=NTDLL.RtlUnwind +RtlZeroMemory=NTDLL.RtlZeroMemory ScrollConsoleScreenBufferA=ScrollConsoleScreenBufferA@20 ScrollConsoleScreenBufferW=ScrollConsoleScreenBufferW@20 SearchPathA=SearchPathA@24 @@ -604,7 +604,7 @@ TlsSetValue=TlsSetValue@8 TransactNamedPipe=TransactNamedPipe@28 TransmitCommChar=TransmitCommChar@8 TrimVirtualBuffer=TrimVirtualBuffer@4 -TryEnterCriticalSection=TryEnterCriticalSection@4 +TryEnterCriticalSection=NTDLL.RtlTryEnterCriticalSection UnhandledExceptionFilter=UnhandledExceptionFilter@4 UnlockFile=UnlockFile@20 UnlockFileEx=UnlockFileEx@20 diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index 31a7b009465..2b69015e61d 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.42 2001/01/20 12:17:51 ekohl Exp $ +# $Id: makefile,v 1.43 2001/02/17 00:02:32 ekohl Exp $ # # ReactOS Operating System # @@ -18,7 +18,7 @@ SYNCH_OBJECTS = synch/critical.o synch/event.o synch/intrlck.o synch/mutex.o \ synch/sem.o synch/timer.o synch/wait.o MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o \ - misc/console.o misc/time.o misc/stubs.o misc/rtl.o misc/ldr.o misc/res.o \ + misc/console.o misc/time.o misc/stubs.o misc/ldr.o misc/res.o \ misc/debug.o misc/sysinfo.o FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \ diff --git a/reactos/lib/kernel32/mem/heap.c b/reactos/lib/kernel32/mem/heap.c index 1a7475e3ba9..1c6fb061c75 100644 --- a/reactos/lib/kernel32/mem/heap.c +++ b/reactos/lib/kernel32/mem/heap.c @@ -1,4 +1,4 @@ -/* $Id: heap.c,v 1.16 1999/09/12 22:09:34 ea Exp $ +/* $Id: heap.c,v 1.17 2001/02/17 00:01:26 ekohl Exp $ * * kernel/heap.c * Copyright (C) 1996, Onno Hovers, All rights reserved @@ -51,30 +51,6 @@ BOOL WINAPI HeapDestroy(HANDLE hheap) return(RtlDestroyHeap(hheap)); } -/********************************************************************* -* HeapAlloc -- KERNEL32 * -*********************************************************************/ -LPVOID STDCALL HeapAlloc(HANDLE hheap, DWORD flags, DWORD size) -{ - return(RtlAllocateHeap(hheap, flags, size)); -} - -/********************************************************************* -* HeapReAlloc -- KERNEL32 * -*********************************************************************/ -LPVOID STDCALL HeapReAlloc(HANDLE hheap, DWORD flags, LPVOID ptr, DWORD size) -{ - return(RtlReAllocateHeap(hheap, flags, ptr, size)); -} - -/********************************************************************* -* HeapFree -- KERNEL32 * -*********************************************************************/ -WINBOOL STDCALL HeapFree(HANDLE hheap, DWORD flags, LPVOID ptr) -{ - return(RtlFreeHeap(hheap, flags, ptr)); -} - /********************************************************************* * GetProcessHeap -- KERNEL32 * *********************************************************************/ @@ -118,25 +94,11 @@ BOOL WINAPI HeapUnlock(HANDLE hheap) * NT uses this function to compact moveable blocks and other things * * Here it does not compact, but it finds the largest free region * *********************************************************************/ -UINT -STDCALL -HeapCompact ( - HANDLE hheap, - DWORD flags - ) +UINT STDCALL +HeapCompact(HANDLE hheap, + DWORD flags) { - return RtlCompactHeap( - hheap, - flags - ); -} - -/********************************************************************* -* HeapSize -- KERNEL32 * -*********************************************************************/ -DWORD WINAPI HeapSize(HANDLE hheap, DWORD flags, LPCVOID pmem) -{ - return(RtlSizeHeap(hheap, flags, (PVOID)pmem)); + return RtlCompactHeap(hheap, flags); } /********************************************************************* diff --git a/reactos/lib/kernel32/misc/rtl.c b/reactos/lib/kernel32/misc/rtl.c deleted file mode 100644 index b185a37bf27..00000000000 --- a/reactos/lib/kernel32/misc/rtl.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id: rtl.c,v 1.4 2001/02/10 22:51:07 dwelch Exp $ - * - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/kernel32/misc/rtl.c - * PURPOSE: - * PROGRAMMER: Boudewijn Dekker - */ - -/* INCLUDES ******************************************************************/ - -#include - -typedef DWORD -(*RtlFillMemoryType) (PVOID Destination, ULONG Length, UCHAR Fill); - -#undef FillMemory -VOID STDCALL -RtlFillMemory (PVOID Destination, ULONG Length, UCHAR Fill) -{ - HINSTANCE hModule; - RtlFillMemoryType FillMemory; - - hModule = LoadLibraryA("ntdll.dll"); - if (hModule == NULL) - return; - FillMemory = (RtlFillMemoryType)GetProcAddress(hModule, "RtlFillMemory"); - if ( FillMemory == NULL ) - return; - FillMemory(Destination, Length, Fill); -} - -typedef DWORD -(*RtlMoveMemoryType) (PVOID Destination, CONST VOID* Source, ULONG Length); -#undef MoveMemory -VOID STDCALL -RtlMoveMemory (PVOID Destination, CONST VOID* Source, ULONG Length) -{ - HINSTANCE hModule; - RtlMoveMemoryType MoveMemory; - - hModule = LoadLibraryA("ntdll.dll"); - if (hModule == NULL) - return; - MoveMemory = (RtlMoveMemoryType)GetProcAddress(hModule, "RtlMoveMemory"); - if (MoveMemory == NULL) - return; - MoveMemory(Destination, Source, Length); -} - -typedef DWORD ( *RtlZeroMemoryType) (PVOID Destination, ULONG Length); -#undef ZeroMemory -VOID STDCALL -RtlZeroMemory (PVOID Destination, ULONG Length) -{ - HINSTANCE hModule; - RtlZeroMemoryType ZeroMemory; - - hModule = LoadLibraryA("ntdll.dll"); - if (hModule == NULL) - return; - ZeroMemory = (RtlZeroMemoryType)GetProcAddress(hModule, "RtlZeroMemory"); - if (ZeroMemory == NULL) - return; - ZeroMemory(Destination, Length); -} - -typedef DWORD ( *RtlUnwindType) (DWORD Unknown0, DWORD Unknown1, DWORD Unknown2, DWORD Unknown3 ); -#undef Unwind -VOID -STDCALL -RtlUnwind ( - ULONG Unknown0, - ULONG Unknown1, - ULONG Unknown2, - ULONG Unknown3 - ) -{ - HINSTANCE hModule; - RtlUnwindType Unwind; - hModule = LoadLibraryA("ntdll.dll"); - if ( hModule == NULL ) - return; - Unwind = (RtlUnwindType)GetProcAddress(hModule, "RtlUnwind"); - if ( Unwind == NULL ) - return; - Unwind(Unknown0, Unknown1, Unknown2, Unknown3); -} - - -/* EOF */ diff --git a/reactos/lib/kernel32/synch/critical.c b/reactos/lib/kernel32/synch/critical.c index d3a374b4a1b..22a73e35408 100644 --- a/reactos/lib/kernel32/synch/critical.c +++ b/reactos/lib/kernel32/synch/critical.c @@ -1,9 +1,9 @@ -/* $Id: critical.c,v 1.9 2000/04/25 23:22:55 ea Exp $ +/* $Id: critical.c,v 1.10 2001/02/17 00:02:13 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/kernel32/sync/critical.c - * PURPOSE: Critical regions + * PURPOSE: Critical sections * UPDATE HISTORY: * Created 30/09/98 */ @@ -14,85 +14,19 @@ #include -#define NTOS_MODE_USER -#include /* FUNCTIONS *****************************************************************/ - -VOID -STDCALL -DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection) +VOID STDCALL +InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection) { - CloseHandle(lpCriticalSection->LockSemaphore); - lpCriticalSection->Reserved = -1; + NTSTATUS Status; + + Status = RtlInitializeCriticalSection(lpCriticalSection); + if (!NT_SUCCESS(Status)) + { + RtlRaiseStatus(Status); + } } - -VOID -STDCALL -EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - if( InterlockedIncrement(&(lpCriticalSection->LockCount) ) != 1 ) { - if (lpCriticalSection->OwningThread != (HANDLE)GetCurrentThreadId() ) { - WaitForSingleObject(lpCriticalSection->LockSemaphore,100000); - // WAIT_TIMEOUT should give message if DEBUG - lpCriticalSection->OwningThread = (HANDLE)GetCurrentThreadId(); - } - } - else - lpCriticalSection->OwningThread = (HANDLE)GetCurrentThreadId(); - - lpCriticalSection->RecursionCount++; -} - - -VOID -STDCALL -InitializeCriticalSection(LPCRITICAL_SECTION pcritical) -{ - pcritical->LockCount = -1; - pcritical->RecursionCount = 0; - pcritical->LockSemaphore = CreateSemaphoreW(NULL,0,100,NULL); - pcritical->OwningThread = (HANDLE)-1; // critical section has no owner yet - pcritical->Reserved = 0; -} - - -VOID -STDCALL -LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - lpCriticalSection->RecursionCount--; - if ( lpCriticalSection->RecursionCount == 0 ) { - lpCriticalSection->OwningThread = (HANDLE)-1; - // if LockCount > 0 and RecursionCount == 0 there - // is a waiting thread - // ReleaseSemaphore will fire up a waiting thread - if ( InterlockedDecrement( &lpCriticalSection->LockCount ) > 0 ) - ReleaseSemaphore( lpCriticalSection->LockSemaphore,1,NULL); - } - else InterlockedDecrement( &lpCriticalSection->LockCount ); -} - - -WINBOOL -STDCALL -TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - if( InterlockedCompareExchange( (PVOID *)&lpCriticalSection->LockCount, (PVOID)1, (PVOID)0 ) == 0 ) - { - lpCriticalSection->OwningThread = (HANDLE)GetCurrentThreadId(); - lpCriticalSection->RecursionCount++; - return TRUE; - } - if( lpCriticalSection->OwningThread == (HANDLE)GetCurrentThreadId() ) - { - lpCriticalSection->RecursionCount++; - return TRUE; - } - return FALSE; -} - - /* EOF */