diff options
author | Araq <rumpf_a@web.de> | 2011-06-02 13:02:40 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-06-02 13:02:40 +0200 |
commit | 3260702a6044cdae89cf673ad1983aa3342127de (patch) | |
tree | 40439bfaf9f4ecb4929547e387998b282eee408c /lib/system.nim | |
parent | d0bfc3665fd0131dad516d2fcd7cfe73c3a6f122 (diff) | |
download | Nim-3260702a6044cdae89cf673ad1983aa3342127de.tar.gz |
first steps to thread local heaps
Diffstat (limited to 'lib/system.nim')
-rwxr-xr-x | lib/system.nim | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/system.nim b/lib/system.nim index 9a9e4fb06..ef9685574 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -778,6 +778,12 @@ proc compileOption*(option, arg: string): bool {. const hasThreadSupport = compileOption("threads") + hasSharedHeap = false # don't share heaps, so every thread has its own heap + +when hasThreadSupport and not hasSharedHeap: + {.pragma: rtlThreadVar, threadvar.} +else: + {.pragma: rtlThreadVar.} include "system/inclrtl" @@ -1448,12 +1454,6 @@ proc quit*(errorcode: int = QuitSuccess) {. when not defined(EcmaScript) and not defined(NimrodVM): {.push stack_trace: off.} - proc atomicInc*(memLoc: var int, x: int): int {.inline.} - ## atomic increment of `memLoc`. Returns the value after the operation. - - proc atomicDec*(memLoc: var int, x: int): int {.inline.} - ## atomic decrement of `memLoc`. Returns the value after the operation. - proc initGC() proc initStackBottom() {.inline.} = @@ -1666,7 +1666,23 @@ when not defined(EcmaScript) and not defined(NimrodVM): # ---------------------------------------------------------------------------- - include "system/systhread" + proc atomicInc*(memLoc: var int, x: int): int {.inline.} + ## atomic increment of `memLoc`. Returns the value after the operation. + + proc atomicDec*(memLoc: var int, x: int): int {.inline.} + ## atomic decrement of `memLoc`. Returns the value after the operation. + + include "system/atomics" + + type + PSafePoint = ptr TSafePoint + TSafePoint {.compilerproc, final.} = object + prev: PSafePoint # points to next safe point ON THE STACK + status: int + context: C_JmpBuf + + when hasThreadSupport: + include "system/threads" include "system/excpt" # we cannot compile this with stack tracing on # as it would recurse endlessly! |