summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-06-02 13:02:40 +0200
committerAraq <rumpf_a@web.de>2011-06-02 13:02:40 +0200
commit3260702a6044cdae89cf673ad1983aa3342127de (patch)
tree40439bfaf9f4ecb4929547e387998b282eee408c /lib/system.nim
parentd0bfc3665fd0131dad516d2fcd7cfe73c3a6f122 (diff)
downloadNim-3260702a6044cdae89cf673ad1983aa3342127de.tar.gz
first steps to thread local heaps
Diffstat (limited to 'lib/system.nim')
-rwxr-xr-xlib/system.nim30
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!
1' href='#n21'>21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68