diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/core/typeinfo.nim | 1 | ||||
-rw-r--r-- | lib/impure/re.nim | 16 | ||||
-rw-r--r-- | lib/impure/zipfiles.nim | 2 | ||||
-rw-r--r-- | lib/posix/posix.nim | 2 | ||||
-rw-r--r-- | lib/pure/asyncio.nim | 10 | ||||
-rw-r--r-- | lib/pure/concurrency/cpuinfo.nim | 11 | ||||
-rw-r--r-- | lib/pure/net.nim | 4 | ||||
-rw-r--r-- | lib/pure/oids.nim | 2 | ||||
-rw-r--r-- | lib/pure/osproc.nim | 2 | ||||
-rw-r--r-- | lib/pure/pegs.nim | 18 | ||||
-rw-r--r-- | lib/pure/rawsockets.nim | 2 | ||||
-rw-r--r-- | lib/pure/sockets.nim | 2 | ||||
-rw-r--r-- | lib/system.nim | 134 | ||||
-rw-r--r-- | lib/system/alloc.nim | 2 | ||||
-rw-r--r-- | lib/system/assign.nim | 12 | ||||
-rw-r--r-- | lib/system/avltree.nim | 4 | ||||
-rw-r--r-- | lib/system/cgprocs.nim | 4 | ||||
-rw-r--r-- | lib/system/channels.nim | 11 | ||||
-rw-r--r-- | lib/system/deepcopy.nim | 4 | ||||
-rw-r--r-- | lib/system/excpt.nim | 12 | ||||
-rw-r--r-- | lib/system/gc.nim | 20 | ||||
-rw-r--r-- | lib/system/gc_ms.nim | 16 | ||||
-rw-r--r-- | lib/system/hti.nim | 4 | ||||
-rw-r--r-- | lib/system/inclrtl.nim | 5 | ||||
-rw-r--r-- | lib/windows/winlean.nim | 2 | ||||
-rw-r--r-- | lib/wrappers/openssl.nim | 8 |
26 files changed, 181 insertions, 129 deletions
diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 842a944e1..84281485f 100644 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -13,6 +13,7 @@ {.push hints: off.} +include "system/inclrtl.nim" include "system/hti.nim" {.pop.} diff --git a/lib/impure/re.nim b/lib/impure/re.nim index fc9ed3ce0..6e3a69c62 100644 --- a/lib/impure/re.nim +++ b/lib/impure/re.nim @@ -92,7 +92,7 @@ proc matchOrFind(s: string, pattern: Regex, matches: var openArray[string], var a = rawMatches[i * 2] var b = rawMatches[i * 2 + 1] if a >= 0'i32: matches[i-1] = substr(s, int(a), int(b)-1) - else: matches[i-1] = "" + else: matches[i-1] = nil return rawMatches[1] - rawMatches[0] proc findBounds*(s: string, pattern: Regex, matches: var openArray[string], @@ -110,7 +110,7 @@ proc findBounds*(s: string, pattern: Regex, matches: var openArray[string], var a = rawMatches[i * 2] var b = rawMatches[i * 2 + 1] if a >= 0'i32: matches[i-1] = substr(s, int(a), int(b)-1) - else: matches[i-1] = "" + else: matches[i-1] = nil return (rawMatches[0].int, rawMatches[1].int - 1) proc findBounds*(s: string, pattern: Regex, @@ -190,7 +190,7 @@ proc find*(s: string, pattern: Regex, matches: var openArray[string], var a = rawMatches[i * 2] var b = rawMatches[i * 2 + 1] if a >= 0'i32: matches[i-1] = substr(s, int(a), int(b)-1) - else: matches[i-1] = "" + else: matches[i-1] = nil return rawMatches[0] proc find*(s: string, pattern: Regex, start = 0): int = @@ -310,6 +310,8 @@ proc replacef*(s: string, sub: Regex, by: string): string = while true: var match = findBounds(s, sub, caps, prev) if match.first < 0: break + assert result != nil + assert s != nil add(result, substr(s, prev, match.first-1)) addf(result, by, caps) prev = match.last + 1 @@ -450,6 +452,14 @@ when isMainModule: assert matches[1] == "abc" else: assert false + + if "abc" =~ re"(cba)?.*": + assert matches[0] == nil + else: assert false + + if "abc" =~ re"().*": + assert matches[0] == "" + else: assert false assert "var1=key; var2=key2".endsWith(re"\w+=\w+") assert("var1=key; var2=key2".replacef(re"(\w+)=(\w+)", "$1<-$2$2") == diff --git a/lib/impure/zipfiles.nim b/lib/impure/zipfiles.nim index fb687e6f1..c22294061 100644 --- a/lib/impure/zipfiles.nim +++ b/lib/impure/zipfiles.nim @@ -56,6 +56,8 @@ proc addFile*(z: var TZipArchive, dest, src: string) = ## Adds the file `src` to the archive `z` with the name `dest`. `dest` ## may contain a path that will be created. assert(z.mode != fmRead) + if not fileExists(src): + raise newException(IOError, "File '" & src & "' does not exist") var zipsrc = zip_source_file(z.w, src, 0, -1) if zipsrc == nil: #echo("Dest: " & dest) diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index c3085f0fb..8c1c258db 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -2382,7 +2382,7 @@ proc hstrerror*(herrnum: cint): cstring {.importc, header: "<netdb.h>".} proc FD_CLR*(a1: cint, a2: var TFdSet) {.importc, header: "<sys/select.h>".} proc FD_ISSET*(a1: cint | SocketHandle, a2: var TFdSet): cint {. importc, header: "<sys/select.h>".} -proc fdSet*(a1: cint | SocketHandle, a2: var TFdSet) {. +proc FD_SET*(a1: cint | SocketHandle, a2: var TFdSet) {. importc: "FD_SET", header: "<sys/select.h>".} proc FD_ZERO*(a1: var TFdSet) {.importc, header: "<sys/select.h>".} diff --git a/lib/pure/asyncio.nim b/lib/pure/asyncio.nim index bb0d29fc4..0dbc0a3d5 100644 --- a/lib/pure/asyncio.nim +++ b/lib/pure/asyncio.nim @@ -91,11 +91,11 @@ import sockets, os ## getSocket(s).accept(client) when defined(windows): - from winlean import TimeVal, SocketHandle, fdSet, FD_ZERO, TFdSet, - fdSet, FD_ISSET, select + from winlean import TimeVal, SocketHandle, FD_SET, FD_ZERO, TFdSet, + FD_ISSET, select else: - from posix import TimeVal, SocketHandle, fdSet, FD_ZERO, TFdSet, - fdSet, FD_ISSET, select + from posix import TimeVal, SocketHandle, FD_SET, FD_ZERO, TFdSet, + FD_ISSET, select type DelegateObj* = object @@ -556,7 +556,7 @@ proc createFdSet(fd: var TFdSet, s: seq[Delegate], m: var int) = FD_ZERO(fd) for i in items(s): m = max(m, int(i.fd)) - fdSet(i.fd, fd) + FD_SET(i.fd, fd) proc pruneSocketSet(s: var seq[Delegate], fd: var TFdSet) = var i = 0 diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index e55786c3e..ac5fa5dd9 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -18,15 +18,24 @@ when not defined(windows): when defined(linux): import linux + +when defined(freebsd) or defined(macosx): + {.emit:"#include <sys/types.h>".} + +when defined(openbsd) or defined(netbsd): + {.emit:"#include <sys/param.h>".} when defined(macosx) or defined(bsd): + # we HAVE to emit param.h before sysctl.h so we cannot use .header here + # either. The amount of archaic bullshit in Poonix based OSes is just insane. + {.emit:"#include <sys/sysctl.h>".} const CTL_HW = 6 HW_AVAILCPU = 25 HW_NCPU = 3 proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer, a: var csize, b: pointer, c: int): cint {. - importc: "sysctl", header: "<sys/sysctl.h>".} + importc: "sysctl", nodecl.} proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 60298ec88..f63f5fff8 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -232,10 +232,10 @@ when defined(ssl): proc socketError*(socket: Socket, err: int = -1, async = false, lastError = (-1).OSErrorCode) = - ## Raises an EOS error based on the error code returned by ``SSLGetError`` + ## Raises an OSError based on the error code returned by ``SSLGetError`` ## (for SSL sockets) and ``osLastError`` otherwise. ## - ## If ``async`` is ``True`` no error will be thrown in the case when the + ## If ``async`` is ``true`` no error will be thrown in the case when the ## error was caused by no data being available to be read. ## ## If ``err`` is not lower than 0 no exception will be raised. diff --git a/lib/pure/oids.nim b/lib/pure/oids.nim index 7c58a2dda..0dc8e3c15 100644 --- a/lib/pure/oids.nim +++ b/lib/pure/oids.nim @@ -55,7 +55,7 @@ proc oidToString*(oid: Oid, str: cstring) = str[24] = '\0' proc `$`*(oid: Oid): string = - result = newString(25) + result = newString(24) oidToString(oid, result) var diff --git a/lib/pure/osproc.nim b/lib/pure/osproc.nim index 59eecf88d..500ec7fb7 100644 --- a/lib/pure/osproc.nim +++ b/lib/pure/osproc.nim @@ -897,7 +897,7 @@ elif not defined(useNimRtl): FD_ZERO(fd) for i in items(s): m = max(m, int(i.outHandle)) - fdSet(cint(i.outHandle), fd) + FD_SET(cint(i.outHandle), fd) proc pruneProcessSet(s: var seq[Process], fd: var TFdSet) = var i = 0 diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index b2d8a2a4f..6eb7dee78 100644 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -737,7 +737,12 @@ proc rawMatch*(s: string, p: Peg, start: int, c: var Captures): int {. template fillMatches(s, caps, c: expr) = for k in 0..c.ml-1: - caps[k] = substr(s, c.matches[k][0], c.matches[k][1]) + let startIdx = c.matches[k][0] + let endIdx = c.matches[k][1] + if startIdx != -1: + caps[k] = substr(s, startIdx, endIdx) + else: + caps[k] = nil proc match*(s: string, pattern: Peg, matches: var openArray[string], start = 0): bool {.nosideEffect, rtl, extern: "npegs$1Capture".} = @@ -1767,3 +1772,14 @@ when isMainModule: assert match("prefix/start", peg"^start$", 7) + if "foo" =~ peg"{'a'}?.*": + assert matches[0] == nil + else: assert false + + if "foo" =~ peg"{''}.*": + assert matches[0] == "" + else: assert false + + if "foo" =~ peg"{'foo'}": + assert matches[0] == "foo" + else: assert false diff --git a/lib/pure/rawsockets.nim b/lib/pure/rawsockets.nim index 5756ca23d..62a011999 100644 --- a/lib/pure/rawsockets.nim +++ b/lib/pure/rawsockets.nim @@ -372,7 +372,7 @@ proc createFdSet(fd: var TFdSet, s: seq[SocketHandle], m: var int) = FD_ZERO(fd) for i in items(s): m = max(m, int(i)) - fdSet(i, fd) + FD_SET(i, fd) proc pruneSocketSet(s: var seq[SocketHandle], fd: var TFdSet) = var i = 0 diff --git a/lib/pure/sockets.nim b/lib/pure/sockets.nim index 6975f07c0..36389edcc 100644 --- a/lib/pure/sockets.nim +++ b/lib/pure/sockets.nim @@ -936,7 +936,7 @@ proc createFdSet(fd: var TFdSet, s: seq[Socket], m: var int) = FD_ZERO(fd) for i in items(s): m = max(m, int(i.fd)) - fdSet(i.fd, fd) + FD_SET(i.fd, fd) proc pruneSocketSet(s: var seq[Socket], fd: var TFdSet) = var i = 0 diff --git a/lib/system.nim b/lib/system.nim index da49386ed..a9b4da77a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1318,20 +1318,20 @@ proc substr*(s: string, first, last: int): string {. ## or `limit`:idx: a string's length. when not defined(nimrodVM): - proc zeroMem*(p: pointer, size: int) {.importc, noDecl, gcsafe.} + proc zeroMem*(p: pointer, size: int) {.importc, noDecl, benign.} ## overwrites the contents of the memory at ``p`` with the value 0. ## Exactly ``size`` bytes will be overwritten. Like any procedure ## dealing with raw memory this is *unsafe*. proc copyMem*(dest, source: pointer, size: int) {. - importc: "memcpy", header: "<string.h>", gcsafe.} + importc: "memcpy", header: "<string.h>", benign.} ## copies the contents from the memory at ``source`` to the memory ## at ``dest``. Exactly ``size`` bytes will be copied. The memory ## regions may not overlap. Like any procedure dealing with raw ## memory this is *unsafe*. proc moveMem*(dest, source: pointer, size: int) {. - importc: "memmove", header: "<string.h>", gcsafe.} + importc: "memmove", header: "<string.h>", benign.} ## copies the contents from the memory at ``source`` to the memory ## at ``dest``. Exactly ``size`` bytes will be copied. The memory ## regions may overlap, ``moveMem`` handles this case appropriately @@ -1346,14 +1346,14 @@ when not defined(nimrodVM): ## *unsafe*. when hostOS != "standalone": - proc alloc*(size: int): pointer {.noconv, rtl, tags: [], gcsafe.} + proc alloc*(size: int): pointer {.noconv, rtl, tags: [], benign.} ## allocates a new memory block with at least ``size`` bytes. The ## block has to be freed with ``realloc(block, 0)`` or ## ``dealloc(block)``. The block is not initialized, so reading ## from it before writing to it is undefined behaviour! ## The allocated memory belongs to its allocating thread! ## Use `allocShared` to allocate from a shared heap. - proc createU*(T: typedesc, size = 1.Positive): ptr T {.inline, gcsafe.} = + proc createU*(T: typedesc, size = 1.Positive): ptr T {.inline, benign.} = ## allocates a new memory block with at least ``T.sizeof * size`` ## bytes. The block has to be freed with ``resize(block, 0)`` or ## ``free(block)``. The block is not initialized, so reading @@ -1361,14 +1361,14 @@ when not defined(nimrodVM): ## The allocated memory belongs to its allocating thread! ## Use `createSharedU` to allocate from a shared heap. cast[ptr T](alloc(T.sizeof * size)) - proc alloc0*(size: int): pointer {.noconv, rtl, tags: [], gcsafe.} + proc alloc0*(size: int): pointer {.noconv, rtl, tags: [], benign.} ## allocates a new memory block with at least ``size`` bytes. The ## block has to be freed with ``realloc(block, 0)`` or ## ``dealloc(block)``. The block is initialized with all bytes ## containing zero, so it is somewhat safer than ``alloc``. ## The allocated memory belongs to its allocating thread! ## Use `allocShared0` to allocate from a shared heap. - proc create*(T: typedesc, size = 1.Positive): ptr T {.inline, gcsafe.} = + proc create*(T: typedesc, size = 1.Positive): ptr T {.inline, benign.} = ## allocates a new memory block with at least ``T.sizeof * size`` ## bytes. The block has to be freed with ``resize(block, 0)`` or ## ``free(block)``. The block is initialized with all bytes @@ -1377,7 +1377,7 @@ when not defined(nimrodVM): ## Use `createShared` to allocate from a shared heap. cast[ptr T](alloc0(T.sizeof * size)) proc realloc*(p: pointer, newSize: int): pointer {.noconv, rtl, tags: [], - gcsafe.} + benign.} ## grows or shrinks a given memory block. If p is **nil** then a new ## memory block is returned. In either way the block has at least ## ``newSize`` bytes. If ``newSize == 0`` and p is not **nil** @@ -1385,7 +1385,7 @@ when not defined(nimrodVM): ## be freed with ``dealloc``. ## The allocated memory belongs to its allocating thread! ## Use `reallocShared` to reallocate from a shared heap. - proc resize*[T](p: ptr T, newSize: Natural): ptr T {.inline, gcsafe.} = + proc resize*[T](p: ptr T, newSize: Natural): ptr T {.inline, benign.} = ## grows or shrinks a given memory block. If p is **nil** then a new ## memory block is returned. In either way the block has at least ## ``T.sizeof * newSize`` bytes. If ``newSize == 0`` and p is not @@ -1394,7 +1394,7 @@ when not defined(nimrodVM): ## its allocating thread! ## Use `resizeShared` to reallocate from a shared heap. cast[ptr T](realloc(p, T.sizeof * newSize)) - proc dealloc*(p: pointer) {.noconv, rtl, tags: [], gcsafe.} + proc dealloc*(p: pointer) {.noconv, rtl, tags: [], benign.} ## frees the memory allocated with ``alloc``, ``alloc0`` or ## ``realloc``. This procedure is dangerous! If one forgets to ## free the memory a leak occurs; if one tries to access freed @@ -1402,23 +1402,23 @@ when not defined(nimrodVM): ## or other memory may be corrupted. ## The freed memory must belong to its allocating thread! ## Use `deallocShared` to deallocate from a shared heap. - proc free*[T](p: ptr T) {.inline, gcsafe.} = + proc free*[T](p: ptr T) {.inline, benign.} = dealloc(p) - proc allocShared*(size: int): pointer {.noconv, rtl, gcsafe.} + proc allocShared*(size: int): pointer {.noconv, rtl, benign.} ## allocates a new memory block on the shared heap with at ## least ``size`` bytes. The block has to be freed with ## ``reallocShared(block, 0)`` or ``deallocShared(block)``. The block ## is not initialized, so reading from it before writing to it is ## undefined behaviour! proc createSharedU*(T: typedesc, size = 1.Positive): ptr T {.inline, - gcsafe.} = + benign.} = ## allocates a new memory block on the shared heap with at ## least ``T.sizeof * size`` bytes. The block has to be freed with ## ``resizeShared(block, 0)`` or ``freeShared(block)``. The block ## is not initialized, so reading from it before writing to it is ## undefined behaviour! cast[ptr T](allocShared(T.sizeof * size)) - proc allocShared0*(size: int): pointer {.noconv, rtl, gcsafe.} + proc allocShared0*(size: int): pointer {.noconv, rtl, benign.} ## allocates a new memory block on the shared heap with at ## least ``size`` bytes. The block has to be freed with ## ``reallocShared(block, 0)`` or ``deallocShared(block)``. @@ -1432,7 +1432,7 @@ when not defined(nimrodVM): ## containing zero, so it is somewhat safer than ``createSharedU``. cast[ptr T](allocShared0(T.sizeof * size)) proc reallocShared*(p: pointer, newSize: int): pointer {.noconv, rtl, - gcsafe.} + benign.} ## grows or shrinks a given memory block on the heap. If p is **nil** ## then a new memory block is returned. In either way the block has at ## least ``newSize`` bytes. If ``newSize == 0`` and p is not **nil** @@ -1445,13 +1445,13 @@ when not defined(nimrodVM): ## not **nil** ``resizeShared`` calls ``freeShared(p)``. In other ## cases the block has to be freed with ``freeShared``. cast[ptr T](reallocShared(p, T.sizeof * newSize)) - proc deallocShared*(p: pointer) {.noconv, rtl, gcsafe.} + proc deallocShared*(p: pointer) {.noconv, rtl, benign.} ## frees the memory allocated with ``allocShared``, ``allocShared0`` or ## ``reallocShared``. This procedure is dangerous! If one forgets to ## free the memory a leak occurs; if one tries to access freed ## memory (or just freeing it twice!) a core dump may happen ## or other memory may be corrupted. - proc freeShared*[T](p: ptr T) {.inline, gcsafe.} = + proc freeShared*[T](p: ptr T) {.inline, benign.} = ## frees the memory allocated with ``createShared``, ``createSharedU`` or ## ``resizeShared``. This procedure is dangerous! If one forgets to ## free the memory a leak occurs; if one tries to access freed @@ -1993,15 +1993,15 @@ when false: # ----------------- GC interface --------------------------------------------- when not defined(nimrodVM) and hostOS != "standalone": - proc GC_disable*() {.rtl, inl.} + proc GC_disable*() {.rtl, inl, benign.} ## disables the GC. If called n-times, n calls to `GC_enable` are needed to ## reactivate the GC. Note that in most circumstances one should only disable ## the mark and sweep phase with `GC_disableMarkAndSweep`. - proc GC_enable*() {.rtl, inl.} + proc GC_enable*() {.rtl, inl, benign.} ## enables the GC again. - proc GC_fullCollect*() {.rtl.} + proc GC_fullCollect*() {.rtl, benign.} ## forces a full garbage collection pass. ## Ordinary code does not need to call this (and should not). @@ -2014,22 +2014,23 @@ when not defined(nimrodVM) and hostOS != "standalone": {.deprecated: [TGC_Strategy: GC_Strategy].} - proc GC_setStrategy*(strategy: GC_Strategy) {.rtl, deprecated.} + proc GC_setStrategy*(strategy: GC_Strategy) {.rtl, deprecated, benign.} ## tells the GC the desired strategy for the application. ## **Deprecated** since version 0.8.14. This has always been a nop. - proc GC_enableMarkAndSweep*() {.rtl.} - proc GC_disableMarkAndSweep*() {.rtl.} + proc GC_enableMarkAndSweep*() {.rtl, benign.} + proc GC_disableMarkAndSweep*() {.rtl, benign.} ## the current implementation uses a reference counting garbage collector ## with a seldomly run mark and sweep phase to free cycles. The mark and ## sweep phase may take a long time and is not needed if the application ## does not create cycles. Thus the mark and sweep phase can be deactivated ## and activated separately from the rest of the GC. - proc GC_getStatistics*(): string {.rtl.} + proc GC_getStatistics*(): string {.rtl, benign.} ## returns an informative string about the GC's activity. This may be useful ## for tweaking. + # XXX mark these as 'locks: 0' once 0.10.0 has been released proc GC_ref*[T](x: ref T) {.magic: "GCref", gcsafe.} proc GC_ref*[T](x: seq[T]) {.magic: "GCref", gcsafe.} proc GC_ref*(x: string) {.magic: "GCref", gcsafe.} @@ -2057,7 +2058,7 @@ const NimStackTrace = compileOption("stacktrace") # of the code var - globalRaiseHook*: proc (e: ref Exception): bool {.nimcall, gcsafe.} + globalRaiseHook*: proc (e: ref Exception): bool {.nimcall, benign.} ## with this hook you can influence exception handling on a global level. ## If not nil, every 'raise' statement ends up calling this hook. Ordinary ## application code should never set this hook! You better know what you @@ -2065,7 +2066,7 @@ var ## exception is caught and does not propagate further through the call ## stack. - localRaiseHook* {.threadvar.}: proc (e: ref Exception): bool {.nimcall, gcsafe.} + localRaiseHook* {.threadvar.}: proc (e: ref Exception): bool {.nimcall, benign.} ## with this hook you can influence exception handling on a ## thread local level. ## If not nil, every 'raise' statement ends up calling this hook. Ordinary @@ -2073,7 +2074,7 @@ var ## do when setting this. If ``localRaiseHook`` returns false, the exception ## is caught and does not propagate further through the call stack. - outOfMemHook*: proc () {.nimcall, tags: [], gcsafe.} + outOfMemHook*: proc () {.nimcall, tags: [], benign.} ## set this variable to provide a procedure that should be called ## in case of an `out of memory`:idx: event. The standard handler ## writes an error message and terminates the program. `outOfMemHook` can @@ -2125,7 +2126,7 @@ elif hostOS != "standalone": inc(i) {.pop.} -proc echo*[T](x: varargs[T, `$`]) {.magic: "Echo", tags: [WriteIOEffect], gcsafe.} +proc echo*[T](x: varargs[T, `$`]) {.magic: "Echo", tags: [WriteIOEffect], benign.} ## Writes and flushes the parameters to the standard output. ## ## Special built-in that takes a variable number of arguments. Each argument @@ -2178,9 +2179,14 @@ when not declared(sysFatal): e.msg = message & arg raise e -proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo", gcsafe.} - ## get type information for `x`. Ordinary code should not use this, but - ## the `typeinfo` module instead. +when defined(nimlocks): + proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo", gcsafe, locks: 0.} + ## get type information for `x`. Ordinary code should not use this, but + ## the `typeinfo` module instead. +else: + proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo", gcsafe.} + ## get type information for `x`. Ordinary code should not use this, but + ## the `typeinfo` module instead. {.push stackTrace: off.} proc abs*(x: int): int {.magic: "AbsI", noSideEffect.} = @@ -2294,14 +2300,14 @@ when not defined(JS): #and not defined(NimrodVM): proc open*(f: var File, filename: string, mode: FileMode = fmRead, bufSize: int = -1): bool {.tags: [], - gcsafe.} + benign.} ## Opens a file named `filename` with given `mode`. ## ## Default mode is readonly. Returns true iff the file could be opened. ## This throws no exception if the file could not be opened. proc open*(f: var File, filehandle: FileHandle, - mode: FileMode = fmRead): bool {.tags: [], gcsafe.} + mode: FileMode = fmRead): bool {.tags: [], benign.} ## Creates a ``TFile`` from a `filehandle` with given `mode`. ## ## Default mode is readonly. Returns true iff the file could be opened. @@ -2316,7 +2322,7 @@ when not defined(JS): #and not defined(NimrodVM): sysFatal(IOError, "cannot open: ", filename) proc reopen*(f: File, filename: string, mode: FileMode = fmRead): bool {. - tags: [], gcsafe.} + tags: [], benign.} ## reopens the file `f` with given `filename` and `mode`. This ## is often used to redirect the `stdin`, `stdout` or `stderr` ## file variables. @@ -2326,7 +2332,7 @@ when not defined(JS): #and not defined(NimrodVM): proc close*(f: File) {.importc: "fclose", header: "<stdio.h>", tags: [].} ## Closes the file. - proc endOfFile*(f: File): bool {.tags: [], gcsafe.} + proc endOfFile*(f: File): bool {.tags: [], benign.} ## Returns true iff `f` is at the end. proc readChar*(f: File): char {. @@ -2336,40 +2342,40 @@ when not defined(JS): #and not defined(NimrodVM): importc: "fflush", header: "<stdio.h>", tags: [WriteIOEffect].} ## Flushes `f`'s buffer. - proc readAll*(file: File): TaintedString {.tags: [ReadIOEffect], gcsafe.} + proc readAll*(file: File): TaintedString {.tags: [ReadIOEffect], benign.} ## Reads all data from the stream `file`. ## ## Raises an IO exception in case of an error. It is an error if the ## current file position is not at the beginning of the file. - proc readFile*(filename: string): TaintedString {.tags: [ReadIOEffect], gcsafe.} + proc readFile*(filename: string): TaintedString {.tags: [ReadIOEffect], benign.} ## Opens a file named `filename` for reading. Then calls `readAll` ## and closes the file afterwards. Returns the string. ## Raises an IO exception in case of an error. - proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], gcsafe.} + proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], benign.} ## Opens a file named `filename` for writing. Then writes the ## `content` completely to the file and closes the file afterwards. ## Raises an IO exception in case of an error. - proc write*(f: File, r: float32) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, i: int) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, i: BiggestInt) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, r: BiggestFloat) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, s: string) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, b: bool) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, c: char) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, c: cstring) {.tags: [WriteIOEffect], gcsafe.} - proc write*(f: File, a: varargs[string, `$`]) {.tags: [WriteIOEffect], gcsafe.} + proc write*(f: File, r: float32) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, i: int) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, i: BiggestInt) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, r: BiggestFloat) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, s: string) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, b: bool) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, c: char) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, c: cstring) {.tags: [WriteIOEffect], benign.} + proc write*(f: File, a: varargs[string, `$`]) {.tags: [WriteIOEffect], benign.} ## Writes a value to the file `f`. May throw an IO exception. - proc readLine*(f: File): TaintedString {.tags: [ReadIOEffect], gcsafe.} + proc readLine*(f: File): TaintedString {.tags: [ReadIOEffect], benign.} ## reads a line of text from the file `f`. May throw an IO exception. ## A line of text may be delimited by ``CR``, ``LF`` or ## ``CRLF``. The newline character(s) are not part of the returned string. proc readLine*(f: File, line: var TaintedString): bool {.tags: [ReadIOEffect], - gcsafe.} + benign.} ## reads a line of text from the file `f` into `line`. `line` must not be ## ``nil``! May throw an IO exception. ## A line of text may be delimited by ``CR``, ``LF`` or @@ -2379,57 +2385,57 @@ when not defined(JS): #and not defined(NimrodVM): when not defined(booting): proc writeln*[Ty](f: File, x: varargs[Ty, `$`]) {.inline, - tags: [WriteIOEffect], gcsafe.} + tags: [WriteIOEffect], gcsafe, locks: 0.} ## writes the values `x` to `f` and then writes "\n". ## May throw an IO exception. else: proc writeln*[Ty](f: File, x: varargs[Ty, `$`]) {.inline, tags: [WriteIOEffect].} - proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], gcsafe.} + proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], benign.} ## retrieves the file size (in bytes) of `f`. proc readBytes*(f: File, a: var openArray[int8], start, len: int): int {. - tags: [ReadIOEffect], gcsafe.} + tags: [ReadIOEffect], benign.} ## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns ## the actual number of bytes that have been read which may be less than ## `len` (if not as many bytes are remaining), but not greater. proc readChars*(f: File, a: var openArray[char], start, len: int): int {. - tags: [ReadIOEffect], gcsafe.} + tags: [ReadIOEffect], benign.} ## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns ## the actual number of bytes that have been read which may be less than ## `len` (if not as many bytes are remaining), but not greater. proc readBuffer*(f: File, buffer: pointer, len: int): int {. - tags: [ReadIOEffect], gcsafe.} + tags: [ReadIOEffect], benign.} ## reads `len` bytes into the buffer pointed to by `buffer`. Returns ## the actual number of bytes that have been read which may be less than ## `len` (if not as many bytes are remaining), but not greater. proc writeBytes*(f: File, a: openArray[int8], start, len: int): int {. - tags: [WriteIOEffect], gcsafe.} + tags: [WriteIOEffect], benign.} ## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns ## the number of actual written bytes, which may be less than `len` in case ## of an error. proc writeChars*(f: File, a: openArray[char], start, len: int): int {. - tags: [WriteIOEffect], gcsafe.} + tags: [WriteIOEffect], benign.} ## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns ## the number of actual written bytes, which may be less than `len` in case ## of an error. proc writeBuffer*(f: File, buffer: pointer, len: int): int {. - tags: [WriteIOEffect], gcsafe.} + tags: [WriteIOEffect], benign.} ## writes the bytes of buffer pointed to by the parameter `buffer` to the ## file `f`. Returns the number of actual written bytes, which may be less ## than `len` in case of an error. - proc setFilePos*(f: File, pos: int64) {.gcsafe.} + proc setFilePos*(f: File, pos: int64) {.benign.} ## sets the position of the file pointer that is used for read/write ## operations. The file's first byte has the index zero. - proc getFilePos*(f: File): int64 {.gcsafe.} + proc getFilePos*(f: File): int64 {.benign.} ## retrieves the current position of the file pointer that is used to ## read from the file `f`. The file's first byte has the index zero. @@ -2476,11 +2482,11 @@ when not defined(JS): #and not defined(NimrodVM): when not defined(NimrodVM): proc atomicInc*(memLoc: var int, x: int = 1): int {.inline, - discardable, gcsafe.} + discardable, benign.} ## atomic increment of `memLoc`. Returns the value after the operation. proc atomicDec*(memLoc: var int, x: int = 1): int {.inline, - discardable, gcsafe.} + discardable, benign.} ## atomic decrement of `memLoc`. Returns the value after the operation. include "system/atomics" @@ -2611,11 +2617,11 @@ when not defined(JS): #and not defined(NimrodVM): include "system/assign" include "system/repr" - proc getCurrentException*(): ref Exception {.compilerRtl, inl, gcsafe.} = + proc getCurrentException*(): ref Exception {.compilerRtl, inl, benign.} = ## retrieves the current exception; if there is none, nil is returned. result = currException - proc getCurrentExceptionMsg*(): string {.inline, gcsafe.} = + proc getCurrentExceptionMsg*(): string {.inline, benign.} = ## retrieves the error message that was attached to the current ## exception; if there is none, "" is returned. var e = getCurrentException() @@ -2631,7 +2637,7 @@ when not defined(JS): #and not defined(NimrodVM): excHandler.hasRaiseAction = true excHandler.raiseAction = action - proc setCurrentException*(exc: ref Exception) {.inline, gcsafe.} = + proc setCurrentException*(exc: ref Exception) {.inline, benign.} = ## sets the current exception. ## ## **Warning**: Only use this if you know what you are doing. diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 9f227f0c5..fd3ced832 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -514,7 +514,7 @@ proc getSmallChunk(a: var TMemRegion): PSmallChunk = result = cast[PSmallChunk](res) # ----------------------------------------------------------------------------- -proc isAllocatedPtr(a: TMemRegion, p: pointer): bool +proc isAllocatedPtr(a: TMemRegion, p: pointer): bool {.benign.} proc allocInv(a: TMemRegion): bool = ## checks some (not all yet) invariants of the allocator's data structures. diff --git a/lib/system/assign.nim b/lib/system/assign.nim index 6c58c24c2..8d53e127c 100644 --- a/lib/system/assign.nim +++ b/lib/system/assign.nim @@ -7,11 +7,11 @@ # distribution, for details about the copyright. # -proc genericResetAux(dest: pointer, n: ptr TNimNode) {.gcsafe.} +proc genericResetAux(dest: pointer, n: ptr TNimNode) {.benign.} -proc genericAssignAux(dest, src: pointer, mt: PNimType, shallow: bool) {.gcsafe.} +proc genericAssignAux(dest, src: pointer, mt: PNimType, shallow: bool) {.benign.} proc genericAssignAux(dest, src: pointer, n: ptr TNimNode, - shallow: bool) {.gcsafe.} = + shallow: bool) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) @@ -136,8 +136,8 @@ proc genericAssignOpenArray(dest, src: pointer, len: int, genericAssign(cast[pointer](d +% i*% mt.base.size), cast[pointer](s +% i*% mt.base.size), mt.base) -proc objectInit(dest: pointer, typ: PNimType) {.compilerProc, gcsafe.} -proc objectInitAux(dest: pointer, n: ptr TNimNode) {.gcsafe.} = +proc objectInit(dest: pointer, typ: PNimType) {.compilerProc, benign.} +proc objectInitAux(dest: pointer, n: ptr TNimNode) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkNone: sysAssert(false, "objectInitAux") @@ -182,7 +182,7 @@ else: mixin destroy for i in countup(0, r.len - 1): destroy(r[i]) -proc genericReset(dest: pointer, mt: PNimType) {.compilerProc, gcsafe.} +proc genericReset(dest: pointer, mt: PNimType) {.compilerProc, benign.} proc genericResetAux(dest: pointer, n: ptr TNimNode) = var d = cast[ByteAddress](dest) case n.kind diff --git a/lib/system/avltree.nim b/lib/system/avltree.nim index 157799b28..292097062 100644 --- a/lib/system/avltree.nim +++ b/lib/system/avltree.nim @@ -51,7 +51,7 @@ proc split(t: var PAvlNode) = t.link[0] = temp inc t.level -proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.gcsafe.} = +proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.benign.} = if t == bottom: t = allocAvlNode(a, key, upperBound) else: @@ -64,7 +64,7 @@ proc add(a: var TMemRegion, t: var PAvlNode, key, upperBound: int) {.gcsafe.} = skew(t) split(t) -proc del(a: var TMemRegion, t: var PAvlNode, x: int) {.gcsafe.} = +proc del(a: var TMemRegion, t: var PAvlNode, x: int) {.benign.} = if t == bottom: return a.last = t if x <% t.key: diff --git a/lib/system/cgprocs.nim b/lib/system/cgprocs.nim index d46e715f1..089846578 100644 --- a/lib/system/cgprocs.nim +++ b/lib/system/cgprocs.nim @@ -9,7 +9,7 @@ # Headers for procs that the code generator depends on ("compilerprocs") -proc addChar(s: NimString, c: char): NimString {.compilerProc, gcsafe.} +proc addChar(s: NimString, c: char): NimString {.compilerProc, benign.} type TLibHandle = pointer # private type @@ -21,5 +21,5 @@ proc nimGetProcAddr(lib: TLibHandle, name: cstring): TProcAddr {.compilerproc.} proc nimLoadLibraryError(path: string) {.compilerproc, noinline.} -proc setStackBottom(theStackBottom: pointer) {.compilerRtl, noinline, gcsafe.} +proc setStackBottom(theStackBottom: pointer) {.compilerRtl, noinline, benign.} diff --git a/lib/system/channels.nim b/lib/system/channels.nim index d7ec2c4af..3e5ca0795 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -49,9 +49,9 @@ proc deinitRawChannel(p: pointer) = deinitSysCond(c.cond) proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, - mode: TLoadStoreMode) {.gcsafe.} + mode: TLoadStoreMode) {.benign.} proc storeAux(dest, src: pointer, n: ptr TNimNode, t: PRawChannel, - mode: TLoadStoreMode) {.gcsafe.} = + mode: TLoadStoreMode) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) @@ -226,15 +226,16 @@ proc recv*[TMsg](c: var TChannel[TMsg]): TMsg = llRecv(q, addr(result), cast[PNimType](getTypeInfo(result))) releaseSys(q.lock) -proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvaliable: bool, +proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool, msg: TMsg] = ## try to receives a message from the channel `c` if available. Otherwise ## it returns ``(false, default(msg))``. var q = cast[PRawChannel](addr(c)) if q.mask != ChannelDeadMask: - lockChannel(q): + if tryAcquireSys(q.lock): llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg))) - result.dataAvaliable = true + result.dataAvailable = true + releaseSys(q.lock) proc peek*[TMsg](c: var TChannel[TMsg]): int = ## returns the current number of messages in the channel `c`. Returns -1 diff --git a/lib/system/deepcopy.nim b/lib/system/deepcopy.nim index e4356a25d..fbebb17a8 100644 --- a/lib/system/deepcopy.nim +++ b/lib/system/deepcopy.nim @@ -7,8 +7,8 @@ # distribution, for details about the copyright. # -proc genericDeepCopyAux(dest, src: pointer, mt: PNimType) {.gcsafe.} -proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode) {.gcsafe.} = +proc genericDeepCopyAux(dest, src: pointer, mt: PNimType) {.benign.} +proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode) {.benign.} = var d = cast[ByteAddress](dest) s = cast[ByteAddress](src) diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim index c0e99a5e2..e21eeca6a 100644 --- a/lib/system/excpt.nim +++ b/lib/system/excpt.nim @@ -11,7 +11,7 @@ # use the heap (and nor exceptions) do not include the GC or memory allocator. var - errorMessageWriter*: (proc(msg: string) {.tags: [WriteIOEffect], gcsafe.}) + errorMessageWriter*: (proc(msg: string) {.tags: [WriteIOEffect], benign.}) ## Function that will be called ## instead of stdmsg.write when printing stacktrace. ## Unstable API. @@ -32,10 +32,10 @@ proc showErrorMessage(data: cstring) = else: writeToStdErr(data) -proc chckIndx(i, a, b: int): int {.inline, compilerproc, gcsafe.} -proc chckRange(i, a, b: int): int {.inline, compilerproc, gcsafe.} -proc chckRangeF(x, a, b: float): float {.inline, compilerproc, gcsafe.} -proc chckNil(p: pointer) {.noinline, compilerproc, gcsafe.} +proc chckIndx(i, a, b: int): int {.inline, compilerproc, benign.} +proc chckRange(i, a, b: int): int {.inline, compilerproc, benign.} +proc chckRangeF(x, a, b: float): float {.inline, compilerproc, benign.} +proc chckNil(p: pointer) {.noinline, compilerproc, benign.} var framePtr {.threadvar.}: PFrame @@ -343,5 +343,5 @@ when not defined(noSignalHandler): proc setControlCHook(hook: proc () {.noconv.}) = # ugly cast, but should work on all architectures: - type TSignalHandler = proc (sig: cint) {.noconv, gcsafe.} + type TSignalHandler = proc (sig: cint) {.noconv, benign.} c_signal(SIGINT, cast[TSignalHandler](hook)) diff --git a/lib/system/gc.nim b/lib/system/gc.nim index c4b3a4928..fe4b40903 100644 --- a/lib/system/gc.nim +++ b/lib/system/gc.nim @@ -51,7 +51,7 @@ type waZctDecRef, waPush, waCycleDecRef, waMarkGray, waScan, waScanBlack, waCollectWhite, - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, gcsafe.} + TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} # A ref type can have a finalizer that is called before the object's # storage is freed. @@ -152,11 +152,11 @@ template gcTrace(cell, state: expr): stmt {.immediate.} = when traceGC: traceCell(cell, state) # forward declarations: -proc collectCT(gch: var TGcHeap) {.gcsafe.} -proc isOnStack*(p: pointer): bool {.noinline, gcsafe.} -proc forAllChildren(cell: PCell, op: TWalkOp) {.gcsafe.} -proc doOperation(p: pointer, op: TWalkOp) {.gcsafe.} -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.gcsafe.} +proc collectCT(gch: var TGcHeap) {.benign.} +proc isOnStack*(p: pointer): bool {.noinline, benign.} +proc forAllChildren(cell: PCell, op: TWalkOp) {.benign.} +proc doOperation(p: pointer, op: TWalkOp) {.benign.} +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.benign.} # we need the prototype here for debugging purposes when hasThreadSupport and hasSharedHeap: @@ -294,7 +294,7 @@ proc initGC() = when useMarkForDebug or useBackupGc: type - TGlobalMarkerProc = proc () {.nimcall, gcsafe.} + TGlobalMarkerProc = proc () {.nimcall, benign.} var globalMarkersLen: int globalMarkers: array[0.. 7_000, TGlobalMarkerProc] @@ -311,7 +311,7 @@ proc cellsetReset(s: var TCellSet) = deinit(s) init(s) -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.gcsafe.} = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) @@ -680,11 +680,11 @@ proc doOperation(p: pointer, op: TWalkOp) = proc nimGCvisit(d: pointer, op: int) {.compilerRtl.} = doOperation(d, TWalkOp(op)) -proc collectZCT(gch: var TGcHeap): bool {.gcsafe.} +proc collectZCT(gch: var TGcHeap): bool {.benign.} when useMarkForDebug or useBackupGc: proc markStackAndRegistersForSweep(gch: var TGcHeap) {.noinline, cdecl, - gcsafe.} + benign.} proc collectRoots(gch: var TGcHeap) = for s in elements(gch.cycleRoots): diff --git a/lib/system/gc_ms.nim b/lib/system/gc_ms.nim index f90000a1c..242ca1608 100644 --- a/lib/system/gc_ms.nim +++ b/lib/system/gc_ms.nim @@ -32,11 +32,11 @@ type # local waMarkPrecise # fast precise marking - TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, gcsafe.} + TFinalizer {.compilerproc.} = proc (self: pointer) {.nimcall, benign.} # A ref type can have a finalizer that is called before the object's # storage is freed. - TGlobalMarkerProc = proc () {.nimcall, gcsafe.} + TGlobalMarkerProc = proc () {.nimcall, benign.} TGcStat = object collections: int # number of performed full collections @@ -116,11 +116,11 @@ when BitsPerPage mod (sizeof(int)*8) != 0: {.error: "(BitsPerPage mod BitsPerUnit) should be zero!".} # forward declarations: -proc collectCT(gch: var TGcHeap) {.gcsafe.} -proc isOnStack*(p: pointer): bool {.noinline, gcsafe.} -proc forAllChildren(cell: PCell, op: TWalkOp) {.gcsafe.} -proc doOperation(p: pointer, op: TWalkOp) {.gcsafe.} -proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.gcsafe.} +proc collectCT(gch: var TGcHeap) {.benign.} +proc isOnStack*(p: pointer): bool {.noinline, benign.} +proc forAllChildren(cell: PCell, op: TWalkOp) {.benign.} +proc doOperation(p: pointer, op: TWalkOp) {.benign.} +proc forAllChildrenAux(dest: pointer, mt: PNimType, op: TWalkOp) {.benign.} # we need the prototype here for debugging purposes proc prepareDealloc(cell: PCell) = @@ -168,7 +168,7 @@ proc initGC() = Init(gch.allocated) init(gch.marked) -proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.gcsafe.} = +proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) {.benign.} = var d = cast[ByteAddress](dest) case n.kind of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op) diff --git a/lib/system/hti.nim b/lib/system/hti.nim index 4a8ab2485..e599668a7 100644 --- a/lib/system/hti.nim +++ b/lib/system/hti.nim @@ -85,8 +85,8 @@ type base: ptr TNimType node: ptr TNimNode # valid for tyRecord, tyObject, tyTuple, tyEnum finalizer: pointer # the finalizer for the type - marker: proc (p: pointer, op: int) {.nimcall, gcsafe.} # marker proc for GC - deepcopy: proc (p: pointer): pointer {.nimcall, gcsafe.} + marker: proc (p: pointer, op: int) {.nimcall, benign.} # marker proc for GC + deepcopy: proc (p: pointer): pointer {.nimcall, benign.} PNimType = ptr TNimType # node.len may be the ``first`` element of a set diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index a975bb7c2..aac802229 100644 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -46,3 +46,8 @@ else: when not defined(nimsuperops): {.pragma: operator.} + +when defined(nimlocks): + {.pragma: benign, gcsafe, locks: 0.} +else: + {.pragma: benign, gcsafe.} diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index cc633d90b..76d17bc4a 100644 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -536,7 +536,7 @@ proc WSAFDIsSet(s: SocketHandle, set: var TFdSet): bool {. proc FD_ISSET*(socket: SocketHandle, set: var TFdSet): cint = result = if WSAFDIsSet(socket, set): 1'i32 else: 0'i32 -proc fdSet*(socket: SocketHandle, s: var TFdSet) = +proc FD_SET*(socket: SocketHandle, s: var TFdSet) = if s.fd_count < FD_SETSIZE: s.fd_array[int(s.fd_count)] = socket inc(s.fd_count) diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim index abdfcdb52..6e85fb9dd 100644 --- a/lib/wrappers/openssl.nim +++ b/lib/wrappers/openssl.nim @@ -41,7 +41,9 @@ {.deadCodeElim: on.} -when defined(WINDOWS): +const useWinVersion = defined(Windows) or defined(nimdoc) + +when useWinVersion: const DLLSSLName = "(ssleay32|libssl32).dll" DLLUtilName = "libeay32.dll" @@ -270,12 +272,12 @@ proc OpenSSL_add_all_algorithms*(){.cdecl, dynlib: DLLUtilName, importc: "OPENSS proc OPENSSL_config*(configName: cstring){.cdecl, dynlib: DLLSSLName, importc.} -when not defined(windows): +when not useWinVersion: proc CRYPTO_set_mem_functions(a,b,c: pointer){.cdecl, dynlib: DLLUtilName, importc.} proc CRYPTO_malloc_init*() = - when not defined(windows): + when not useWinVersion: CRYPTO_set_mem_functions(alloc, realloc, dealloc) proc SSL_CTX_ctrl*(ctx: SslCtx, cmd: cInt, larg: int, parg: pointer): int{. |