diff options
Diffstat (limited to 'lib/system')
-rwxr-xr-x | lib/system/alloc.nim | 7 | ||||
-rwxr-xr-x | lib/system/ecmasys.nim | 50 | ||||
-rwxr-xr-x | lib/system/gc.nim | 4 | ||||
-rwxr-xr-x | lib/system/hti.nim | 2 | ||||
-rwxr-xr-x | lib/system/sysio.nim | 2 | ||||
-rwxr-xr-x | lib/system/sysstr.nim | 14 | ||||
-rwxr-xr-x | lib/system/threads.nim | 8 |
7 files changed, 45 insertions, 42 deletions
diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index ba172373d..53c20316c 100755 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -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.} = diff --git a/lib/system/ecmasys.nim b/lib/system/ecmasys.nim index 8f4585931..0c9db2206 100755 --- a/lib/system/ecmasys.nim +++ b/lib/system/ecmasys.nim @@ -247,14 +247,14 @@ proc eqStrings(a, b: string): bool {.noStackFrame, compilerProc.} = type TDocument {.importc.} = object of TObject - write: proc (text: cstring) - writeln: proc (text: cstring) - createAttribute: proc (identifier: cstring): ref TNode - createElement: proc (identifier: cstring): ref TNode - createTextNode: proc (identifier: cstring): ref TNode - getElementById: proc (id: cstring): ref TNode - getElementsByName: proc (name: cstring): seq[ref TNode] - getElementsByTagName: proc (name: cstring): seq[ref TNode] + write: proc (text: cstring) {.nimcall.} + writeln: proc (text: cstring) {.nimcall.} + createAttribute: proc (identifier: cstring): ref TNode {.nimcall.} + createElement: proc (identifier: cstring): ref TNode {.nimcall.} + createTextNode: proc (identifier: cstring): ref TNode {.nimcall.} + getElementById: proc (id: cstring): ref TNode {.nimcall.} + getElementsByName: proc (name: cstring): seq[ref TNode] {.nimcall.} + getElementsByTagName: proc (name: cstring): seq[ref TNode] {.nimcall.} TNodeType* = enum ElementNode = 1, @@ -281,23 +281,23 @@ type nodeValue*: cstring parentNode*: ref TNode previousSibling*: ref TNode - appendChild*: proc (child: ref TNode) - appendData*: proc (data: cstring) - cloneNode*: proc (copyContent: bool) - deleteData*: proc (start, len: int) - getAttribute*: proc (attr: cstring): cstring - getAttributeNode*: proc (attr: cstring): ref TNode - getElementsByTagName*: proc (): seq[ref TNode] - hasChildNodes*: proc (): bool - insertBefore*: proc (newNode, before: ref TNode) - insertData*: proc (position: int, data: cstring) - removeAttribute*: proc (attr: cstring) - removeAttributeNode*: proc (attr: ref TNode) - removeChild*: proc (child: ref TNode) - replaceChild*: proc (newNode, oldNode: ref TNode) - replaceData*: proc (start, len: int, text: cstring) - setAttribute*: proc (name, value: cstring) - setAttributeNode*: proc (attr: ref TNode) + appendChild*: proc (child: ref TNode) {.nimcall.} + appendData*: proc (data: cstring) {.nimcall.} + cloneNode*: proc (copyContent: bool) {.nimcall.} + deleteData*: proc (start, len: int) {.nimcall.} + getAttribute*: proc (attr: cstring): cstring {.nimcall.} + getAttributeNode*: proc (attr: cstring): ref TNode {.nimcall.} + getElementsByTagName*: proc (): seq[ref TNode] {.nimcall.} + hasChildNodes*: proc (): bool {.nimcall.} + insertBefore*: proc (newNode, before: ref TNode) {.nimcall.} + insertData*: proc (position: int, data: cstring) {.nimcall.} + removeAttribute*: proc (attr: cstring) {.nimcall.} + removeAttributeNode*: proc (attr: ref TNode) {.nimcall.} + removeChild*: proc (child: ref TNode) {.nimcall.} + replaceChild*: proc (newNode, oldNode: ref TNode) {.nimcall.} + replaceData*: proc (start, len: int, text: cstring) {.nimcall.} + setAttribute*: proc (name, value: cstring) {.nimcall.} + setAttributeNode*: proc (attr: ref TNode) {.nimcall.} when defined(nodejs): proc ewriteln(x: cstring) = log(x) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 1c6caeb77..470064c5f 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -45,7 +45,7 @@ type TWalkOp = enum waZctDecRef, waPush, waCycleDecRef - TFinalizer {.compilerproc.} = proc (self: pointer) + TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall.} # A ref type can have a finalizer that is called before the object's # storage is freed. @@ -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 diff --git a/lib/system/hti.nim b/lib/system/hti.nim index d79679107..93dc79e3d 100755 --- a/lib/system/hti.nim +++ b/lib/system/hti.nim @@ -62,7 +62,7 @@ type # This should be he same as ast.TTypeKind base: ptr TNimType node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum finalizer: pointer # the finalizer for the type - marker: proc (p: pointer, op: int) # marker proc for GC + marker: proc (p: pointer, op: int) {.nimcall.} # marker proc for GC PNimType = ptr TNimType # node.len may be the ``first`` element of a set diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index d5234e62f..012e5d95a 100755 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -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: diff --git a/lib/system/sysstr.nim b/lib/system/sysstr.nim index c61cf2bea..5d2113439 100755 --- a/lib/system/sysstr.nim +++ b/lib/system/sysstr.nim @@ -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 diff --git a/lib/system/threads.nim b/lib/system/threads.nim index e0812f41c..6b1fd2178 100755 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -203,7 +203,6 @@ when not defined(useNimRtl): when not useStackMaskHack: var mainThread: TGcThread ThreadVarSetValue(globalsSlot, addr(mainThread)) - initStackBottom() initGC() when emulatedThreadVars: @@ -255,9 +254,9 @@ type ## that **must not** be part of a message! Use ## a ``TThreadId`` for that. when TArg is void: - dataFn: proc () + dataFn: proc () {.nimcall.} else: - dataFn: proc (m: TArg) + dataFn: proc (m: TArg) {.nimcall.} data: TArg TThreadId*[TArg] = ptr TThread[TArg] ## the current implementation uses ## a pointer as a thread ID. @@ -317,7 +316,8 @@ proc joinThreads*[TArg](t: openArray[TThread[TArg]]) = var a: array[0..255, TSysThread] sysAssert a.len >= t.len, "a.len >= t.len" for i in 0..t.high: a[i] = t[i].sys - discard WaitForMultipleObjects(t.len, cast[ptr TSysThread](addr(a)), 1, -1) + discard WaitForMultipleObjects(t.len.int32, + cast[ptr TSysThread](addr(a)), 1, -1) else: for i in 0..t.high: joinThread(t[i]) |