Fixes to support Dragonfly BSD. (#5552)

* Fix kqueue.nim and ansi_c.nim to support dragonfly.
* Fix ioselectors.nim, threads.nim to support dragonfly.
* Fix deprecated dealloc call in tioselectors.nim.
* Fix tfsmonitor.nim test to run only on Linux.
* Fix osproc.nim return wrong exit codes.
* Fix getAppFilename() for dragonfly.
* Fix proper exit code handling.
This commit is contained in:
Eugene Kabanov 2017-03-17 09:22:11 +02:00 • committed by Andreas Rumpf
commit 336a7c9b3f
9 changed files with 39 additions and 20 deletions

View file

@ -1464,7 +1464,7 @@ when declared(paramCount) or defined(nimdoc):
for i in 1..paramCount():
result.add(paramStr(i))
when defined(freebsd):
when defined(freebsd) or defined(dragonfly):
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
newp: pointer, newplen: csize): cint
{.importc: "sysctl",header: """#include <sys/types.h>
@ -1472,9 +1472,13 @@ when defined(freebsd):
const
CTL_KERN = 1
KERN_PROC = 14
KERN_PROC_PATHNAME = 12
MAX_PATH = 1024
when defined(freebsd):
const KERN_PROC_PATHNAME = 12
else:
const KERN_PROC_PATHNAME = 9
proc getApplFreebsd(): string =
var pathLength = csize(MAX_PATH)
result = newString(pathLength)
@ -1578,7 +1582,7 @@ proc getAppFilename*(): string {.rtl, extern: "nos$1", tags: [ReadIOEffect].} =
result = getApplAux("/proc/self/exe")
elif defined(solaris):
result = getApplAux("/proc/" & $getpid() & "/path/a.out")
elif defined(freebsd):
elif defined(freebsd) or defined(dragonfly):
result = getApplFreebsd()
# little heuristic that may work on other POSIX-like systems:
if result.len == 0: