v/vlib/runtime/runtime_windows.c.v

20 lines
321 B
V
Raw Normal View History

2019-10-11 13:16:02 +02:00
module runtime
import os
[typedef]
struct C.SYSTEM_INFO {
dwNumberOfProcessors u32
}
fn C.GetSystemInfo(&C.SYSTEM_INFO)
pub fn nr_cpus() int {
sinfo := C.SYSTEM_INFO{}
C.GetSystemInfo(&sinfo)
mut nr := int(sinfo.dwNumberOfProcessors)
if nr == 0 {
nr = os.getenv('NUMBER_OF_PROCESSORS').int()
}
return nr
}