summary refs log tree commit diff stats
path: root/compiler/cgen.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/cgen.nim')
-rwxr-xr-xcompiler/cgen.nim22
1 files changed, 16 insertions, 6 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim
index 7f162b6e6..c89942be4 100755
--- a/compiler/cgen.nim
+++ b/compiler/cgen.nim
@@ -431,9 +431,18 @@ proc assignLocalVar(p: BProc, s: PSym) =
 
 proc declareThreadVar(m: BModule, s: PSym) =
   if optThreads in gGlobalOptions:
-    app(m.s[cfsVars], "NIM_THREADVAR ")
-  app(m.s[cfsVars], getTypeDesc(m, s.loc.t))
-  
+    if platform.OS[targetOS].props.contains(ospLacksThreadVars):
+      # we gather all thread locals var into a struct and put that into
+      # nim__dat.c; we need to allocate storage for that somehow, can't use
+      # the thread local storage allocator for it :-(
+      # XXX we need to adapt expr() too, every reference to a thread local var
+      # generates quite some code ...
+      InternalError("no workaround for lack of thread local vars implemented")
+    else:
+      app(m.s[cfsVars], "NIM_THREADVAR ")
+      app(m.s[cfsVars], getTypeDesc(m, s.loc.t))
+  else:
+    app(m.s[cfsVars], getTypeDesc(m, s.loc.t))
 
 proc assignGlobalVar(p: BProc, s: PSym) = 
   if s.loc.k == locNone: 
@@ -640,8 +649,8 @@ proc genProcAux(m: BModule, prc: PSym) =
     assignParam(p, param)
   genStmts(p, prc.ast.sons[codePos]) # modifies p.locals, p.init, etc.
   if sfPure in prc.flags: 
-    generatedProc = ropeff("$1 {$n$2$3$4}$n", "define $1 {$n$2$3$4}$n", [header, 
-        p.s[cpsLocals], p.s[cpsInit], p.s[cpsStmts]])
+    generatedProc = ropeff("$1 {$n$2$3$4}$n", "define $1 {$n$2$3$4}$n",
+        [header, p.s[cpsLocals], p.s[cpsInit], p.s[cpsStmts]])
   else: 
     generatedProc = ropeff("$1 {$n", "define $1 {$n", [header])
     if optStackTrace in prc.options: 
@@ -756,7 +765,8 @@ proc getFileHeader(cfilenoext: string): PRope =
         ";   (c) 2011 Andreas Rumpf$n", [toRope(versionAsString)])
   else: 
     result = ropeff("/* Generated by Nimrod Compiler v$1 */$n" &
-        "/*   (c) 2011 Andreas Rumpf */$n" & "/* Compiled for: $2, $3, $4 */$n" &
+        "/*   (c) 2011 Andreas Rumpf */$n" & 
+        "/* Compiled for: $2, $3, $4 */$n" &
         "/* Command for C compiler:$n   $5 */$n", 
         "; Generated by Nimrod Compiler v$1$n" &
         ";   (c) 2011 Andreas Rumpf$n" & "; Compiled for: $2, $3, $4$n" &