- Timestamp:
- Jul 21, 2002, 11:17:28 AM (23 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/heapshared.cpp
r8877 r8898 1 /* $Id: heapshared.cpp,v 1. 9 2002-07-15 14:28:51sandervl Exp $ */1 /* $Id: heapshared.cpp,v 1.10 2002-07-21 09:17:28 sandervl Exp $ */ 2 2 /* 3 3 * Shared heap functions for OS/2 … … 18 18 #define INCL_DOSMEMMGR 19 19 #include <os2wrap.h> 20 #include <misc.h> 20 #include <string.h> 21 #include <dbglog.h> 21 22 #include <heapshared.h> 23 #include "initterm.h" 22 24 23 25 #define DBG_LOCALLOG DBG_heapshared 24 26 #include "dbglocal.h" 27 28 #define MAX_HEAPSIZE (2048*1024) 29 #define MAX_HEAPPAGES (MAX_HEAPSIZE/PAGE_SIZE) 30 #define INCR_HEAPSIZE (16*1024) 25 31 26 32 //Global DLL Data … … 32 38 #pragma data_seg() 33 39 40 static int privateRefCount = 0; 41 34 42 void * _LNK_CONV getmoreShared(Heap_t pHeap, size_t *size, int *clean); 35 43 void _LNK_CONV releaseShared(Heap_t pHeap, void *block, size_t size); … … 37 45 //****************************************************************************** 38 46 //****************************************************************************** 39 BOOL InitializeSharedHeap()47 BOOL SYSTEM InitializeSharedHeap() 40 48 { 41 49 APIRET rc; 50 ULONG flAllocMem = 0, ulSysinfo; 51 52 //necessary until next WGSS update 53 if(++privateRefCount > 1) { 54 return TRUE; 55 } 56 57 rc = DosQuerySysInfo(QSV_VIRTUALADDRESSLIMIT, QSV_VIRTUALADDRESSLIMIT, &ulSysinfo, sizeof(ulSysinfo)); 58 if (rc == 0 && ulSysinfo > 512) //VirtualAddresslimit is in MB 59 { 60 flAllocMem = PAG_ANY; 61 } 42 62 43 63 if(pSharedMem == NULL) { 44 rc = DosAllocSharedMem(&pSharedMem, NULL, MAX_HEAPSIZE, PAG_READ|PAG_WRITE|OBJ_GETTABLE );64 rc = DosAllocSharedMem(&pSharedMem, NULL, MAX_HEAPSIZE, PAG_READ|PAG_WRITE|OBJ_GETTABLE|flAllocMem); 45 65 if(rc != 0) { 46 66 dprintf(("InitializeSharedHeap: DosAllocSharedMem failed with %d", rc)); 47 67 return FALSE; 48 68 } 49 69 rc = DosSetMem(pSharedMem, INCR_HEAPSIZE, PAG_READ|PAG_WRITE|PAG_COMMIT); 50 70 if(rc != 0) { 51 71 DosFreeMem(pSharedMem); 52 53 72 dprintf(("InitializeSharedHeap: DosSetMem failed with %d", rc)); 73 return FALSE; 54 74 } 55 75 sharedHeap = _ucreate(pSharedMem, INCR_HEAPSIZE, _BLOCK_CLEAN, _HEAP_REGULAR|_HEAP_SHARED, … … 58 78 if(sharedHeap == NULL) { 59 79 DosFreeMem(pSharedMem); 60 61 80 dprintf(("InitializeSharedHeap: _ucreate failed!")); 81 return FALSE; 62 82 } 63 83 dprintf(("KERNEL32: First InitializeSharedHeap %x %x", pSharedMem, sharedHeap)); … … 82 102 //****************************************************************************** 83 103 //****************************************************************************** 84 void DestroySharedHeap()104 void SYSTEM DestroySharedHeap() 85 105 { 86 106 dprintf(("KERNEL32: DestroySharedHeap %d", refCount)); 107 if(--privateRefCount > 0) { 108 return; 109 } 87 110 if(--refCount == 0) { 88 111 if(sharedHeap) { … … 132 155 { 133 156 int nrpagesfree = GetPageRangeFree(i); 134 if(nrpagesfree >= *size/PAGE_SIZE) { 157 if(nrpagesfree >= *size/PAGE_SIZE) 158 { 135 159 newblock = (PVOID)((ULONG)pSharedMem + i*PAGE_SIZE); 136 160 rc = DosSetMem(newblock, *size, PAG_READ|PAG_WRITE|PAG_COMMIT); … … 171 195 //****************************************************************************** 172 196 //****************************************************************************** 173 DWORD HeapGetSharedMemBase() 174 { 175 dprintf(("KERNEL32: HeapGetSharedMemBase()\n")); 176 return (DWORD) pSharedMem; 177 } 178 //****************************************************************************** 179 //****************************************************************************** 197 void * SYSTEM _smalloc(int size) 198 { 199 return _umalloc(sharedHeap, size); 200 } 201 //****************************************************************************** 202 //****************************************************************************** 203 void * SYSTEM _smallocfill(int size, int filler) 204 { 205 void *chunk; 206 207 chunk = _umalloc(sharedHeap, size); 208 if(chunk) { 209 memset(chunk, 0, size); 210 } 211 return chunk; 212 } 213 //****************************************************************************** 214 //****************************************************************************** -
trunk/src/kernel32/initkernel32.cpp
r8880 r8898 1 /* $Id: initkernel32.cpp,v 1.2 1 2002-07-15 14:40:16sandervl Exp $1 /* $Id: initkernel32.cpp,v 1.22 2002-07-21 09:17:28 sandervl Exp $ 2 2 * 3 3 * KERNEL32 DLL entry point … … 134 134 OpenPrivateLogFiles(); 135 135 136 if (InitializeSharedHeap() == FALSE)137 return 0UL;138 139 if (InitializeCodeHeap() == FALSE)140 return 0UL;141 142 136 //SvL: Do it here instead of during the exe object creation 143 137 //(std handles can be used in win32 dll initialization routines 144 138 HMInitialize(); /* store standard handles within HandleManager */ 145 146 InitializeMemMaps();147 148 PROFILE_LoadOdinIni();149 dllHandle = RegisterLxDll(hModule, 0, (PVOID)&kernel32_PEResTab);150 if (dllHandle == 0)151 return 0UL;152 153 //SvL: Kernel32 is a special case; pe.exe loads it, so increase154 // the reference count here155 Win32DllBase *module = Win32DllBase::findModule(dllHandle);156 if (module)157 {158 module->AddRef();159 module->DisableUnload();160 }161 139 162 140 /* knut: check for high memory support */ … … 174 152 else 175 153 flAllocMem = 0; // no high memory support 154 155 if (InitializeSharedHeap() == FALSE) 156 return 0UL; 157 158 if (InitializeCodeHeap() == FALSE) 159 return 0UL; 160 161 InitializeMemMaps(); 162 163 PROFILE_LoadOdinIni(); 164 dllHandle = RegisterLxDll(hModule, 0, (PVOID)&kernel32_PEResTab); 165 if (dllHandle == 0) 166 return 0UL; 167 168 //SvL: Kernel32 is a special case; pe.exe loads it, so increase 169 // the reference count here 170 Win32DllBase *module = Win32DllBase::findModule(dllHandle); 171 if (module) 172 { 173 module->AddRef(); 174 module->DisableUnload(); 175 } 176 176 177 177 OSLibDosSetInitialMaxFileHandles(ODIN_DEFAULT_MAX_FILEHANDLES);
Note:
See TracChangeset
for help on using the changeset viewer.