summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-01-09 11:48:37 +0100
committerGitHub <noreply@github.com>2020-01-09 11:48:37 +0100
commit852170cc786b09e17b6bfd09bdb2ac9184b359d1 (patch)
tree5a94b3ab4b91fcf519db181e06f5e550c68120d8 /lib/system
parent27fee4d8b4b47635e7d96a7a857906e6ecb98565 (diff)
downloadNim-852170cc786b09e17b6bfd09bdb2ac9184b359d1.tar.gz
take the one good idea from --os:standalone and enable it via -d:StandaloneHeapSize (#13077)
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/mmdisp.nim2
-rw-r--r--lib/system/osalloc.nim14
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim
index 60f8f7db6..8bc8fe28a 100644
--- a/lib/system/mmdisp.nim
+++ b/lib/system/mmdisp.nim
@@ -62,7 +62,7 @@ const
 
 proc raiseOutOfMem() {.noinline.} =
   if outOfMemHook != nil: outOfMemHook()
-  cstderr.rawWrite("out of memory")
+  cstderr.rawWrite("out of memory\n")
   quit(1)
 
 when defined(boehmgc):
diff --git a/lib/system/osalloc.nim b/lib/system/osalloc.nim
index b7e3e7183..85c32e676 100644
--- a/lib/system/osalloc.nim
+++ b/lib/system/osalloc.nim
@@ -28,7 +28,7 @@ const doNotUnmap = not (defined(amd64) or defined(i386)) or
                    defined(windows) or defined(nimAllocNoUnmap)
 
 
-when defined(emscripten):
+when defined(emscripten) and not defined(StandaloneHeapSize):
   const
     PROT_READ  = 1             # page can be read
     PROT_WRITE = 2             # page can be written
@@ -77,10 +77,10 @@ when defined(emscripten):
     var mmapDescr = cast[EmscriptenMMapBlock](mmapDescrPos)
     munmap(mmapDescr.realPointer, mmapDescr.realSize)
 
-elif defined(genode):
+elif defined(genode) and not defined(StandaloneHeapSize):
   include genode/alloc # osAllocPages, osTryAllocPages, osDeallocPages
 
-elif defined(nintendoswitch):
+elif defined(nintendoswitch) and not defined(StandaloneHeapSize):
 
   import nintendoswitch/switch_memory
 
@@ -191,7 +191,7 @@ elif defined(nintendoswitch):
     when reallyOsDealloc:
       freeMem(p)
 
-elif defined(posix):
+elif defined(posix) and not defined(StandaloneHeapSize):
   const
     PROT_READ  = 1             # page can be read
     PROT_WRITE = 2             # page can be written
@@ -234,7 +234,7 @@ elif defined(posix):
   proc osDeallocPages(p: pointer, size: int) {.inline.} =
     when reallyOsDealloc: discard munmap(p, cast[csize_t](size))
 
-elif defined(windows):
+elif defined(windows) and not defined(StandaloneHeapSize):
   const
     MEM_RESERVE = 0x2000
     MEM_COMMIT = 0x1000
@@ -274,10 +274,10 @@ elif defined(windows):
         quit 1
     #VirtualFree(p, size, MEM_DECOMMIT)
 
-elif hostOS == "standalone":
+elif hostOS == "standalone" or defined(StandaloneHeapSize):
   const StandaloneHeapSize {.intdefine.}: int = 1024 * PageSize
   var
-    theHeap: array[StandaloneHeapSize, float64] # 'float64' for alignment
+    theHeap: array[StandaloneHeapSize div sizeof(float64), float64] # 'float64' for alignment
     bumpPointer = cast[int](addr theHeap)
 
   proc osAllocPages(size: int): pointer {.inline.} =