Windows: Avoid concurrent access to sysinfo
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
383a2f046b
commit
54e09aa4e2
|
@ -34,10 +34,9 @@ const (
|
||||||
ProcessorArchitectureArm = 5 // PROCESSOR_ARCHITECTURE_ARM
|
ProcessorArchitectureArm = 5 // PROCESSOR_ARCHITECTURE_ARM
|
||||||
)
|
)
|
||||||
|
|
||||||
var sysinfo systeminfo
|
|
||||||
|
|
||||||
// runtimeArchitecture gets the name of the current architecture (x86, x86_64, …)
|
// runtimeArchitecture gets the name of the current architecture (x86, x86_64, …)
|
||||||
func runtimeArchitecture() (string, error) {
|
func runtimeArchitecture() (string, error) {
|
||||||
|
var sysinfo systeminfo
|
||||||
syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
|
syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
|
||||||
switch sysinfo.wProcessorArchitecture {
|
switch sysinfo.wProcessorArchitecture {
|
||||||
case ProcessorArchitecture64, ProcessorArchitectureIA64:
|
case ProcessorArchitecture64, ProcessorArchitectureIA64:
|
||||||
|
@ -53,6 +52,7 @@ func runtimeArchitecture() (string, error) {
|
||||||
|
|
||||||
// NumProcs returns the number of processors on the system
|
// NumProcs returns the number of processors on the system
|
||||||
func NumProcs() uint32 {
|
func NumProcs() uint32 {
|
||||||
|
var sysinfo systeminfo
|
||||||
syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
|
syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
|
||||||
return sysinfo.dwNumberOfProcessors
|
return sysinfo.dwNumberOfProcessors
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue