#include <windows.h>
#endif
#if darwin_HOST_OS
+#include <mach/mach.h>
#include <mach/vm_map.h>
#endif
lnat mblocks_allocated = 0;
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS)
+static caddr_t next_request = 0;
+#endif
+
+void
+initMBlocks(void)
+{
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS)
+ next_request = (caddr_t)RtsFlags.GcFlags.heapBase;
+#endif
+}
+
/* -----------------------------------------------------------------------------
The MBlock Map: provides our implementation of HEAP_ALLOCED()
-------------------------------------------------------------------------- */
errorBelch("memory allocation failed (requested %lu bytes)", size);
stg_exit(EXIT_FAILURE);
} else {
- vm_protect(mach_task_self(),ret,size,FALSE,VM_PROT_READ|VM_PROT_WRITE);
+ vm_protect(mach_task_self(),(vm_address_t)ret,size,FALSE,VM_PROT_READ|VM_PROT_WRITE);
}
#else
ret = mmap(addr, size, PROT_READ | PROT_WRITE | PROT_EXEC,
void *
getMBlocks(nat n)
{
- static caddr_t next_request = (caddr_t)HEAP_BASE;
caddr_t ret;
lnat size = MBLOCK_SIZE * n;
nat i;
if(rec->base==0) {
stgFree((void*)rec);
rec=0;
- sysErrorBelch(
- "getMBlocks: VirtualAlloc MEM_RESERVE %d blocks failed", n);
+ if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) {
+
+ errorBelch("out of memory");
+ } else {
+ sysErrorBelch(
+ "getMBlocks: VirtualAlloc MEM_RESERVE %d blocks failed", n);
+ }
} else {
alloc_rec temp;
temp.base=0; temp.size=0; temp.next=allocs;