diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-05-25 12:04:27 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-05-25 12:04:27 +0200 |
commit | 2bc6acd0ed962ca29b88e79bbf1e9147b2dd0a30 (patch) | |
tree | d689448390be0ce404012d610c2e0bd7a06a3bc0 /lib | |
parent | ad70fb4ffeb91f1cb847705f41ffaf3c2aefb67c (diff) | |
download | Nim-2bc6acd0ed962ca29b88e79bbf1e9147b2dd0a30.tar.gz |
gc:stack compiles with --threads:on
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/gc_stack.nim | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/system/gc_stack.nim b/lib/system/gc_stack.nim index 37d19db89..e30d0a720 100644 --- a/lib/system/gc_stack.nim +++ b/lib/system/gc_stack.nim @@ -11,8 +11,8 @@ when defined(nimphpext): proc roundup(x, v: int): int {.inline.} = result = (x + (v-1)) and not (v-1) - proc emalloc(size: int): pointer {.importc:"_emalloc".} - proc efree(mem: pointer) {.importc:"_efree".} + proc emalloc(size: int): pointer {.importc: "_emalloc".} + proc efree(mem: pointer) {.importc: "_efree".} proc osAllocPages(size: int): pointer {.inline.} = emalloc(size) @@ -144,11 +144,12 @@ proc runFinalizers(c: Chunk) = (cast[Finalizer](it.typ.finalizer))(it+!sizeof(ObjHeader)) it = it.nextFinal -proc dealloc(r: var MemRegion; p: pointer) = - let it = cast[ptr ObjHeader](p-!sizeof(ObjHeader)) - if it.typ != nil and it.typ.finalizer != nil: - (cast[Finalizer](it.typ.finalizer))(p) - it.typ = nil +when false: + proc dealloc(r: var MemRegion; p: pointer) = + let it = cast[ptr ObjHeader](p-!sizeof(ObjHeader)) + if it.typ != nil and it.typ.finalizer != nil: + (cast[Finalizer](it.typ.finalizer))(p) + it.typ = nil proc deallocAll(r: var MemRegion; head: Chunk) = var it = head @@ -187,6 +188,8 @@ proc obstackPtr*(): StackPtr = tlRegion.obstackPtr() proc setObstackPtr*(sp: StackPtr) = tlRegion.setObstackPtr(sp) proc deallocAll*() = tlRegion.deallocAll() +proc deallocOsPages(r: var MemRegion) = r.deallocAll() + proc joinRegion*(dest: var MemRegion; src: MemRegion) = # merging is not hard. if dest.head.isNil: @@ -424,6 +427,13 @@ proc realloc(p: pointer, newsize: Natural): pointer = if result == nil: raiseOutOfMem() proc dealloc(p: pointer) = cfree(p) +proc alloc0(r: var MemRegion; size: Natural): pointer = + # ignore the region. That is correct for the channels module + # but incorrect in general. XXX + result = alloc0(size) + +proc dealloc(r: var MemRegion; p: pointer) = dealloc(p) + proc allocShared(size: Natural): pointer = result = cmalloc(size) if result == nil: raiseOutOfMem() |