csize => csize_t for sysctl
This commit is contained in:
parent
2e20f5648b
commit
2ecef8f779
3 changed files with 10 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ when defined(macosx) or defined(bsd):
|
||||||
HW_AVAILCPU = 25
|
HW_AVAILCPU = 25
|
||||||
HW_NCPU = 3
|
HW_NCPU = 3
|
||||||
proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
|
proc sysctl(x: ptr array[0..3, cint], y: cint, z: pointer,
|
||||||
a: var csize, b: pointer, c: int): cint {.
|
a: var csize_t, b: pointer, c: csize_t): cint {.
|
||||||
importc: "sysctl", nodecl.}
|
importc: "sysctl", nodecl.}
|
||||||
|
|
||||||
when defined(genode):
|
when defined(genode):
|
||||||
|
|
@ -73,10 +73,9 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
|
||||||
var
|
var
|
||||||
mib: array[0..3, cint]
|
mib: array[0..3, cint]
|
||||||
numCPU: int
|
numCPU: int
|
||||||
len: csize
|
|
||||||
mib[0] = CTL_HW
|
mib[0] = CTL_HW
|
||||||
mib[1] = HW_AVAILCPU
|
mib[1] = HW_AVAILCPU
|
||||||
len = sizeof(numCPU)
|
var len = sizeof(numCPU).csize_t
|
||||||
discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
|
discard sysctl(addr(mib), 2, addr(numCPU), len, nil, 0)
|
||||||
if numCPU < 1:
|
if numCPU < 1:
|
||||||
mib[1] = HW_NCPU
|
mib[1] = HW_NCPU
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ when defined(macosx) or defined(freebsd) or defined(dragonfly):
|
||||||
const MAX_DESCRIPTORS_ID = 29 # KERN_MAXFILESPERPROC (MacOS)
|
const MAX_DESCRIPTORS_ID = 29 # KERN_MAXFILESPERPROC (MacOS)
|
||||||
else:
|
else:
|
||||||
const MAX_DESCRIPTORS_ID = 27 # KERN_MAXFILESPERPROC (FreeBSD)
|
const MAX_DESCRIPTORS_ID = 27 # KERN_MAXFILESPERPROC (FreeBSD)
|
||||||
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
|
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize_t,
|
||||||
newp: pointer, newplen: csize): cint
|
newp: pointer, newplen: csize_t): cint
|
||||||
{.importc: "sysctl",header: """#include <sys/types.h>
|
{.importc: "sysctl",header: """#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>"""}
|
#include <sys/sysctl.h>"""}
|
||||||
elif defined(netbsd) or defined(openbsd):
|
elif defined(netbsd) or defined(openbsd):
|
||||||
|
|
@ -36,8 +36,8 @@ elif defined(netbsd) or defined(openbsd):
|
||||||
# KERN_MAXFILES, because KERN_MAXFILES is always bigger,
|
# KERN_MAXFILES, because KERN_MAXFILES is always bigger,
|
||||||
# than KERN_MAXFILESPERPROC.
|
# than KERN_MAXFILESPERPROC.
|
||||||
const MAX_DESCRIPTORS_ID = 7 # KERN_MAXFILES
|
const MAX_DESCRIPTORS_ID = 7 # KERN_MAXFILES
|
||||||
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
|
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize_t,
|
||||||
newp: pointer, newplen: csize): cint
|
newp: pointer, newplen: csize_t): cint
|
||||||
{.importc: "sysctl",header: """#include <sys/param.h>
|
{.importc: "sysctl",header: """#include <sys/param.h>
|
||||||
#include <sys/sysctl.h>"""}
|
#include <sys/sysctl.h>"""}
|
||||||
|
|
||||||
|
|
@ -82,7 +82,7 @@ proc getUnique[T](s: Selector[T]): int {.inline.} =
|
||||||
|
|
||||||
proc newSelector*[T](): owned(Selector[T]) =
|
proc newSelector*[T](): owned(Selector[T]) =
|
||||||
var maxFD = 0.cint
|
var maxFD = 0.cint
|
||||||
var size = csize(sizeof(cint))
|
var size = csize_t(sizeof(cint))
|
||||||
var namearr = [1.cint, MAX_DESCRIPTORS_ID.cint]
|
var namearr = [1.cint, MAX_DESCRIPTORS_ID.cint]
|
||||||
# Obtain maximum number of opened file descriptors for process
|
# Obtain maximum number of opened file descriptors for process
|
||||||
if sysctl(addr(namearr[0]), 2, cast[pointer](addr maxFD), addr size,
|
if sysctl(addr(namearr[0]), 2, cast[pointer](addr maxFD), addr size,
|
||||||
|
|
|
||||||
|
|
@ -2725,8 +2725,8 @@ when declared(paramCount) or defined(nimdoc):
|
||||||
result.add(paramStr(i))
|
result.add(paramStr(i))
|
||||||
|
|
||||||
when not weirdTarget and (defined(freebsd) or defined(dragonfly)):
|
when not weirdTarget and (defined(freebsd) or defined(dragonfly)):
|
||||||
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize,
|
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr csize_t,
|
||||||
newp: pointer, newplen: csize): cint
|
newp: pointer, newplen: csize_t): cint
|
||||||
{.importc: "sysctl",header: """#include <sys/types.h>
|
{.importc: "sysctl",header: """#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>"""}
|
#include <sys/sysctl.h>"""}
|
||||||
const
|
const
|
||||||
|
|
@ -2740,7 +2740,7 @@ when not weirdTarget and (defined(freebsd) or defined(dragonfly)):
|
||||||
const KERN_PROC_PATHNAME = 9
|
const KERN_PROC_PATHNAME = 9
|
||||||
|
|
||||||
proc getApplFreebsd(): string =
|
proc getApplFreebsd(): string =
|
||||||
var pathLength = csize(MAX_PATH)
|
var pathLength = csize_t(MAX_PATH)
|
||||||
result = newString(pathLength)
|
result = newString(pathLength)
|
||||||
var req = [CTL_KERN.cint, KERN_PROC.cint, KERN_PROC_PATHNAME.cint, -1.cint]
|
var req = [CTL_KERN.cint, KERN_PROC.cint, KERN_PROC_PATHNAME.cint, -1.cint]
|
||||||
while true:
|
while true:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue