github.com/akerouanton/docker@v1.11.0-rc3/pkg/platform/architecture_windows.go (about) 1 package platform 2 3 import ( 4 "fmt" 5 "syscall" 6 "unsafe" 7 ) 8 9 var ( 10 modkernel32 = syscall.NewLazyDLL("kernel32.dll") 11 procGetSystemInfo = modkernel32.NewProc("GetSystemInfo") 12 ) 13 14 // see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx 15 type systeminfo struct { 16 wProcessorArchitecture uint16 17 wReserved uint16 18 dwPageSize uint32 19 lpMinimumApplicationAddress uintptr 20 lpMaximumApplicationAddress uintptr 21 dwActiveProcessorMask uintptr 22 dwNumberOfProcessors uint32 23 dwProcessorType uint32 24 dwAllocationGranularity uint32 25 wProcessorLevel uint16 26 wProcessorRevision uint16 27 } 28 29 // Constants 30 const ( 31 ProcessorArchitecture64 = 9 // PROCESSOR_ARCHITECTURE_AMD64 32 ProcessorArchitectureIA64 = 6 // PROCESSOR_ARCHITECTURE_IA64 33 ProcessorArchitecture32 = 0 // PROCESSOR_ARCHITECTURE_INTEL 34 ProcessorArchitectureArm = 5 // PROCESSOR_ARCHITECTURE_ARM 35 ) 36 37 var sysinfo systeminfo 38 39 // runtimeArchitecture get the name of the current architecture (x86, x86_64, …) 40 func runtimeArchitecture() (string, error) { 41 syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0) 42 switch sysinfo.wProcessorArchitecture { 43 case ProcessorArchitecture64, ProcessorArchitectureIA64: 44 return "x86_64", nil 45 case ProcessorArchitecture32: 46 return "i686", nil 47 case ProcessorArchitectureArm: 48 return "arm", nil 49 default: 50 return "", fmt.Errorf("Unknown processor architecture") 51 } 52 }