diff options
author | Araq <rumpf_a@web.de> | 2011-05-17 22:56:34 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-05-17 22:56:34 +0200 |
commit | b0b2c233aedb7a475c0d918d7747c3ad942bb75f (patch) | |
tree | 2d6cb09385909818b18b4569ca0cc2f1014cb94a /lib/system | |
parent | 9207492bb997b414f45f24fed3ec5e942286d259 (diff) | |
download | Nim-b0b2c233aedb7a475c0d918d7747c3ad942bb75f.tar.gz |
still playing with threads
Diffstat (limited to 'lib/system')
-rwxr-xr-x | lib/system/gc.nim | 27 | ||||
-rwxr-xr-x | lib/system/systhread.nim | 3 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim index 3a7270539..15d2df70e 100755 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -80,15 +80,13 @@ var proc aquire(gch: var TGcHeap) {.inline.} = when hasThreadSupport: - if isMultiThreaded: - aquireSys(gch.zctLock) - aquireSys(gch.cycleRootsLock) + aquireSys(gch.zctLock) + aquireSys(gch.cycleRootsLock) proc release(gch: var TGcHeap) {.inline.} = when hasThreadSupport: - if isMultiThreaded: - releaseSys(gch.zctLock) - releaseSys(gch.cycleRootsLock) + releaseSys(gch.cycleRootsLock) + releaseSys(gch.zctLock) proc addZCT(s: var TCellSeq, c: PCell) {.noinline.} = if (c.refcount and rcZct) == 0: @@ -207,18 +205,18 @@ proc prepareDealloc(cell: PCell) = proc rtlAddCycleRoot(c: PCell) {.rtl, inl.} = # we MUST access gch as a global here, because this crosses DLL boundaries! when hasThreadSupport: - if isMultiThreaded: AquireSys(gch.cycleRootsLock) + AquireSys(gch.cycleRootsLock) incl(gch.cycleRoots, c) when hasThreadSupport: - if isMultiThreaded: ReleaseSys(gch.cycleRootsLock) + ReleaseSys(gch.cycleRootsLock) proc rtlAddZCT(c: PCell) {.rtl, inl.} = # we MUST access gch as a global here, because this crosses DLL boundaries! when hasThreadSupport: - if isMultiThreaded: AquireSys(gch.zctLock) + AquireSys(gch.zctLock) addZCT(gch.zct, c) when hasThreadSupport: - if isMultiThreaded: ReleaseSys(gch.zctLock) + ReleaseSys(gch.zctLock) proc decRef(c: PCell) {.inline.} = when stressGC: @@ -561,8 +559,9 @@ proc stackSize(): int {.noinline.} = when defined(sparc): # For SPARC architecture. proc isOnStack(p: pointer): bool = var stackTop {.volatile.}: pointer + stackTop = addr(stackTop) var b = cast[TAddress](stackBottom) - var a = cast[TAddress](addr(stackTop)) + var a = cast[TAddress](stackTop) var x = cast[TAddress](p) result = a <=% x and x <=% b @@ -591,8 +590,9 @@ elif stackIncreases: # --------------------------------------------------------------------------- proc isOnStack(p: pointer): bool = var stackTop {.volatile.}: pointer + stackTop = addr(stackTop) var a = cast[TAddress](stackBottom) - var b = cast[TAddress](addr(stackTop)) + var b = cast[TAddress](stackTop) var x = cast[TAddress](p) result = a <=% x and x <=% b @@ -618,8 +618,9 @@ else: # --------------------------------------------------------------------------- proc isOnStack(p: pointer): bool = var stackTop {.volatile.}: pointer + stackTop = addr(stackTop) var b = cast[TAddress](stackBottom) - var a = cast[TAddress](addr(stackTop)) + var a = cast[TAddress](stackTop) var x = cast[TAddress](p) result = a <=% x and x <=% b diff --git a/lib/system/systhread.nim b/lib/system/systhread.nim index 2b5057ff0..c497cc961 100755 --- a/lib/system/systhread.nim +++ b/lib/system/systhread.nim @@ -77,7 +77,8 @@ when defined(Windows): else: type - TSysLock {.importc: "pthread_mutex_t", header: "<sys/types.h>".} = int + TSysLock {.importc: "pthread_mutex_t", pure, final, + header: "<sys/types.h>".} = object proc InitSysLock(L: var TSysLock, attr: pointer = nil) {. importc: "pthread_mutex_init", header: "<pthread.h>".} |