...
Source file
src/cmd/dist/sys_windows.go
1
2
3
4
5 package main
6
7 import (
8 "syscall"
9 "unsafe"
10 )
11
12 var (
13 modkernel32 = syscall.NewLazyDLL("kernel32.dll")
14 procGetSystemInfo = modkernel32.NewProc("GetSystemInfo")
15 )
16
17
18 type systeminfo struct {
19 wProcessorArchitecture uint16
20 wReserved uint16
21 dwPageSize uint32
22 lpMinimumApplicationAddress uintptr
23 lpMaximumApplicationAddress uintptr
24 dwActiveProcessorMask uintptr
25 dwNumberOfProcessors uint32
26 dwProcessorType uint32
27 dwAllocationGranularity uint32
28 wProcessorLevel uint16
29 wProcessorRevision uint16
30 }
31
32
33 const (
34 PROCESSOR_ARCHITECTURE_AMD64 = 9
35 PROCESSOR_ARCHITECTURE_INTEL = 0
36 PROCESSOR_ARCHITECTURE_ARM = 5
37 PROCESSOR_ARCHITECTURE_ARM64 = 12
38 PROCESSOR_ARCHITECTURE_IA64 = 6
39 )
40
41 var sysinfo systeminfo
42
43 func sysinit() {
44 syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
45 switch sysinfo.wProcessorArchitecture {
46 case PROCESSOR_ARCHITECTURE_AMD64:
47 gohostarch = "amd64"
48 case PROCESSOR_ARCHITECTURE_INTEL:
49 gohostarch = "386"
50 case PROCESSOR_ARCHITECTURE_ARM:
51 gohostarch = "arm"
52 case PROCESSOR_ARCHITECTURE_ARM64:
53 gohostarch = "arm64"
54 default:
55 fatalf("unknown processor architecture")
56 }
57 }
58
View as plain text