summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-02-19 01:08:00 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-02-19 01:08:00 +0100
commit608170b9d6a8b63c4c2915f9f1d98f18a4db07a4 (patch)
treeafa9029f04c5f9846fb347010508972cb88f32ab /lib/system
parent8ec5c01cae61a727159ddfd0ea7c781d10be9f83 (diff)
parent12b5c0985d7e7449d98a6f80a77369368698b0a3 (diff)
downloadNim-608170b9d6a8b63c4c2915f9f1d98f18a4db07a4.tar.gz
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/excpt.nim2
-rw-r--r--lib/system/repr.nim1
-rw-r--r--lib/system/syslocks.nim16
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index df28c1493..8d1e04b8d 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -216,7 +216,7 @@ proc raiseExceptionAux(e: ref Exception) =
     if not localRaiseHook(e): return
   if globalRaiseHook != nil:
     if not globalRaiseHook(e): return
-  when defined(cpp):
+  when defined(cpp) and not defined(noCppExceptions):
     if e[] of OutOfMemError:
       showErrorMessage(e.name)
       quitOrDebug()
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index 986994203..7f18ed31c 100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -76,6 +76,7 @@ proc reprEnum(e: int, typ: PNimType): string {.compilerRtl.} =
   # we read an 'int' but this may have been too large, so mask the other bits:
   let e = if typ.size == 1: e and 0xff
           elif typ.size == 2: e and 0xffff
+          elif typ.size == 4: e and 0xffffffff
           else: e
   # XXX we need a proper narrowing based on signedness here
   #e and ((1 shl (typ.size*8)) - 1)
diff --git a/lib/system/syslocks.nim b/lib/system/syslocks.nim
index 7a113b9d4..a91a5e7d4 100644
--- a/lib/system/syslocks.nim
+++ b/lib/system/syslocks.nim
@@ -7,7 +7,7 @@
 #    distribution, for details about the copyright.
 #
 
-## Low level system locks and condition vars.
+# Low level system locks and condition vars.
 
 when defined(Windows):
   type
@@ -75,12 +75,24 @@ else:
   type
     SysLock {.importc: "pthread_mutex_t", pure, final,
                header: "<sys/types.h>".} = object
+    SysLockAttr {.importc: "pthread_mutexattr_t", pure, final
+               header: "<sys/types.h>".} = object
     SysCond {.importc: "pthread_cond_t", pure, final,
                header: "<sys/types.h>".} = object
+    SysLockType = distinct cint
+
+  proc SysLockType_Reentrant: SysLockType =
+    {.emit: "`result` = PTHREAD_MUTEX_RECURSIVE;".}
 
-  proc initSysLock(L: var SysLock, attr: pointer = nil) {.
+  proc initSysLock(L: var SysLock, attr: ptr SysLockAttr = nil) {.
     importc: "pthread_mutex_init", header: "<pthread.h>", noSideEffect.}
 
+  proc initSysLockAttr(a: var SysLockAttr) {.
+    importc: "pthread_mutexattr_init", header: "<pthread.h>", noSideEffect.}
+
+  proc setSysLockType(a: var SysLockAttr, t: SysLockType) {.
+    importc: "pthread_mutexattr_settype", header: "<pthread.h>", noSideEffect.}
+  
   proc acquireSys(L: var SysLock) {.noSideEffect,
     importc: "pthread_mutex_lock", header: "<pthread.h>".}
   proc tryAcquireSysAux(L: var SysLock): cint {.noSideEffect,