windows: port to ARM64

This also fixes up some spaces->tabs issues and moves build tags from
the file contents to the file name.

Updates golang/go#36439.

Change-Id: Iafa03e26575603a802832e587bb18ebd16fd176b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/289449
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/windows/svc/sys_386.s b/windows/svc/sys_windows_386.s
similarity index 98%
rename from windows/svc/sys_386.s
rename to windows/svc/sys_windows_386.s
index c8a583d..1ed9141 100644
--- a/windows/svc/sys_386.s
+++ b/windows/svc/sys_windows_386.s
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build windows
-
 // func servicemain(argc uint32, argv **uint16)
 TEXT ·servicemain(SB),7,$0
 	MOVL	argc+0(FP), AX
diff --git a/windows/svc/sys_amd64.s b/windows/svc/sys_windows_amd64.s
similarity index 98%
rename from windows/svc/sys_amd64.s
rename to windows/svc/sys_windows_amd64.s
index 3d4df0c..1e5ef92 100644
--- a/windows/svc/sys_amd64.s
+++ b/windows/svc/sys_windows_amd64.s
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build windows
-
 // func servicemain(argc uint32, argv **uint16)
 TEXT ·servicemain(SB),7,$0
 	MOVQ	SP, AX
diff --git a/windows/svc/sys_arm.s b/windows/svc/sys_windows_arm.s
similarity index 82%
rename from windows/svc/sys_arm.s
rename to windows/svc/sys_windows_arm.s
index 33c692a..360b86e 100644
--- a/windows/svc/sys_arm.s
+++ b/windows/svc/sys_windows_arm.s
@@ -2,15 +2,13 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build windows
-
 #include "textflag.h"
 
 // func servicemain(argc uint32, argv **uint16)
 TEXT ·servicemain(SB),NOSPLIT|NOFRAME,$0
 	MOVM.DB.W [R4, R14], (R13)	// push {r4, lr}
-	MOVW    R13, R4
-	BIC     $0x7, R13		// alignment for ABI
+	MOVW	R13, R4
+	BIC	$0x7, R13		// alignment for ABI
 
 	MOVW	R0, ·sArgc(SB)
 	MOVW	R1, ·sArgv(SB)
@@ -19,19 +17,19 @@
 	MOVW	·ctlHandlerExProc(SB), R1
 	MOVW	$0, R2
 	MOVW	·cRegisterServiceCtrlHandlerExW(SB), R3
-	BL      (R3)
-	CMP     $0, R0
-	BEQ     exit
+	BL	(R3)
+	CMP	$0, R0
+	BEQ	exit
 	MOVW	R0, ·ssHandle(SB)
 
 	MOVW	·goWaitsH(SB), R0
 	MOVW	·cSetEvent(SB), R1
-	BL      (R1)
+	BL	(R1)
 
 	MOVW	·cWaitsH(SB), R0
 	MOVW	$-1, R1
 	MOVW	·cWaitForSingleObject(SB), R2
-	BL      (R2)
+	BL	(R2)
 
 exit:
 	MOVW	R4, R13			// free extra stack space
diff --git a/windows/svc/sys_windows_arm64.s b/windows/svc/sys_windows_arm64.s
new file mode 100644
index 0000000..3ca540e
--- /dev/null
+++ b/windows/svc/sys_windows_arm64.s
@@ -0,0 +1,31 @@
+// Copyright 2018 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.
+
+#include "textflag.h"
+
+// func servicemain(argc uint32, argv **uint16)
+TEXT ·servicemain(SB),NOSPLIT|NOFRAME,$0
+	MOVD	R0, ·sArgc(SB)
+	MOVD	R1, ·sArgv(SB)
+
+	MOVD	·sName(SB), R0
+	MOVD	·ctlHandlerExProc(SB), R1
+	MOVD	$0, R2
+	MOVD	·cRegisterServiceCtrlHandlerExW(SB), R3
+	BL	(R3)
+	CMP	$0, R0
+	BEQ	exit
+	MOVD	R0, ·ssHandle(SB)
+
+	MOVD	·goWaitsH(SB), R0
+	MOVD	·cSetEvent(SB), R1
+	BL	(R1)
+
+	MOVD	·cWaitsH(SB), R0
+	MOVD	$-1, R1
+	MOVD	·cWaitForSingleObject(SB), R2
+	BL	(R2)
+
+exit:
+	RET
diff --git a/windows/types_windows_arm64.go b/windows/types_windows_arm64.go
new file mode 100644
index 0000000..fdddc0c
--- /dev/null
+++ b/windows/types_windows_arm64.go
@@ -0,0 +1,34 @@
+// 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 windows
+
+type WSAData struct {
+	Version      uint16
+	HighVersion  uint16
+	MaxSockets   uint16
+	MaxUdpDg     uint16
+	VendorInfo   *byte
+	Description  [WSADESCRIPTION_LEN + 1]byte
+	SystemStatus [WSASYS_STATUS_LEN + 1]byte
+}
+
+type Servent struct {
+	Name    *byte
+	Aliases **byte
+	Proto   *byte
+	Port    uint16
+}
+
+type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
+	PerProcessUserTimeLimit int64
+	PerJobUserTimeLimit     int64
+	LimitFlags              uint32
+	MinimumWorkingSetSize   uintptr
+	MaximumWorkingSetSize   uintptr
+	ActiveProcessLimit      uint32
+	Affinity                uintptr
+	PriorityClass           uint32
+	SchedulingClass         uint32
+}