put the @N suffix on stdcall foreign calls in .cmm code
[ghc-hetmet.git] / rts / sm / MBlock.c
index 85fe02d..54d4148 100644 (file)
 
 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()
    -------------------------------------------------------------------------- */
@@ -258,7 +270,6 @@ gen_map_mblocks (lnat size)
 void *
 getMBlocks(nat n)
 {
-  static caddr_t next_request = (caddr_t)HEAP_BASE;
   caddr_t ret;
   lnat size = MBLOCK_SIZE * n;
   nat i;
@@ -337,8 +348,13 @@ allocNew(nat n) {
     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;