From b999d01de7ac47e7440352f9c5f5c6a71efe6c33 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 25 Sep 2020 22:02:29 +0300 Subject: [PATCH] runtime: use GetCurrentProcessorNumber for runtime.nr_cpus() --- vlib/runtime/runtime_windows.c.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/runtime/runtime_windows.c.v b/vlib/runtime/runtime_windows.c.v index 9b3e7259cd..6a345644bf 100644 --- a/vlib/runtime/runtime_windows.c.v +++ b/vlib/runtime/runtime_windows.c.v @@ -2,8 +2,16 @@ module runtime import os +[typedef] +struct C.SYSTEM_INFO { + dwNumberOfProcessors u32 +} +fn C.GetSystemInfo(&C.SYSTEM_INFO) + 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 { nr = os.getenv('NUMBER_OF_PROCESSORS').int() }