aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_windows_amd64.s
diff options
context:
space:
mode:
authorEvgeniy Polyakov <zbr@ioremap.net>2017-04-20 16:51:36 +0300
committerAlex Brainman <alex.brainman@gmail.com>2017-04-25 04:30:06 +0000
commit9f98e49825e38267dc5e91b827cb1db3291ff3bb (patch)
treee87b8929e6c25693bf5fe0bb6cbdd08b2cfb0e6d /src/runtime/sys_windows_amd64.s
parentb0472e225bddf7c7ba2b61f10339106719f25b7f (diff)
downloadgo-9f98e49825e38267dc5e91b827cb1db3291ff3bb.tar.xz
runtime: make time correctly update on Wine
Implemented low-level time system for windows on hardware (software), which does not support memory mapped _KSYSTEM_TIME page update. In particular this problem exists on Wine where _KSYSTEM_TIME only contains time at the start, and is never modified. On start we try to detect Wine and if it's so we fallback to GetSystemTimeAsFileTime() for current time and a monotonic timer based on QueryPerformanceCounter family of syscalls: https://msdn.microsoft.com/en-us/library/windows/desktop/dn553408(v=vs.85).aspx Fixes #18537 Change-Id: I269d22467ed9b0afb62056974d23e731b80c83ed Reviewed-on: https://go-review.googlesource.com/35710 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/sys_windows_amd64.s')
-rw-r--r--src/runtime/sys_windows_amd64.s10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/runtime/sys_windows_amd64.s b/src/runtime/sys_windows_amd64.s
index 898aadfcf4..744e78c708 100644
--- a/src/runtime/sys_windows_amd64.s
+++ b/src/runtime/sys_windows_amd64.s
@@ -474,6 +474,8 @@ TEXT runtime·switchtothread(SB),NOSPLIT|NOFRAME,$0
#define time_hi2 8
TEXT runtime·nanotime(SB),NOSPLIT,$0-8
+ CMPB runtime·useQPCTime(SB), $0
+ JNE useQPC
MOVQ $_INTERRUPT_TIME, DI
loop:
MOVL time_hi1(DI), AX
@@ -487,8 +489,13 @@ loop:
SUBQ runtime·startNano(SB), CX
MOVQ CX, ret+0(FP)
RET
+useQPC:
+ JMP runtime·nanotimeQPC(SB)
+ RET
TEXT time·now(SB),NOSPLIT,$0-24
+ CMPB runtime·useQPCTime(SB), $0
+ JNE useQPC
MOVQ $_INTERRUPT_TIME, DI
loop:
MOVL time_hi1(DI), AX
@@ -529,3 +536,6 @@ wall:
SUBQ DX, CX
MOVL CX, nsec+8(FP)
RET
+useQPC:
+ JMP runtime·nowQPC(SB)
+ RET