diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2008-11-16 22:08:15 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2008-11-16 22:08:15 +0100 |
commit | 8b2a9401a147bd0b26cd2976ae71a1022fbde8cc (patch) | |
tree | c1a1323003ee8148af5dc60bcf1b88157dd00eb8 /lib/excpt.nim | |
parent | 972c51086152bd45aef4eb17c099fa3472a19d04 (diff) | |
download | Nim-8b2a9401a147bd0b26cd2976ae71a1022fbde8cc.tar.gz |
version 0.7.0
Diffstat (limited to 'lib/excpt.nim')
-rw-r--r-- | lib/excpt.nim | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/excpt.nim b/lib/excpt.nim index 8adb3d5a9..9c87fab55 100644 --- a/lib/excpt.nim +++ b/lib/excpt.nim @@ -171,8 +171,7 @@ var proc signalHandler(sig: cint) {.exportc: "signalHandler", noconv.} = # print stack trace and quit - var - s = int(sig) + var s = sig GC_disable() setLen(buf, 0) rawWriteStackTrace(buf) @@ -199,7 +198,8 @@ proc registerSignalHandler() = c_signal(SIGILL, signalHandler) c_signal(SIGBUS, signalHandler) -registerSignalHandler() # call it in initialization section +when not defined(noSignalHandler): + registerSignalHandler() # call it in initialization section # for easier debugging of the GC, this memory is only allocated after the # signal handlers have been registered new(gAssertionFailed) @@ -256,3 +256,12 @@ proc chckObj(obj, subclass: PNimType) {.compilerproc.} = proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} = if a != b: raise newException(EInvalidObjectAssignment, "invalid object assignment") + +proc isObj(obj, subclass: PNimType): bool {.compilerproc.} = + # checks if obj is of type subclass: + var x = obj + if x == subclass: return true # optimized fast path + while x != subclass: + if x == nil: return false + x = x.base + return true |