DLLs should work again; fixes #169

This commit is contained in:
Araq
2012-07-24 01:14:21 +02:00
parent 34efc2cdf9
commit ed915a309e
12 changed files with 29 additions and 410 deletions

View File

@@ -179,9 +179,10 @@ var
{.push stack_trace: off.}
proc initAllocator() =
bottom = addr(bottomData)
bottom.link[0] = bottom
bottom.link[1] = bottom
when not defined(useNimRtl):
bottom = addr(bottomData)
bottom.link[0] = bottom
bottom.link[1] = bottom
{.pop.}
proc incCurrMem(a: var TMemRegion, bytes: int) {.inline.} =

View File

@@ -536,7 +536,7 @@ proc doOperation(p: pointer, op: TWalkOp) =
sysAssert(c.refcount >=% rcIncrement, "doOperation 3")
c.refcount = c.refcount -% rcIncrement
proc nimGCvisit(d: pointer, op: int) {.compilerProc.} =
proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} =
doOperation(d, TWalkOp(op))
# we now use a much simpler and non-recursive algorithm for cycle removal

View File

@@ -228,6 +228,7 @@ proc ReadBytes(f: TFile, a: var openarray[int8], start, len: int): int =
proc ReadChars(f: TFile, a: var openarray[char], start, len: int): int =
result = readBuffer(f, addr(a[start]), len)
{.push stackTrace:off.}
proc writeBytes(f: TFile, a: openarray[int8], start, len: int): int =
var x = cast[ptr array[0..1000_000_000, int8]](a)
result = writeBuffer(f, addr(x[start]), len)
@@ -240,6 +241,7 @@ proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
proc write(f: TFile, s: string) =
if writeBuffer(f, cstring(s), s.len) != s.len:
raiseEIO("cannot write string to file")
{.pop.}
proc setFilePos(f: TFile, pos: int64) =
if fseek(f, clong(pos), 0) != 0:

View File

@@ -69,10 +69,10 @@ proc toNimStr(str: CString, len: int): NimString {.compilerProc.} =
c_memcpy(result.data, str, (len+1) * sizeof(Char))
#result.data[len] = '\0' # readline relies on this!
proc cstrToNimstr(str: CString): NimString {.compilerProc.} =
proc cstrToNimstr(str: CString): NimString {.compilerRtl.} =
result = toNimstr(str, c_strlen(str))
proc copyString(src: NimString): NimString {.compilerProc.} =
proc copyString(src: NimString): NimString {.compilerRtl.} =
if (src.reserved and seqShallowFlag) != 0:
result = src
elif src != nil:
@@ -80,7 +80,7 @@ proc copyString(src: NimString): NimString {.compilerProc.} =
result.len = src.len
c_memcpy(result.data, src.data, (src.len + 1) * sizeof(Char))
proc copyStringRC1(src: NimString): NimString {.compilerProc.} =
proc copyStringRC1(src: NimString): NimString {.compilerRtl.} =
if src != nil:
var s = src.space
if s < 8: s = 7
@@ -148,7 +148,7 @@ proc addChar(s: NimString, c: char): NimString =
# <generated C code>
# s = rawNewString(0);
proc resizeString(dest: NimString, addlen: int): NimString {.compilerproc.} =
proc resizeString(dest: NimString, addlen: int): NimString {.compilerRtl.} =
if dest.len + addLen <= dest.space:
result = dest
else: # slow path:
@@ -168,7 +168,7 @@ proc appendChar(dest: NimString, c: char) {.compilerproc, inline.} =
dest.data[dest.len+1] = '\0'
inc(dest.len)
proc setLengthStr(s: NimString, newLen: int): NimString {.compilerProc.} =
proc setLengthStr(s: NimString, newLen: int): NimString {.compilerRtl.} =
var n = max(newLen, 0)
if n <= s.space:
result = s
@@ -254,10 +254,10 @@ proc nimInt64ToStr(x: int64): string {.compilerRtl.} =
for j in 0..i div 2 - 1:
swap(result[j], result[i-j-1])
proc nimBoolToStr(x: bool): string {.compilerproc.} =
proc nimBoolToStr(x: bool): string {.compilerRtl.} =
return if x: "true" else: "false"
proc nimCharToStr(x: char): string {.compilerproc.} =
proc nimCharToStr(x: char): string {.compilerRtl.} =
result = newString(1)
result[0] = x