Merge pull request #1196 from EXetoC/cpp-target-fixes

C++ target fixes
This commit is contained in:
Andreas Rumpf 2014-05-24 01:41:34 +02:00
commit 912fbb9893
8 changed files with 11 additions and 10 deletions

View file

@ -484,7 +484,7 @@ proc unaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) =
opr: array[mUnaryMinusI..mAbsI64, string] = [ opr: array[mUnaryMinusI..mAbsI64, string] = [
mUnaryMinusI: "((NI$2)-($1))", mUnaryMinusI: "((NI$2)-($1))",
mUnaryMinusI64: "-($1)", mUnaryMinusI64: "-($1)",
mAbsI: "(NI$2)abs($1)", mAbsI: "($1 > 0? ($1) : -($1))",
mAbsI64: "($1 > 0? ($1) : -($1))"] mAbsI64: "($1 > 0? ($1) : -($1))"]
var var
a: TLoc a: TLoc

View file

@ -503,7 +503,8 @@ proc assignLocalVar(p: BProc, s: PSym) =
if sfRegister in s.flags: app(decl, " register") if sfRegister in s.flags: app(decl, " register")
#elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds: #elif skipTypes(s.typ, abstractInst).kind in GcTypeKinds:
# app(decl, " GC_GUARD") # app(decl, " GC_GUARD")
if sfVolatile in s.flags or p.nestedTryStmts.len > 0: if sfVolatile in s.flags or (p.nestedTryStmts.len > 0 and
gCmd != cmdCompileToCpp):
app(decl, " volatile") app(decl, " volatile")
appf(decl, " $1;$n", [s.loc.r]) appf(decl, " $1;$n", [s.loc.r])
else: else:

View file

@ -310,7 +310,7 @@ proc mainCommand* =
of "cpp", "compiletocpp": of "cpp", "compiletocpp":
extccomp.cExt = ".cpp" extccomp.cExt = ".cpp"
gCmd = cmdCompileToCpp gCmd = cmdCompileToCpp
if cCompiler == ccGcc: setCC("gpp") if cCompiler == ccGcc: setCC("gcc")
wantMainModule() wantMainModule()
defineSymbol("cpp") defineSymbol("cpp")
commandCompileToC() commandCompileToC()

View file

@ -10,7 +10,7 @@
## Serialization utilities for the compiler. ## Serialization utilities for the compiler.
import strutils import strutils
proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", nodecl, varargs.} proc c_sprintf(buf, frmt: cstring) {.importc: "sprintf", header: "<stdio.h>", nodecl, varargs.}
proc toStrMaxPrecision*(f: BiggestFloat): string = proc toStrMaxPrecision*(f: BiggestFloat): string =
if f != f: if f != f:

View file

@ -152,7 +152,7 @@ proc boot(args: string) =
copyExe(findStartNimrod(), 0.thVersion) copyExe(findStartNimrod(), 0.thVersion)
for i in 0..2: for i in 0..2:
echo "iteration: ", i+1 echo "iteration: ", i+1
exec i.thVersion & " cc $# $# compiler" / "nimrod.nim" % [bootOptions, args] exec i.thVersion & " c $# $# compiler" / "nimrod.nim" % [bootOptions, args]
if sameFileContent(output, i.thVersion): if sameFileContent(output, i.thVersion):
copyExe(output, finalDest) copyExe(output, finalDest)
echo "executables are equal: SUCCESS!" echo "executables are equal: SUCCESS!"

View file

@ -62,9 +62,9 @@ var
proc genOid*(): TOid = proc genOid*(): TOid =
## generates a new OID. ## generates a new OID.
proc rand(): cint {.importc: "rand", nodecl.} proc rand(): cint {.importc: "rand", header: "<stdlib.h>", nodecl.}
proc gettime(dummy: ptr cint): cint {.importc: "time", header: "<time.h>".} proc gettime(dummy: ptr cint): cint {.importc: "time", header: "<time.h>".}
proc srand(seed: cint) {.importc: "srand", nodecl.} proc srand(seed: cint) {.importc: "srand", header: "<stdlib.h>", nodecl.}
var t = gettime(nil) var t = gettime(nil)

View file

@ -903,7 +903,7 @@ elif not defined(useNimRtl):
createStream(p.errStream, p.errHandle, fmRead) createStream(p.errStream, p.errHandle, fmRead)
return p.errStream return p.errStream
proc csystem(cmd: cstring): cint {.nodecl, importc: "system".} proc csystem(cmd: cstring): cint {.nodecl, importc: "system", header: "<stdlib.h>".}
proc execCmd(command: string): int = proc execCmd(command: string): int =
when defined(linux): when defined(linux):

View file

@ -10,7 +10,7 @@
# set handling # set handling
type type
TNimSet = array [0..4*2048-1, int8] TNimSet = array [0..4*2048-1, uint8]
proc countBits32(n: int32): int {.compilerproc.} = proc countBits32(n: int32): int {.compilerproc.} =
var v = n var v = n
@ -25,4 +25,4 @@ proc countBits64(n: int64): int {.compilerproc.} =
proc cardSet(s: TNimSet, len: int): int {.compilerproc.} = proc cardSet(s: TNimSet, len: int): int {.compilerproc.} =
result = 0 result = 0
for i in countup(0, len-1): for i in countup(0, len-1):
inc(result, countBits32(int32(ze(s[i])))) inc(result, countBits32(int32(s[i])))