From b6379f190b3820c2765c7589c1fd6292e5581407 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 27 Jan 2021 11:39:48 -0500 Subject: [PATCH] syscall: clean up windows a bit The files being deleted contain no code. They exist because back when we used Makefiles that listed all the Go sources to be compiled, we wrote patterns like syscall_$GOOS_$GOARCH.go, and it was easier to create dummy empty files than introduce conditionals to not look for that file on Windows. Now that we have the go command instead, we don't need those dummy files. This CL is part of a stack adding windows/arm64 support (#36439), intended to land in the Go 1.17 cycle. This CL is, however, not windows/arm64-specific. It is cleanup meant to make the port (and future ports) easier. Change-Id: Ie0066d1dd2bf09802c74c6a496276e8c593e4bc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/288815 Trust: Russ Cox Trust: Jason A. Donenfeld Reviewed-by: Alex Brainman Reviewed-by: Cherry Zhang Reviewed-by: Jason A. Donenfeld --- src/syscall/syscall_windows.go | 27 +++++++++++++++------------ src/syscall/syscall_windows_386.go | 5 ----- src/syscall/syscall_windows_amd64.go | 5 ----- src/syscall/zerrors_windows_386.go | 5 ----- src/syscall/zerrors_windows_amd64.go | 5 ----- src/syscall/zsysnum_windows_386.go | 3 --- src/syscall/zsysnum_windows_amd64.go | 3 --- 7 files changed, 15 insertions(+), 38 deletions(-) delete mode 100644 src/syscall/syscall_windows_386.go delete mode 100644 src/syscall/syscall_windows_amd64.go delete mode 100644 src/syscall/zerrors_windows_386.go delete mode 100644 src/syscall/zerrors_windows_amd64.go delete mode 100644 src/syscall/zsysnum_windows_386.go delete mode 100644 src/syscall/zsysnum_windows_amd64.go diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go index ba69133d81..4a576486d1 100644 --- a/src/syscall/syscall_windows.go +++ b/src/syscall/syscall_windows.go @@ -414,19 +414,22 @@ const ptrSize = unsafe.Sizeof(uintptr(0)) // See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365542(v=vs.85).aspx func setFilePointerEx(handle Handle, distToMove int64, newFilePointer *int64, whence uint32) error { var e1 Errno - switch runtime.GOARCH { - default: - panic("unsupported architecture") - case "amd64": + if unsafe.Sizeof(uintptr(0)) == 8 { _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 4, uintptr(handle), uintptr(distToMove), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence), 0, 0) - case "386": - // distToMove is a LARGE_INTEGER: - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v=vs.85).aspx - _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 5, uintptr(handle), uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence), 0) - case "arm": - // distToMove must be 8-byte aligned per ARM calling convention - // https://msdn.microsoft.com/en-us/library/dn736986.aspx#Anchor_7 - _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 6, uintptr(handle), 0, uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence)) + } else { + // Different 32-bit systems disgaree about whether distToMove starts 8-byte aligned. + switch runtime.GOARCH { + default: + panic("unsupported 32-bit architecture") + case "386": + // distToMove is a LARGE_INTEGER: + // https://msdn.microsoft.com/en-us/library/windows/desktop/aa383713(v=vs.85).aspx + _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 5, uintptr(handle), uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence), 0) + case "arm": + // distToMove must be 8-byte aligned per ARM calling convention + // https://msdn.microsoft.com/en-us/library/dn736986.aspx#Anchor_7 + _, _, e1 = Syscall6(procSetFilePointerEx.Addr(), 6, uintptr(handle), 0, uintptr(distToMove), uintptr(distToMove>>32), uintptr(unsafe.Pointer(newFilePointer)), uintptr(whence)) + } } if e1 != 0 { return errnoErr(e1) diff --git a/src/syscall/syscall_windows_386.go b/src/syscall/syscall_windows_386.go deleted file mode 100644 index e82b540b4b..0000000000 --- a/src/syscall/syscall_windows_386.go +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2009 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 syscall diff --git a/src/syscall/syscall_windows_amd64.go b/src/syscall/syscall_windows_amd64.go deleted file mode 100644 index e82b540b4b..0000000000 --- a/src/syscall/syscall_windows_amd64.go +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2009 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 syscall diff --git a/src/syscall/zerrors_windows_386.go b/src/syscall/zerrors_windows_386.go deleted file mode 100644 index 8bc5b6b194..0000000000 --- a/src/syscall/zerrors_windows_386.go +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2011 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 syscall diff --git a/src/syscall/zerrors_windows_amd64.go b/src/syscall/zerrors_windows_amd64.go deleted file mode 100644 index 8bc5b6b194..0000000000 --- a/src/syscall/zerrors_windows_amd64.go +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2011 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 syscall diff --git a/src/syscall/zsysnum_windows_386.go b/src/syscall/zsysnum_windows_386.go deleted file mode 100644 index 36bf065d1f..0000000000 --- a/src/syscall/zsysnum_windows_386.go +++ /dev/null @@ -1,3 +0,0 @@ -// nothing to see here - -package syscall diff --git a/src/syscall/zsysnum_windows_amd64.go b/src/syscall/zsysnum_windows_amd64.go deleted file mode 100644 index 36bf065d1f..0000000000 --- a/src/syscall/zsysnum_windows_amd64.go +++ /dev/null @@ -1,3 +0,0 @@ -// nothing to see here - -package syscall