Update cpuinfo.nim
sys/types.h needed for macosx and freebsd sys/param.h needed for openbsd and netbsd
This commit is contained in:
parent
1da251523f
commit
54f6280d76
1 changed files with 8 additions and 1 deletions
|
|
@ -18,15 +18,22 @@ when not defined(windows):
|
||||||
|
|
||||||
when defined(linux):
|
when defined(linux):
|
||||||
import 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):
|
when defined(macosx) or defined(bsd):
|
||||||
|
{.emit:"#include <sys/sysctl.h>".}
|
||||||
const
|
const
|
||||||
CTL_HW = 6
|
CTL_HW = 6
|
||||||
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, b: pointer, c: int): cint {.
|
||||||
importc: "sysctl", header: "<sys/sysctl.h>".}
|
importc: "sysctl".}
|
||||||
|
|
||||||
proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
|
proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
|
||||||
## returns the numer of the processors/cores the machine has.
|
## returns the numer of the processors/cores the machine has.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue