Home | History | Annotate | Download | only in dist
      1 // Copyright 2015 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      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 // see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
     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 const (
     33 	PROCESSOR_ARCHITECTURE_AMD64 = 9
     34 	PROCESSOR_ARCHITECTURE_INTEL = 0
     35 )
     36 
     37 var sysinfo systeminfo
     38 
     39 func sysinit() {
     40 	syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
     41 	switch sysinfo.wProcessorArchitecture {
     42 	case PROCESSOR_ARCHITECTURE_AMD64:
     43 		gohostarch = "amd64"
     44 	case PROCESSOR_ARCHITECTURE_INTEL:
     45 		gohostarch = "386"
     46 	default:
     47 		fatalf("unknown processor architecture")
     48 	}
     49 }
     50