Merge branch 'devel' of https://github.com/Araq/Nim into devel
This commit is contained in:
commit
c461f5a8c6
57 changed files with 652 additions and 436 deletions
|
|
@ -649,6 +649,8 @@ proc `$`*(node: PNimrodNode): string {.compileTime.} =
|
|||
result = $node.basename.ident & "*"
|
||||
of nnkStrLit..nnkTripleStrLit:
|
||||
result = node.strVal
|
||||
of nnkSym:
|
||||
result = $node.symbol
|
||||
else:
|
||||
badNodeKind node.kind, "$"
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,15 @@ proc getSystemVersion*(): string =
|
|||
elif $unix_info.sysname == "Darwin":
|
||||
# Darwin
|
||||
result.add("Mac OS X ")
|
||||
if "10" in $unix_info.release:
|
||||
if "14" in $unix_info.release:
|
||||
result.add("v10.10 Yosemite")
|
||||
elif "13" in $unix_info.release:
|
||||
result.add("v10.9 Mavericks")
|
||||
elif "12" in $unix_info.release:
|
||||
result.add("v10.8 Mountian Lion")
|
||||
elif "11" in $unix_info.release:
|
||||
result.add("v10.7 Lion")
|
||||
elif "10" in $unix_info.release:
|
||||
result.add("v10.6 Snow Leopard")
|
||||
elif "9" in $unix_info.release:
|
||||
result.add("v10.5 Leopard")
|
||||
|
|
|
|||
|
|
@ -245,6 +245,14 @@ proc `$`*(osvi: TVersionInfo): string =
|
|||
if osvi.ProductType == VER_NT_WORKSTATION:
|
||||
result.add("Windows 7 ")
|
||||
else: result.add("Windows Server 2008 R2 ")
|
||||
elif osvi.minorVersion == 2:
|
||||
if osvi.ProductType == VER_NT_WORKSTATION:
|
||||
result.add("Windows 8 ")
|
||||
else: result.add("Windows Server 2012 ")
|
||||
elif osvi.minorVersion == 3:
|
||||
if osvi.ProductType == VER_NT_WORKSTATION:
|
||||
result.add("Windows 8.1 ")
|
||||
else: result.add("Windows Server 2012 R2 ")
|
||||
|
||||
var dwType = getProductInfo(osvi.majorVersion, osvi.minorVersion, 0, 0)
|
||||
case dwType
|
||||
|
|
|
|||
|
|
@ -1570,9 +1570,9 @@ else:
|
|||
|
||||
|
||||
when defined(macosx):
|
||||
# We can't use the NOSIGNAL flag in the ``send`` function, it has no effect
|
||||
var
|
||||
MSG_HAVEMORE* {.importc, header: "<sys/socket.h>".}: cint
|
||||
MSG_NOSIGNAL* = MSG_HAVEMORE
|
||||
MSG_NOSIGNAL* = 0'i32
|
||||
else:
|
||||
var
|
||||
MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
## as the response body.
|
||||
##
|
||||
## .. code-block::nim
|
||||
## import asynchttpserver, asyncdispatch
|
||||
##
|
||||
## var server = newAsyncHttpServer()
|
||||
## proc cb(req: Request) {.async.} =
|
||||
## await req.respond(Http200, "Hello World")
|
||||
|
|
|
|||
|
|
@ -1433,7 +1433,7 @@ proc eat(p: var PegParser, kind: TTokKind) =
|
|||
if p.tok.kind == kind: getTok(p)
|
||||
else: pegError(p, tokKindToStr[kind] & " expected")
|
||||
|
||||
proc parseExpr(p: var PegParser): Peg
|
||||
proc parseExpr(p: var PegParser): Peg {.gcsafe.}
|
||||
|
||||
proc getNonTerminal(p: var PegParser, name: string): NonTerminal =
|
||||
for i in 0..high(p.nonterms):
|
||||
|
|
|
|||
|
|
@ -428,6 +428,10 @@ proc selectWrite*(writefds: var seq[SocketHandle],
|
|||
|
||||
pruneSocketSet(writefds, (wr))
|
||||
|
||||
# We ignore signal SIGPIPE on Darwin
|
||||
when defined(macosx):
|
||||
signal(SIGPIPE, SIG_IGN)
|
||||
|
||||
when defined(Windows):
|
||||
var wsa: WSAData
|
||||
if wsaStartup(0x0101'i16, addr wsa) != 0: raiseOSError(osLastError())
|
||||
|
|
|
|||
|
|
@ -97,7 +97,9 @@ proc checkpoint*(msg: string) =
|
|||
template fail* =
|
||||
bind checkpoints
|
||||
for msg in items(checkpoints):
|
||||
echo msg
|
||||
# this used to be 'echo' which now breaks due to a bug. XXX will revisit
|
||||
# this issue later.
|
||||
stdout.writeln msg
|
||||
|
||||
when not defined(ECMAScript):
|
||||
if abortOnError: quit(1)
|
||||
|
|
|
|||
|
|
@ -1516,7 +1516,7 @@ const
|
|||
NimMinor*: int = 10
|
||||
## is the minor number of Nim's version.
|
||||
|
||||
NimPatch*: int = 1
|
||||
NimPatch*: int = 3
|
||||
## is the patch number of Nim's version.
|
||||
|
||||
NimVersion*: string = $NimMajor & "." & $NimMinor & "." & $NimPatch
|
||||
|
|
|
|||
|
|
@ -232,9 +232,10 @@ proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool,
|
|||
## it returns ``(false, default(msg))``.
|
||||
var q = cast[PRawChannel](addr(c))
|
||||
if q.mask != ChannelDeadMask:
|
||||
if tryAcquireSys(q.lock):
|
||||
llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg)))
|
||||
result.dataAvailable = true
|
||||
if tryAcquireSys(q.lock):
|
||||
if q.count > 0:
|
||||
llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg)))
|
||||
result.dataAvailable = true
|
||||
releaseSys(q.lock)
|
||||
|
||||
proc peek*[TMsg](c: var TChannel[TMsg]): int =
|
||||
|
|
|
|||
|
|
@ -296,15 +296,15 @@ when not defined(noSignalHandler):
|
|||
template processSignal(s, action: expr) {.immediate, dirty.} =
|
||||
if s == SIGINT: action("SIGINT: Interrupted by Ctrl-C.\n")
|
||||
elif s == SIGSEGV:
|
||||
action("SIGSEGV: Illegal storage access. (Attempt to read from nil?)\n")
|
||||
action("SIGSEGV: Illegal storage access. (Try to compile with -d:useSysAssert -d:useGcAssert for details.)\n")
|
||||
elif s == SIGABRT:
|
||||
when defined(endb):
|
||||
if dbgAborting: return # the debugger wants to abort
|
||||
action("SIGABRT: Abnormal termination.\n")
|
||||
elif s == SIGFPE: action("SIGFPE: Arithmetic error.\n")
|
||||
elif s == SIGILL: action("SIGILL: Illegal operation.\n")
|
||||
elif s == SIGBUS:
|
||||
action("SIGBUS: Illegal storage access. (Attempt to read from nil?)\n")
|
||||
elif s == SIGBUS:
|
||||
action("SIGBUS: Illegal storage access. (Try to compile with -d:useSysAssert -d:useGcAssert for details.)\n")
|
||||
else:
|
||||
block platformSpecificSignal:
|
||||
when declared(SIGPIPE):
|
||||
|
|
|
|||
|
|
@ -368,32 +368,32 @@ type
|
|||
{.deprecated: [TSocketHandle: SocketHandle].}
|
||||
|
||||
type
|
||||
WSAData* {.importc: "WSADATA", header: "Winsock2.h".} = object
|
||||
WSAData* {.importc: "WSADATA", header: "winsock2.h".} = object
|
||||
wVersion, wHighVersion: int16
|
||||
szDescription: array[0..WSADESCRIPTION_LEN, char]
|
||||
szSystemStatus: array[0..WSASYS_STATUS_LEN, char]
|
||||
iMaxSockets, iMaxUdpDg: int16
|
||||
lpVendorInfo: cstring
|
||||
|
||||
SockAddr* {.importc: "SOCKADDR", header: "Winsock2.h".} = object
|
||||
SockAddr* {.importc: "SOCKADDR", header: "winsock2.h".} = object
|
||||
sa_family*: int16 # unsigned
|
||||
sa_data: array[0..13, char]
|
||||
|
||||
InAddr* {.importc: "IN_ADDR", header: "Winsock2.h".} = object
|
||||
InAddr* {.importc: "IN_ADDR", header: "winsock2.h".} = object
|
||||
s_addr*: int32 # IP address
|
||||
|
||||
Sockaddr_in* {.importc: "SOCKADDR_IN",
|
||||
header: "Winsock2.h".} = object
|
||||
header: "winsock2.h".} = object
|
||||
sin_family*: int16
|
||||
sin_port*: int16 # unsigned
|
||||
sin_addr*: InAddr
|
||||
sin_zero*: array[0..7, char]
|
||||
|
||||
In6_addr* {.importc: "IN6_ADDR", header: "Winsock2.h".} = object
|
||||
In6_addr* {.importc: "IN6_ADDR", header: "winsock2.h".} = object
|
||||
bytes*: array[0..15, char]
|
||||
|
||||
Sockaddr_in6* {.importc: "SOCKADDR_IN6",
|
||||
header: "Winsock2.h".} = object
|
||||
header: "winsock2.h".} = object
|
||||
sin6_family*: int16
|
||||
sin6_port*: int16 # unsigned
|
||||
sin6_flowinfo*: int32 # unsigned
|
||||
|
|
@ -450,22 +450,22 @@ type
|
|||
|
||||
|
||||
var
|
||||
SOMAXCONN* {.importc, header: "Winsock2.h".}: cint
|
||||
INVALID_SOCKET* {.importc, header: "Winsock2.h".}: SocketHandle
|
||||
SOL_SOCKET* {.importc, header: "Winsock2.h".}: cint
|
||||
SO_DEBUG* {.importc, header: "Winsock2.h".}: cint ## turn on debugging info recording
|
||||
SO_ACCEPTCONN* {.importc, header: "Winsock2.h".}: cint # socket has had listen()
|
||||
SO_REUSEADDR* {.importc, header: "Winsock2.h".}: cint # allow local address reuse
|
||||
SO_KEEPALIVE* {.importc, header: "Winsock2.h".}: cint # keep connections alive
|
||||
SO_DONTROUTE* {.importc, header: "Winsock2.h".}: cint # just use interface addresses
|
||||
SO_BROADCAST* {.importc, header: "Winsock2.h".}: cint # permit sending of broadcast msgs
|
||||
SO_USELOOPBACK* {.importc, header: "Winsock2.h".}: cint # bypass hardware when possible
|
||||
SO_LINGER* {.importc, header: "Winsock2.h".}: cint # linger on close if data present
|
||||
SO_OOBINLINE* {.importc, header: "Winsock2.h".}: cint # leave received OOB data in line
|
||||
SOMAXCONN* {.importc, header: "winsock2.h".}: cint
|
||||
INVALID_SOCKET* {.importc, header: "winsock2.h".}: SocketHandle
|
||||
SOL_SOCKET* {.importc, header: "winsock2.h".}: cint
|
||||
SO_DEBUG* {.importc, header: "winsock2.h".}: cint ## turn on debugging info recording
|
||||
SO_ACCEPTCONN* {.importc, header: "winsock2.h".}: cint # socket has had listen()
|
||||
SO_REUSEADDR* {.importc, header: "winsock2.h".}: cint # allow local address reuse
|
||||
SO_KEEPALIVE* {.importc, header: "winsock2.h".}: cint # keep connections alive
|
||||
SO_DONTROUTE* {.importc, header: "winsock2.h".}: cint # just use interface addresses
|
||||
SO_BROADCAST* {.importc, header: "winsock2.h".}: cint # permit sending of broadcast msgs
|
||||
SO_USELOOPBACK* {.importc, header: "winsock2.h".}: cint # bypass hardware when possible
|
||||
SO_LINGER* {.importc, header: "winsock2.h".}: cint # linger on close if data present
|
||||
SO_OOBINLINE* {.importc, header: "winsock2.h".}: cint # leave received OOB data in line
|
||||
|
||||
SO_DONTLINGER* {.importc, header: "Winsock2.h".}: cint
|
||||
SO_EXCLUSIVEADDRUSE* {.importc, header: "Winsock2.h".}: cint # disallow local address reuse
|
||||
SO_ERROR* {.importc, header: "Winsock2.h".}: cint
|
||||
SO_DONTLINGER* {.importc, header: "winsock2.h".}: cint
|
||||
SO_EXCLUSIVEADDRUSE* {.importc, header: "winsock2.h".}: cint # disallow local address reuse
|
||||
SO_ERROR* {.importc, header: "winsock2.h".}: cint
|
||||
|
||||
proc `==`*(x, y: SocketHandle): bool {.borrow.}
|
||||
|
||||
|
|
|
|||
|
|
@ -280,9 +280,18 @@ when not useWinVersion:
|
|||
proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl,
|
||||
dynlib: DLLUtilName, importc.}
|
||||
|
||||
proc allocWrapper(size: int): pointer {.cdecl.} = alloc(size)
|
||||
proc reallocWrapper(p: pointer; newsize: int): pointer {.cdecl.} =
|
||||
if p == nil:
|
||||
if newSize > 0: result = alloc(newsize)
|
||||
elif newsize == 0: dealloc(p)
|
||||
else: result = realloc(p, newsize)
|
||||
proc deallocWrapper(p: pointer) {.cdecl.} =
|
||||
if p != nil: dealloc(p)
|
||||
|
||||
proc CRYPTO_malloc_init*() =
|
||||
when not useWinVersion:
|
||||
CRYPTO_set_mem_functions(alloc, realloc, dealloc)
|
||||
CRYPTO_set_mem_functions(allocWrapper, reallocWrapper, deallocWrapper)
|
||||
|
||||
proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cInt, larg: int, parg: pointer): int{.
|
||||
cdecl, dynlib: DLLSSLName, importc.}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue