Merge branch 'devel' of github.com:nim-lang/Nim into devel

This commit is contained in:
Andreas Rumpf 2016-02-19 01:08:00 +01:00
commit 608170b9d6
20 changed files with 148 additions and 20 deletions

View file

@ -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()

View file

@ -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)

View file

@ -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 initSysLock(L: var SysLock, attr: pointer = nil) {.
proc SysLockType_Reentrant: SysLockType =
{.emit: "`result` = PTHREAD_MUTEX_RECURSIVE;".}
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,