runtime: use GetCurrentProcessorNumber for runtime.nr_cpus()
parent
acbfc11eef
commit
b999d01de7
|
@ -2,8 +2,16 @@ module runtime
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
[typedef]
|
||||||
|
struct C.SYSTEM_INFO {
|
||||||
|
dwNumberOfProcessors u32
|
||||||
|
}
|
||||||
|
fn C.GetSystemInfo(&C.SYSTEM_INFO)
|
||||||
|
|
||||||
pub fn nr_cpus() int {
|
pub fn nr_cpus() int {
|
||||||
mut nr := int(C.GetCurrentProcessorNumber())
|
sinfo := C.SYSTEM_INFO{}
|
||||||
|
C.GetSystemInfo(&sinfo)
|
||||||
|
mut nr := int(sinfo.dwNumberOfProcessors)
|
||||||
if nr == 0 {
|
if nr == 0 {
|
||||||
nr = os.getenv('NUMBER_OF_PROCESSORS').int()
|
nr = os.getenv('NUMBER_OF_PROCESSORS').int()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue