aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_windows_386.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_386.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_386.s')
-rw-r--r--src/runtime/sys_windows_386.s12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runtime/sys_windows_386.s b/src/runtime/sys_windows_386.s
index 35bc7a9aaa..128e8abd97 100644
--- a/src/runtime/sys_windows_386.s
+++ b/src/runtime/sys_windows_386.s
@@ -441,6 +441,8 @@ TEXT runtime·switchtothread(SB),NOSPLIT,$0
#define time_hi2 8
TEXT runtime·nanotime(SB),NOSPLIT,$0-8
+ CMPB runtime·useQPCTime(SB), $0
+ JNE useQPC
loop:
MOVL (_INTERRUPT_TIME+time_hi1), AX
MOVL (_INTERRUPT_TIME+time_lo), CX
@@ -459,8 +461,13 @@ loop:
MOVL AX, ret_lo+0(FP)
MOVL DX, ret_hi+4(FP)
RET
+useQPC:
+ JMP runtime·nanotimeQPC(SB)
+ RET
TEXT time·now(SB),NOSPLIT,$0-20
+ CMPB runtime·useQPCTime(SB), $0
+ JNE useQPC
loop:
MOVL (_INTERRUPT_TIME+time_hi1), AX
MOVL (_INTERRUPT_TIME+time_lo), CX
@@ -477,7 +484,7 @@ loop:
// w*100 = DX:AX
// subtract startNano and save for return
SUBL runtime·startNano+0(SB), AX
- SBBL runtime·startNano+4(SB), DX
+ SBBL runtime·startNano+4(SB), DX
MOVL AX, mono+12(FP)
MOVL DX, mono+16(FP)
@@ -532,3 +539,6 @@ wall:
MOVL AX, sec+0(FP)
MOVL DX, sec+4(FP)
RET
+useQPC:
+ JMP runtime·nowQPC(SB)
+ RET