Index: trunk/src/kernel32/heap.cpp
===================================================================
--- trunk/src/kernel32/heap.cpp	(revision 7025)
+++ trunk/src/kernel32/heap.cpp	(revision 7027)
@@ -1,3 +1,3 @@
-/* $Id: heap.cpp,v 1.35 2001-10-10 22:25:34 phaller Exp $ */
+/* $Id: heap.cpp,v 1.36 2001-10-12 03:48:06 phaller Exp $ */
 
 /*
@@ -226,8 +226,8 @@
  *	NULL: Failure
  */
-HGLOBAL WINAPI GlobalAlloc(
-                 UINT flags, /* [in] Object allocation attributes */
-                 DWORD size    /* [in] Number of bytes to allocate */
-) {
+ODINFUNCTION2(HGLOBAL, GlobalAlloc,
+              UINT, flags,
+              DWORD, size)
+{
    PGLOBAL32_INTERN     pintern;
    DWORD		hpflags;
@@ -280,7 +280,7 @@
  *	NULL: Failure
  */
-LPVOID WINAPI GlobalLock(
-              HGLOBAL hmem /* [in] Handle of global memory object */
-) {
+ODINFUNCTION1(LPVOID, GlobalLock,
+              HGLOBAL, hmem)
+{
    PGLOBAL32_INTERN pintern;
    LPVOID           palloc;
@@ -328,11 +328,9 @@
  *	FALSE: Object is unlocked
  */
-BOOL WINAPI GlobalUnlock(
-              HGLOBAL hmem /* [in] Handle of global memory object */
-) {
+ODINFUNCTION1(BOOL, GlobalUnlock,
+              HGLOBAL, hmem)
+{
    PGLOBAL32_INTERN       pintern;
    BOOL                 locked;
-
-   dprintf(("KERNEL32: GlobalUnlock %x", hmem));
 
    if(hmem == NULL || ISPOINTER(hmem))
@@ -377,12 +375,10 @@
  *	NULL: Failure
  */
-HGLOBAL WINAPI GlobalHandle(
-                 LPCVOID pmem /* [in] Pointer to global memory block */
-) {
+ODINFUNCTION1(HGLOBAL, GlobalHandle,
+              LPCVOID, pmem)
+{
     HGLOBAL handle;
     PGLOBAL32_INTERN  maybe_intern;
     LPCVOID test;
-
-    dprintf(("KERNEL32: GlobalHandle %x", pmem));
 
     if (!pmem)
@@ -470,9 +466,9 @@
  *	NULL: Failure
  */
-HGLOBAL WINAPI GlobalReAlloc(
-                 HGLOBAL hmem, /* [in] Handle of global memory object */
-                 DWORD size,     /* [in] New size of block */
-                 UINT flags    /* [in] How to reallocate object */
-) {
+ODINFUNCTION3(HGLOBAL, GlobalReAlloc,
+                 HGLOBAL, hmem,
+                 DWORD, size,
+                 UINT, flags)
+{
    LPVOID               palloc;
    HGLOBAL            hnew;
@@ -580,11 +576,9 @@
  *	Handle: Failure
  */
-HGLOBAL WINAPI GlobalFree(
-                 HGLOBAL hmem /* [in] Handle of global memory object */
-) {
+ODINFUNCTION1(HGLOBAL, GlobalFree,
+              HGLOBAL, hmem)
+{
    PGLOBAL32_INTERN pintern;
    HGLOBAL        hreturned = 0;
-
-   dprintf(("KERNEL32: GlobalFree %x", hmem));
 
    /* verify lpMem address */
@@ -631,11 +625,9 @@
  *	0: Failure
  */
-DWORD WINAPI GlobalSize(
-             HGLOBAL hmem /* [in] Handle of global memory object */
-) {
+ODINFUNCTION1(DWORD, GlobalSize,
+              HGLOBAL, hmem)
+{
    DWORD                retval;
    PGLOBAL32_INTERN     pintern;
-
-   dprintf(("KERNEL32: GlobalSize %x", hmem));
 
    if(ISPOINTER(hmem)) 
@@ -674,5 +666,6 @@
  *           GlobalWire   (KERNEL32.@)
  */
-LPVOID WINAPI GlobalWire(HGLOBAL hmem)
+ODINFUNCTION1(LPVOID, GlobalWire,
+              HGLOBAL, hmem)
 {
    return GlobalLock( hmem );
@@ -683,5 +676,6 @@
  *           GlobalUnWire   (KERNEL32.@)
  */
-BOOL WINAPI GlobalUnWire(HGLOBAL hmem)
+ODINFUNCTION1(BOOL, GlobalUnWire,
+              HGLOBAL, hmem)
 {
    return GlobalUnlock( hmem);
@@ -692,5 +686,6 @@
  *           GlobalFix   (KERNEL32.@)
  */
-VOID WINAPI GlobalFix(HGLOBAL hmem)
+ODINPROCEDURE1(GlobalFix,
+               HGLOBAL, hmem)
 {
     GlobalLock( hmem );
@@ -701,5 +696,6 @@
  *           GlobalUnfix   (KERNEL32.@)
  */
-VOID WINAPI GlobalUnfix(HGLOBAL hmem)
+ODINPROCEDURE1(GlobalUnfix,
+               HGLOBAL, hmem)
 {
    GlobalUnlock( hmem);
@@ -718,12 +714,10 @@
  *	GMEM_INVALID_HANDLE: Failure
  */
-UINT WINAPI GlobalFlags(
-              HGLOBAL hmem /* [in] Handle to global memory object */
-) {
+ODINFUNCTION1(UINT, GlobalFlags,
+              HGLOBAL, hmem)
+{
    DWORD                retval;
    PGLOBAL32_INTERN     pintern;
 
-   dprintf(("KERNEL32: GlobalFlags %x", hmem));
-   
    if(ISPOINTER(hmem))
    {
@@ -754,8 +748,7 @@
  *           GlobalCompact   (KERNEL32.@)
  */
-DWORD WINAPI GlobalCompact( DWORD minfree )
-{
-    dprintf(("KERNEL32:  GlobalCompact %d OBSOLETE", minfree));
-
+ODINFUNCTION1(DWORD, GlobalCompact,
+              DWORD, minfree )
+{
     return 0;  /* GlobalCompact does nothing in Win32 */
 }
@@ -766,5 +759,7 @@
 #endif
 //******************************************************************************
-HGLOBAL WIN32API GlobalAlloc(UINT fuFlags, DWORD dwBytes)
+ODINFUNCTION2(HGLOBAL, GlobalAlloc,
+              UINT, fuFlags, 
+              DWORD, dwBytes)
 {
  HGLOBAL ret;
@@ -774,10 +769,10 @@
     totalGlobalAlloc += dwBytes;
 #endif
-    dprintf(("KERNEL32: GlobalAlloc %x %d returned %x (total %x)", fuFlags, dwBytes, ret, totalGlobalAlloc));
     return ret;
 }
 //******************************************************************************
 //******************************************************************************
-HGLOBAL WIN32API GlobalFree( HGLOBAL arg1)
+ODINFUNCTION1(HGLOBAL, GlobalFree,
+              HGLOBAL, arg1)
 {
  HGLOBAL ret;
@@ -787,63 +782,55 @@
 #endif
     ret = O32_GlobalFree(arg1);
-    dprintf(("KERNEL32: GlobalFree %x returned %x (lasterr=%x) total %x", arg1, ret, GetLastError(), totalGlobalAlloc));
     return ret;
 }
 //******************************************************************************
 //******************************************************************************
-HGLOBAL WIN32API GlobalHandle( LPCVOID lpMem)
-{
-    dprintf(("KERNEL32: GlobalHandle %x", lpMem));
-
+ODINFUNCTION1(HGLOBAL, GlobalHandle,
+              LPCVOID, lpMem)
+{
     return O32_GlobalHandle((LPVOID)lpMem);
 }
 //******************************************************************************
 //******************************************************************************
-UINT WIN32API GlobalFlags(HGLOBAL hMem)
-{
-    dprintf(("KERNEL32: GlobalFlags %x", hMem));
-
+ODINFUNCTION1(UINT, GlobalFlags,
+              HGLOBAL, hMem)
+{
     return O32_GlobalFlags(hMem);
 }
 //******************************************************************************
 //******************************************************************************
-DWORD WIN32API GlobalCompact(DWORD dwMinFree)
-{
-  dprintf(("KERNEL32:  GlobalCompact, OBSOLETE - stub\n"));
-
+ODINFUNCTION1(DWORD, GlobalCompact,
+              DWORD, dwMinFree)
+{
   return(0);
 }
 //******************************************************************************
 //******************************************************************************
-PVOID WIN32API GlobalLock(HGLOBAL hMem)
-{
- PVOID ret;
-
-    ret = O32_GlobalLock(hMem);
-    dprintf(("KERNEL32: GlobalLock %x returned %x", hMem, ret));
-    return ret;
-}
-//******************************************************************************
-//******************************************************************************
-HGLOBAL WIN32API GlobalReAlloc(HGLOBAL arg1, DWORD arg2, UINT  arg3)
-{
-    dprintf(("KERNEL32: GlobalReAlloc %x %x %d", arg1, arg2, arg3));
-
+ODINFUNCTION1(PVOID, GlobalLock,
+              HGLOBAL, hMem)
+{
+  return O32_GlobalLock(hMem);
+}
+//******************************************************************************
+//******************************************************************************
+ODINFUNCTION3(HGLOBAL, GlobalReAlloc,
+              HGLOBAL, arg1,
+              DWORD, arg2,
+              UINT,  arg3)
+{
     return O32_GlobalReAlloc(arg1, arg2, arg3);
 }
 //******************************************************************************
 //******************************************************************************
-DWORD WIN32API GlobalSize(HGLOBAL arg1)
-{
-    dprintf(("KERNEL32:  GlobalSize\n"));
-
+ODINFUNCTION1(DWORD, GlobalSize,
+              HGLOBAL, arg1)
+{
     return O32_GlobalSize(arg1);
 }
 //******************************************************************************
 //******************************************************************************
-BOOL WIN32API GlobalUnlock(HGLOBAL arg1)
-{
-    dprintf(("KERNEL32:  GlobalUnlock\n"));
-
+ODINFUNCTION1(BOOL, GlobalUnlock,
+              HGLOBAL, arg1)
+{
     return O32_GlobalUnlock(arg1);
 }
@@ -856,5 +843,6 @@
  *
  */
-LPVOID WIN32API GlobalWire(HGLOBAL hmem)
+ODINFUNCTION1(LPVOID, GlobalWire,
+              HGLOBAL, hmem)
 {
    return GlobalLock( hmem );
@@ -868,5 +856,6 @@
  *
  */
-BOOL WIN32API GlobalUnWire(HGLOBAL hmem)
+ODINFUNCTION1(BOOL, GlobalUnWire,
+              HGLOBAL, hmem)
 {
    return GlobalUnlock( hmem);
@@ -874,8 +863,7 @@
 //******************************************************************************
 //******************************************************************************
-HGLOBAL WIN32API GlobalDiscard(HGLOBAL hGlobal)
-{
-    dprintf(("KERNEL32: GlobalDiscard %x", hGlobal));
-
+ODINFUNCTION1(HGLOBAL, GlobalDiscard,
+              HGLOBAL, hGlobal)
+{
     return O32_GlobalDiscard(hGlobal);
 }
@@ -883,5 +871,6 @@
  *           GlobalFix   (KERNEL32.@)
  */
-VOID WINAPI GlobalFix(HGLOBAL hmem)
+ODINPROCEDURE1(GlobalFix,
+               HGLOBAL, hmem)
 {
     GlobalLock( hmem );
@@ -890,5 +879,6 @@
  *           GlobalUnfix   (KERNEL32.@)
  */
-VOID WINAPI GlobalUnfix(HGLOBAL hmem)
+ODINPROCEDURE1(GlobalUnfix,
+               HGLOBAL, hmem)
 {
    GlobalUnlock( hmem);
@@ -897,5 +887,7 @@
 //******************************************************************************
 //******************************************************************************
-HLOCAL WIN32API LocalAlloc(UINT fuFlags, DWORD cbBytes)
+ODINFUNCTION2(HLOCAL, LocalAlloc,
+              UINT, fuFlags, 
+              DWORD, cbBytes)
 {
     HLOCAL hLocal;
@@ -916,8 +908,8 @@
 //******************************************************************************
 //******************************************************************************
-UINT WIN32API LocalFlags(HLOCAL hMem)
+ODINFUNCTION1(UINT, LocalFlags,
+              HLOCAL, hMem)
 {
     UINT ret, retG;
-    dprintf(("KERNEL32: LocalFlags %X\n", hMem));
 
     retG = GlobalFlags(hMem);
@@ -937,24 +929,21 @@
 //******************************************************************************
 //******************************************************************************
-HLOCAL WIN32API LocalFree(HLOCAL hMem)
-{
-  dprintf(("KERNEL32: LocalFree %X", hMem));
-
+ODINFUNCTION1(HLOCAL, LocalFree,
+              HLOCAL, hMem)
+{
   return GlobalFree(hMem);
 }
 //******************************************************************************
 //******************************************************************************
-HLOCAL WIN32API LocalHandle(PCVOID lpMem)
-{
-    dprintf(("KERNEL32: LocalHandle %x", lpMem));
-
+ODINFUNCTION1(HLOCAL, LocalHandle,
+              PCVOID, lpMem)
+{
     return GlobalHandle(lpMem);
 }
 //******************************************************************************
 //******************************************************************************
-BOOL WIN32API LocalUnlock(HLOCAL hMem)
-{
-    dprintf(("KERNEL32: LocalUnlock %X", hMem));
-
+ODINFUNCTION1(BOOL, LocalUnlock,
+              HLOCAL, hMem)
+{
     return GlobalUnlock(hMem);
 }
@@ -962,11 +951,12 @@
 //TODO: cbBytes==0 && fuFlags & LMEM_MOVEABLE not handled!!
 //******************************************************************************
-HLOCAL WIN32API LocalReAlloc(HLOCAL hMem, DWORD cbBytes, UINT fuFlags)
+ODINFUNCTION3(HLOCAL, LocalReAlloc,
+              HLOCAL, hMem,
+              DWORD, cbBytes,
+              UINT, fuFlags)
 {
   HLOCAL hLocalNew, hLocalOld;
   LPVOID lpMem, lpMemOld;
   DWORD  cbOldSize;
-
-    dprintf(("KERNEL32: LocalReAlloc %X %d %X\n", hMem, cbBytes, fuFlags));
 
     // Check flags
@@ -988,16 +978,14 @@
 //******************************************************************************
 //******************************************************************************
-UINT WIN32API LocalSize(HLOCAL hMem)
-{
-    dprintf(("KERNEL32: LocalSize %X", hMem));
-
+ODINFUNCTION1(UINT, LocalSize,
+              HLOCAL, hMem)
+{
     return GlobalSize(hMem);
 }
 //******************************************************************************
 //******************************************************************************
-PVOID WIN32API LocalLock(HLOCAL hMem)
-{
-    dprintf(("KERNEL32:  LocalLock %X\n", hMem));
-
+ODINFUNCTION1(PVOID, LocalLock,
+              HLOCAL, hMem)
+{
     return GlobalLock(hMem);
 }
@@ -1005,8 +993,8 @@
 //* this function is here for completeness, some stupid software requires it.
 //******************************************************************************
-UINT WIN32API LocalShrink(HLOCAL hMem, UINT cbNewSize)
-{
-    dprintf(("KERNEL32:  LocalShrink %X, %08xh - OBSOLETE", hMem, cbNewSize));
-
+ODINFUNCTION2(UINT, LocalShrink,
+              HLOCAL, hMem,
+              UINT, cbNewSize)
+{
     return cbNewSize;
 }
@@ -1014,8 +1002,7 @@
 //* this function is here for completeness, mIRC/32 requires it.
 //******************************************************************************
-UINT WIN32API LocalCompact(UINT cbNewSize)
-{
-    dprintf(("KERNEL32:  LocalCompact %08xh - OBSOLETE", cbNewSize));
-
+ODINFUNCTION1(UINT, LocalCompact,
+              UINT, cbNewSize)
+{
     return cbNewSize;
 }
Index: trunk/src/kernel32/os2heap.cpp
===================================================================
--- trunk/src/kernel32/os2heap.cpp	(revision 7025)
+++ trunk/src/kernel32/os2heap.cpp	(revision 7027)
@@ -1,3 +1,3 @@
-/* $Id: os2heap.cpp,v 1.26 2001-10-09 20:25:20 sandervl Exp $ */
+/* $Id: os2heap.cpp,v 1.27 2001-10-12 03:48:06 phaller Exp $ */
 
 /*
@@ -45,10 +45,19 @@
 void   _LNK_CONV releaseHeapMem(Heap_t pHeap, void *block, size_t size);
 
+
+//******************************************************************************
+// Fast Heap Handle Management
+//******************************************************************************
+
+static HANDLE   fhhm_lastHandle = 0;
+static OS2Heap* fhhm_lastHeap   = NULL;
+
+
 //******************************************************************************
 //******************************************************************************
 OS2Heap::OS2Heap(DWORD flOptions, DWORD dwInitialSize, DWORD dwMaximumSize)
 {
- OS2Heap *curheap = OS2Heap::heap;
-
+  OS2Heap *curheap = OS2Heap::heap;
+  
   totalAlloc   = 0;
   fInitialized = 0;
@@ -98,5 +107,10 @@
  OS2Heap *curheap = OS2Heap::heap;
  int i;
-
+  
+  // invalidate handle cache
+  fhhm_lastHandle = 0;
+  fhhm_lastHeap   = NULL;
+  
+  
   dprintf(("dtr OS2Heap, hPrimaryHeap = %X\n", hPrimaryHeap));
 
@@ -291,18 +305,33 @@
 OS2Heap *OS2Heap::find(HANDLE hHeap)
 {
+  // check against cache first
+  if (fhhm_lastHeap)
+    if (hHeap == fhhm_lastHandle)
+      return fhhm_lastHeap;
+  
   OS2Heap *curheap = OS2Heap::heap;
-
+  
   //@@@PH NT programs seem to assume heap 0 is always valid?!
   if (hHeap == 0)
-     if (curheap != NULL)
-       return curheap;
-
-  while(curheap != NULL) {
-        if(curheap->hPrimaryHeap == hHeap) {
-                return(curheap);
-        }
-        curheap = curheap->next;
+    if (curheap != NULL)
+    {
+      fhhm_lastHandle = hHeap;
+      fhhm_lastHeap   = curheap;
+      return curheap;
+    }
+
+  while(curheap != NULL) 
+  {
+    if(curheap->hPrimaryHeap == hHeap) 
+    {
+      fhhm_lastHandle = hHeap;
+      fhhm_lastHeap   = curheap;
+      return(curheap);
+    }
+    curheap = curheap->next;
   }
   dprintf(("Heap %X not found!\n", hHeap));
+  fhhm_lastHandle = hHeap;
+  fhhm_lastHeap   = NULL;
   return(NULL);
 }
Index: trunk/src/kernel32/perfview.cpp
===================================================================
--- trunk/src/kernel32/perfview.cpp	(revision 7025)
+++ trunk/src/kernel32/perfview.cpp	(revision 7027)
@@ -1,3 +1,3 @@
-/* $Id: perfview.cpp,v 1.2 2001-10-12 00:49:24 phaller Exp $ */
+/* $Id: perfview.cpp,v 1.3 2001-10-12 03:48:06 phaller Exp $ */
 
 /*
@@ -97,5 +97,8 @@
   // Note: this should rather be done where the times are taken,
   // however this would spread the code just too far.
-  nTicks -= tsCompensation;
+  if (tsCompensation < nTicks)
+    nTicks -= tsCompensation;
+  else
+    nTicks = 0;
   
   // check if that particular function is registered already
@@ -311,5 +314,5 @@
   if(_privateLogFile == NULL) 
   {
-    sprintf(szFilename, "%spe_%d.log", kernel32Path, loadNr);
+    sprintf(szFilename, "%sperf_%d.log", kernel32Path, loadNr);
     _privateLogFile = fopen(szFilename, "w");
   }
