Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows: resync the VM time when the system clock gets changed #588

Merged
merged 3 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions platforms/win32/vm/sqWin32Heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ ioInitTime(void)
utcStartMicroseconds = utcMicrosecondClock;
}

void resyncSystemTime() {
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
// Nothing to be done, time will be resynced upon every heartbeat tick
#else // (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
// By setting these values to maximum, currentUTCMicroseconds() will resync to the system time.
lastTick = (DWORD)-1;
vmThreadLastTick = (DWORD)-1;
#endif
ioUpdateVMTimezone();
}

unsigned long long
ioUTCMicroseconds() { return get64(utcMicrosecondClock); }

Expand Down
4 changes: 4 additions & 0 deletions platforms/win32/vm/sqWin32Window.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ MainWndProcW(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KILLFOCUS:
fHasFocus = 0;
return DefWindowProcW(hwnd,message,wParam,lParam);

case WM_TIMECHANGE:
resyncSystemTime();

LinqLover marked this conversation as resolved.
Show resolved Hide resolved
default:
/* Unprocessed messages may be processed outside the current
module. If firstMessageHook is non-NULL and returns a non
Expand Down