aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist/sys_windows.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-01-07 11:38:00 -0500
committerRuss Cox <rsc@golang.org>2015-01-10 19:16:00 +0000
commit20a10e7ddd1b2305f1279043ec281301c9199359 (patch)
tree674cac1232c8bb87c64c1c42b306808769a9ac00 /src/cmd/dist/sys_windows.go
parentad6ee36cac122894f7ea4043289c10a50e48ac01 (diff)
downloadgo-20a10e7ddd1b2305f1279043ec281301c9199359.tar.gz
go-20a10e7ddd1b2305f1279043ec281301c9199359.zip
build: require old Go to build new Go (and convert cmd/dist to Go)
This CL introduces the bootstrap requirement that in order to build the current release (or development version) of Go, you need an older Go release (1.4 or newer) already installed. This requirement is the whole point of this CL. To enforce the requirement, convert cmd/dist from C to Go. With this bootstrapping out of the way, we can move on to replacing other, larger C programs like the Go compiler, the assemblers, and the linker. See golang.org/s/go15bootstrap for details. Change-Id: I53fd08ddacf3df9fae94fe2c986dba427ee4a21d Reviewed-on: https://go-review.googlesource.com/2470 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/dist/sys_windows.go')
-rw-r--r--src/cmd/dist/sys_windows.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cmd/dist/sys_windows.go b/src/cmd/dist/sys_windows.go
new file mode 100644
index 0000000000..c6867fb895
--- /dev/null
+++ b/src/cmd/dist/sys_windows.go
@@ -0,0 +1,49 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var (
+ modkernel32 = syscall.NewLazyDLL("kernel32.dll")
+ procGetSystemInfo = syscall.NewProc("GetSystemInfo")
+)
+
+// see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
+type systeminfo struct {
+ wProcessorArchitecture uint16
+ wReserved uint16
+ dwPageSize uint32
+ lpMinimumApplicationAddress uintptr
+ lpMaximumApplicationAddress uintptr
+ dwActiveProcessorMask uintptr
+ dwNumberOfProcessors uint32
+ dwProcessorType uint32
+ dwAllocationGranularity uint32
+ wProcessorLevel uint16
+ wProcessorRevision uint16
+}
+
+const (
+ PROCESSOR_ARCHITECTURE_AMD64 = 9
+ PROCESSOR_ARCHITECTURE_INTEL = 0
+)
+
+var sysinfo systeminfo
+
+func sysinit() {
+ syscall.Syscall(procGetSystemInfo.Addr(), 1, uintptr(unsafe.Pointer(&sysinfo)), 0, 0)
+ switch sysinfo.wProcessorArchitecture {
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ gohostarch = "amd64"
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ gohostarch = "386"
+ default:
+ fatal("unknown processor architecture")
+ }
+}