2019-11-15 14:14:28 +01:00
|
|
|
module runtime
|
|
|
|
|
2021-07-17 16:07:59 +02:00
|
|
|
fn C.sysconf(name int) i64
|
|
|
|
|
2020-12-27 19:14:43 +01:00
|
|
|
// nr_cpus returns the number of virtual CPU cores found on the system.
|
2020-07-20 16:36:44 +02:00
|
|
|
pub fn nr_cpus() int {
|
2021-07-17 16:07:59 +02:00
|
|
|
$if linux || macos || solaris {
|
2020-03-21 09:48:02 +01:00
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2019-11-15 14:14:28 +01:00
|
|
|
return 1
|
2020-12-27 19:14:43 +01:00
|
|
|
}
|