summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-03-31 01:03:14 +0200
committerAraq <rumpf_a@web.de>2012-03-31 01:03:14 +0200
commit142e849b91cb39976ec2ca78e0c7a998288a367a (patch)
treea69f6871ae430bb0c5314fcf812b5ce28b665cbc /lib/system
parent97743faa837b4e7ec4db0af59d7aafd5d09deee7 (diff)
downloadNim-142e849b91cb39976ec2ca78e0c7a998288a367a.tar.gz
implemented support for the AVR CPU and standalone OS
Diffstat (limited to 'lib/system')
-rwxr-xr-xlib/system/excpt.nim2
-rwxr-xr-xlib/system/mmdisp.nim72
-rwxr-xr-xlib/system/repr.nim2
3 files changed, 75 insertions, 1 deletions
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 8ffca90fb..2df7fe4ad 100755
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -27,7 +27,7 @@ else:
   proc writeToStdErr(msg: CString) =
     discard MessageBoxA(0, msg, nil, 0)
 
-proc registerSignalHandler() {.compilerproc.}
+proc registerSignalHandler()
 
 proc chckIndx(i, a, b: int): int {.inline, compilerproc.}
 proc chckRange(i, a, b: int): int {.inline, compilerproc.}
diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim
index e8ad23970..1abf3fbbf 100755
--- a/lib/system/mmdisp.nim
+++ b/lib/system/mmdisp.nim
@@ -181,6 +181,78 @@ when defined(boehmgc):
   proc deallocOsPages() {.inline.} = nil
 
   include "system/cellsets"
+elif defined(nogc) and defined(useMalloc):
+  
+  when not defined(useNimRtl):
+    proc alloc(size: int): pointer =
+      result = cmalloc(size)
+      if result == nil: raiseOutOfMem()
+    proc alloc0(size: int): pointer =
+      result = alloc(size)
+      zeroMem(result, size)
+    proc realloc(p: Pointer, newsize: int): pointer =
+      result = crealloc(p, newsize)
+      if result == nil: raiseOutOfMem()
+    proc dealloc(p: Pointer) = cfree(p)
+    
+    proc allocShared(size: int): pointer =
+      result = cmalloc(size)
+      if result == nil: raiseOutOfMem()
+    proc allocShared0(size: int): pointer =
+      result = alloc(size)
+      zeroMem(result, size)
+    proc reallocShared(p: Pointer, newsize: int): pointer =
+      result = crealloc(p, newsize)
+      if result == nil: raiseOutOfMem()
+    proc deallocShared(p: Pointer) = cfree(p)
+
+    proc GC_disable() = nil
+    proc GC_enable() = nil
+    proc GC_fullCollect() = nil
+    proc GC_setStrategy(strategy: TGC_Strategy) = nil
+    proc GC_enableMarkAndSweep() = nil
+    proc GC_disableMarkAndSweep() = nil
+    proc GC_getStatistics(): string = return ""
+    
+    proc getOccupiedMem(): int = nil
+    proc getFreeMem(): int = nil
+    proc getTotalMem(): int = nil
+    
+    proc setStackBottom(theStackBottom: pointer) = nil
+
+  proc initGC() = nil
+
+  proc newObj(typ: PNimType, size: int): pointer {.compilerproc.} =
+    result = alloc(size)
+  proc newSeq(typ: PNimType, len: int): pointer {.compilerproc.} =
+    result = newObj(typ, addInt(mulInt(len, typ.base.size), GenericSeqSize))
+    cast[PGenericSeq](result).len = len
+    cast[PGenericSeq](result).reserved = len
+
+  proc growObj(old: pointer, newsize: int): pointer =
+    result = realloc(old, newsize)
+
+  proc nimGCref(p: pointer) {.compilerproc, inline.} = nil
+  proc nimGCunref(p: pointer) {.compilerproc, inline.} = nil
+  
+  proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
+    dest[] = src
+  proc asgnRef(dest: ppointer, src: pointer) {.compilerproc, inline.} =
+    dest[] = src
+  proc asgnRefNoCycle(dest: ppointer, src: pointer) {.compilerproc, inline.} =
+    dest[] = src
+
+  type
+    TMemRegion = object {.final, pure.}
+  
+  proc Alloc(r: var TMemRegion, size: int): pointer =
+    result = alloc(size)
+  proc Alloc0(r: var TMemRegion, size: int): pointer =
+    result = alloc0(size)
+  proc Dealloc(r: var TMemRegion, p: Pointer) = Dealloc(p)
+  proc deallocOsPages(r: var TMemRegion) {.inline.} = nil
+  proc deallocOsPages() {.inline.} = nil
+
 elif defined(nogc):
   # Even though we don't want the GC, we cannot simply use C's memory manager
   # because Nimrod's runtime wants ``realloc`` to zero out the additional
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index 2dec8136c..43ac0088f 100755
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -9,6 +9,8 @@
 
 # The generic ``repr`` procedure. It is an invaluable debugging tool.
 
+proc reprAny(p: pointer, typ: PNimType): string {.compilerRtl.}
+
 proc reprInt(x: int64): string {.compilerproc.} = return $x
 proc reprFloat(x: float): string {.compilerproc.} = return $x