[PATCH v3 0/1] MR8916: ntdll: Switch to CLOCK_BOOTTIME for monotonic counters on Linux.
This now accounts for system suspend periods on Linux, similar to how native win32 ticks work. On macOS `mach_continuous_time` already does so. ~~On BSDs (and other POSIX compliant operating systems) `CLOCK_MONOTONIC` likewise includes suspend time. However they also provide a `CLOCK_BOOTTIME`, which does *not* include suspend time, hence the added `__linux__` check there.~~ See https://lkml.org/lkml/2020/5/8/1707 -- v3: ntdll: Switch to CLOCK_BOOTTIME for monotonic counters when available. https://gitlab.winehq.org/wine/wine/-/merge_requests/8916
From: Marc-Aurel Zent <mzent(a)codeweavers.com> This now accounts for system suspend periods. See https://lkml.org/lkml/2020/5/8/1707 --- dlls/ntdll/unix/sync.c | 4 ++-- server/request.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index 1660478b0e1..bcd06f8338b 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -97,8 +97,8 @@ static inline ULONGLONG monotonic_counter(void) return mach_continuous_time() * timebase.numer / timebase.denom / 100; #elif defined(HAVE_CLOCK_GETTIME) struct timespec ts; -#ifdef CLOCK_MONOTONIC_RAW - if (!clock_gettime( CLOCK_MONOTONIC_RAW, &ts )) +#ifdef CLOCK_BOOTTIME + if (!clock_gettime( CLOCK_BOOTTIME, &ts )) return ts.tv_sec * (ULONGLONG)TICKSPERSEC + ts.tv_nsec / 100; #endif if (!clock_gettime( CLOCK_MONOTONIC, &ts )) diff --git a/server/request.c b/server/request.c index 835ea30cec3..432a5918892 100644 --- a/server/request.c +++ b/server/request.c @@ -515,8 +515,8 @@ timeout_t monotonic_counter(void) return mach_continuous_time() * timebase.numer / timebase.denom / 100; #elif defined(HAVE_CLOCK_GETTIME) struct timespec ts; -#ifdef CLOCK_MONOTONIC_RAW - if (!clock_gettime( CLOCK_MONOTONIC_RAW, &ts )) +#ifdef CLOCK_BOOTTIME + if (!clock_gettime( CLOCK_BOOTTIME, &ts )) return (timeout_t)ts.tv_sec * TICKS_PER_SEC + ts.tv_nsec / 100; #endif if (!clock_gettime( CLOCK_MONOTONIC, &ts )) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8916
participants (2)
-
Marc-Aurel Zent -
Marc-Aurel Zent (@mzent)