Save/Restore the guest clock in XThreads

This commit is contained in:
Dr. Chat
2015-12-12 16:44:59 -06:00
committed by Ben Vanik
parent adec5602c2
commit 44c9e8fe25
3 changed files with 35 additions and 2 deletions

View File

@@ -84,6 +84,16 @@ uint32_t Clock::QueryGuestUptimeMillis() {
return result;
}
void Clock::SetGuestTickCount(uint64_t tick_count) {
last_host_tick_count_ = Clock::QueryHostTickCount();
guest_tick_count_ = tick_count;
}
void Clock::SetGuestSystemTime(uint64_t system_time) {
last_host_tick_count_ = Clock::QueryHostTickCount();
guest_time_filetime_ = system_time - guest_system_time_base_;
}
uint32_t Clock::ScaleGuestDurationMillis(uint32_t guest_ms) {
if (guest_ms == UINT_MAX) {
return UINT_MAX;

View File

@@ -47,6 +47,11 @@ class Clock {
// Queries the milliseconds since the guest began, accounting for scaling.
static uint32_t QueryGuestUptimeMillis();
// Sets the guest tick count for the current thread.
static void SetGuestTickCount(uint64_t tick_count);
// Sets the system time for the current thread.
static void SetGuestSystemTime(uint64_t system_time);
// Scales a time duration in milliseconds, from guest time.
static uint32_t ScaleGuestDurationMillis(uint32_t guest_ms);
// Scales a time duration in 100ns ticks like FILETIME, from guest time.