diff options
author | Andreas Rumpf <andreas@andreas-laptop> | 2010-07-22 19:18:26 +0200 |
---|---|---|
committer | Andreas Rumpf <andreas@andreas-laptop> | 2010-07-22 19:18:26 +0200 |
commit | be878a599333f2d98b8e95b956d17f5e0d37d8b0 (patch) | |
tree | 96bd73e2313bb5a916598951b5710fff171769ea /lib/system | |
parent | 2b212851441d58d4dd5beb53c1572b652dc04929 (diff) | |
download | Nim-be878a599333f2d98b8e95b956d17f5e0d37d8b0.tar.gz |
c2nim: better parsing of #ifdef C2NIM; #def support
Diffstat (limited to 'lib/system')
-rwxr-xr-x | lib/system/mmdisp.nim | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/lib/system/mmdisp.nim b/lib/system/mmdisp.nim index c89e7dffa..44b3f7326 100755 --- a/lib/system/mmdisp.nim +++ b/lib/system/mmdisp.nim @@ -1,7 +1,7 @@ # # # Nimrod's Runtime Library -# (c) Copyright 2009 Andreas Rumpf +# (c) Copyright 2010 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -187,6 +187,60 @@ elif defined(nogc): dest^ = src include "system/cellsets" +elif appType == "lib": + {.warning: "gc in a library context may not work".} + when hostOS == "windows": + const nimrtl = "nimrtl.dll" + elif hostOS == "macosx": + const nimrtl = "nimrtl.dynlib" + else: + const nimrtl = "libnimrtl.so" + + when not defined(includeGC): + # ordinary client; use the GC from nimrtl.dll: + proc initGC() {.cdecl, importc, dynlib: nimrtl.} + proc GC_disable() {.cdecl, importc, dynlib: nimrtl.} + proc GC_enable() {.cdecl, importc, dynlib: nimrtl.} + proc GC_fullCollect() {.cdecl, importc, dynlib: nimrtl.} + proc GC_setStrategy(strategy: TGC_Strategy) {. + cdecl, importc, dynlib: nimrtl.} + proc GC_enableMarkAndSweep() {.cdecl, importc, dynlib: nimrtl.} + proc GC_disableMarkAndSweep() {.cdecl, importc, dynlib: nimrtl.} + proc GC_getStatistics(): string {.cdecl, importc, dynlib: nimrtl.} + + proc newObj(typ: PNimType, size: int): pointer {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + proc newSeq(typ: PNimType, len: int): pointer {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + proc growObj(old: pointer, newsize: int): pointer {. + cdecl, importc, dynlib: nimrtl.} + + proc setStackBottom(theStackBottom: pointer) {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + proc nimGCref(p: pointer) {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + proc nimGCunref(p: pointer) {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + + # The write barrier is performance critical! + # XXX We should ensure that they are inlined here. + # Later implementations will do this. + + proc unsureAsgnRef(dest: ppointer, src: pointer) {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + proc asgnRef(dest: ppointer, src: pointer) {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + proc asgnRefNoCycle(dest: ppointer, src: pointer) {. + compilerproc, cdecl, importc, dynlib: nimrtl.} + + else: + # include the GC and export it! + include "system/alloc" + include "system/cellsets" + assert(sizeof(TCell) == sizeof(TFreeCell)) + include "system/gc" + + include "system/cellsets" else: include "system/alloc" include "system/cellsets" @@ -195,4 +249,3 @@ else: {.pop.} - |