2019-10-11 13:16:02 +02:00
|
|
|
module runtime
|
2019-11-15 14:14:28 +01:00
|
|
|
|
|
|
|
import os
|
|
|
|
|
2020-09-25 21:02:29 +02:00
|
|
|
[typedef]
|
|
|
|
struct C.SYSTEM_INFO {
|
|
|
|
dwNumberOfProcessors u32
|
|
|
|
}
|
|
|
|
fn C.GetSystemInfo(&C.SYSTEM_INFO)
|
|
|
|
|
2020-07-20 16:36:44 +02:00
|
|
|
pub fn nr_cpus() int {
|
2020-09-25 21:02:29 +02:00
|
|
|
sinfo := C.SYSTEM_INFO{}
|
|
|
|
C.GetSystemInfo(&sinfo)
|
|
|
|
mut nr := int(sinfo.dwNumberOfProcessors)
|
2019-11-15 14:14:28 +01:00
|
|
|
if nr == 0 {
|
|
|
|
nr = os.getenv('NUMBER_OF_PROCESSORS').int()
|
|
|
|
}
|
|
|
|
return nr
|
|
|
|
}
|