1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/runtime/runtime_nix.c.v
2020-12-27 20:14:43 +02:00

16 lines
317 B
V

module runtime
// nr_cpus returns the number of virtual CPU cores found on the system.
pub fn nr_cpus() int {
$if linux {
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
}
$if macos {
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
}
$if solaris {
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
}
return 1
}