diff options
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/ccgexprs.nim | 4 | ||||
-rwxr-xr-x | compiler/cgen.nim | 22 | ||||
-rwxr-xr-x | compiler/platform.nim | 5 |
3 files changed, 21 insertions, 10 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index dc17a39c7..d02c20559 100755 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1105,8 +1105,8 @@ proc rdSetElemLoc(a: TLoc, setType: PType): PRope = # before the set operation result = rdCharLoc(a) assert(setType.kind == tySet) - if (firstOrd(setType) != 0): - result = ropef("($1-$2)", [result, toRope(firstOrd(setType))]) + if firstOrd(setType) != 0: + result = ropef("($1- $2)", [result, toRope(firstOrd(setType))]) proc fewCmps(s: PNode): bool = # this function estimates whether it is better to emit code 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" & diff --git a/compiler/platform.nim b/compiler/platform.nim index 422cc6134..e5bf75c13 100755 --- a/compiler/platform.nim +++ b/compiler/platform.nim @@ -27,7 +27,8 @@ type TInfoOSProp* = enum ospNeedsPIC, # OS needs PIC for libraries ospCaseInsensitive, # OS filesystem is case insensitive - ospPosix # OS is posix-like + ospPosix, # OS is posix-like + ospLacksThreadVars # OS lacks proper __threadvar support TInfoOSProps* = set[TInfoOSProp] TInfoOS* = tuple[name: string, parDir: string, dllFrmt: string, altDirSep: string, objExt: string, newLine: string, @@ -129,7 +130,7 @@ const (name: "MacOSX", parDir: "..", dllFrmt: "lib$1.dylib", altDirSep: ":", objExt: ".o", newLine: "\x0A", pathSep: ":", dirSep: "/", scriptExt: ".sh", curDir: ".", exeExt: "", extSep: ".", - props: {ospNeedsPIC, ospPosix}), + props: {ospNeedsPIC, ospPosix, ospLacksThreadVars}), (name: "EcmaScript", parDir: "..", dllFrmt: "lib$1.so", altDirSep: "/", objExt: ".o", newLine: "\x0A", |