]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: consolidate Windows time constants into single copy
authorIan Lance Taylor <iant@golang.org>
Tue, 27 Apr 2021 17:58:54 +0000 (10:58 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 28 Apr 2021 15:58:43 +0000 (15:58 +0000)
Change-Id: I1a583d3da9cca4ac51f3fec9b508b7638b452d60
Reviewed-on: https://go-review.googlesource.com/c/go/+/314270
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/sys_windows_386.s
src/runtime/sys_windows_amd64.s
src/runtime/sys_windows_arm.s
src/runtime/sys_windows_arm64.s
src/runtime/time_windows.h [new file with mode: 0644]

index d6b521ab659ceafb46136cf78390133bc1df9db8..d8b14eb644267dc6c19f1e5dd34c3ad9cba3b506 100644 (file)
@@ -5,6 +5,7 @@
 #include "go_asm.h"
 #include "go_tls.h"
 #include "textflag.h"
+#include "time_windows.h"
 
 // void runtime·asmstdcall(void *c);
 TEXT runtime·asmstdcall<ABIInternal>(SB),NOSPLIT,$0
@@ -331,16 +332,6 @@ TEXT runtime·switchtothread(SB),NOSPLIT,$0
        MOVL    BP, SP
        RET
 
-// See https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Archived copy at:
-// http://web.archive.org/web/20210411000829/https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Must read hi1, then lo, then hi2. The snapshot is valid if hi1 == hi2.
-#define _INTERRUPT_TIME 0x7ffe0008
-#define _SYSTEM_TIME 0x7ffe0014
-#define time_lo 0
-#define time_hi1 4
-#define time_hi2 8
-
 TEXT runtime·nanotime1(SB),NOSPLIT,$0-8
        CMPB    runtime·useQPCTime(SB), $0
        JNE     useQPC
index ed4456108406a156674ef7262eac17665c84d67d..868fd9d20f7a3f7fb432da0df0110452d06d3b23 100644 (file)
@@ -5,6 +5,7 @@
 #include "go_asm.h"
 #include "go_tls.h"
 #include "textflag.h"
+#include "time_windows.h"
 #include "cgo/abi_amd64.h"
 
 // maxargs should be divisible by 2, as Windows stack
@@ -341,16 +342,6 @@ TEXT runtime·switchtothread(SB),NOSPLIT|NOFRAME,$0
        MOVQ    32(SP), SP
        RET
 
-// See https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Archived copy at:
-// http://web.archive.org/web/20210411000829/https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Must read hi1, then lo, then hi2. The snapshot is valid if hi1 == hi2.
-#define _INTERRUPT_TIME 0x7ffe0008
-#define _SYSTEM_TIME 0x7ffe0014
-#define time_lo 0
-#define time_hi1 4
-#define time_hi2 8
-
 TEXT runtime·nanotime1(SB),NOSPLIT,$0-8
        CMPB    runtime·useQPCTime(SB), $0
        JNE     useQPC
index 6234203798031d02eff72606d684e1022d7bccef..7676bc1ff8c47564e34e0f7c4955415031ac10cc 100644 (file)
@@ -5,6 +5,7 @@
 #include "go_asm.h"
 #include "go_tls.h"
 #include "textflag.h"
+#include "time_windows.h"
 
 // Note: For system ABI, R0-R3 are args, R4-R11 are callee-save.
 
@@ -341,16 +342,6 @@ TEXT runtime·read_tls_fallback(SB),NOSPLIT|NOFRAME,$0
        MOVW    R0, (R0)
        RET
 
-// See https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Archived copy at:
-// http://web.archive.org/web/20210411000829/https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Must read hi1, then lo, then hi2. The snapshot is valid if hi1 == hi2.
-#define _INTERRUPT_TIME 0x7ffe0008
-#define _SYSTEM_TIME 0x7ffe0014
-#define time_lo 0
-#define time_hi1 4
-#define time_hi2 8
-
 TEXT runtime·nanotime1(SB),NOSPLIT|NOFRAME,$0-8
        MOVW    $0, R0
        MOVB    runtime·useQPCTime(SB), R0
index 9fce9a8158fea8a90b5d61b5de261ca76d1d5aae..aa9ea7ed980b3fb9806328dde71aeab9eb5b45ce 100644 (file)
@@ -6,6 +6,7 @@
 #include "go_tls.h"
 #include "textflag.h"
 #include "funcdata.h"
+#include "time_windows.h"
 
 // Offsets into Thread Environment Block (pointer in R18)
 #define TEB_error 0x68
@@ -407,16 +408,6 @@ TEXT runtime·switchtothread(SB),NOSPLIT,$16-0
        ADD     $16, RSP
        RET
 
-// See https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Archived copy at:
-// http://web.archive.org/web/20210411000829/https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
-// Must read hi1, then lo, then hi2. The snapshot is valid if hi1 == hi2.
-#define _INTERRUPT_TIME 0x7ffe0008
-#define _SYSTEM_TIME 0x7ffe0014
-#define time_lo 0
-#define time_hi1 4
-#define time_hi2 8
-
 TEXT runtime·nanotime1(SB),NOSPLIT|NOFRAME,$0-8
        MOVB    runtime·useQPCTime(SB), R0
        CMP     $0, R0
diff --git a/src/runtime/time_windows.h b/src/runtime/time_windows.h
new file mode 100644 (file)
index 0000000..cd16fd1
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2021 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.
+
+// Constants for fetching time values on Windows for use in asm code.
+
+// See https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
+// Archived copy at:
+// http://web.archive.org/web/20210411000829/https://wrkhpi.wordpress.com/2007/08/09/getting-os-information-the-kuser_shared_data-structure/
+
+// Must read hi1, then lo, then hi2. The snapshot is valid if hi1 == hi2.
+#define _INTERRUPT_TIME 0x7ffe0008
+#define _SYSTEM_TIME 0x7ffe0014
+#define time_lo 0
+#define time_hi1 4
+#define time_hi2 8