Inspired by a patch by Andrew Eikum.
macOS's mach_absolute_time() stops counting when the computer goes to
sleep/suspend/hibernate/etc. However, Windows's GetTickCount() does not
stop counting. mach_continuous_time() matches Windows's behavior.
BSD's CLOCK_MONOTONIC already counts asleep time.
Unfortunately, there is no clock source on Linux which does exactly what
we want. CLOCK_MONOTONIC_RAW is unaffected by NTP adjustment, but like
mach_absolute_time() doesn't keep ticking when the computer is asleep.
CLOCK_BOOTTIME does keep ticking, but it is affected by NTP adjustments.
CLOCK_MONOTONIC has both problems. What's needed is a
CLOCK_BOOTTIME_RAW, which would not be slewed by adjtimex(2) and would
count time spent asleep.
To avoid issues with skew and performance, this patch falls back to
mach_absolute_time() on macOS if mach_continuous_time() is unavailable.
Note that mach_continuous_time() was introduced in macOS 10.12, meaning
that if the minimum version required is less than that, it will be
linked weakly. Therefore we must check that it is nonnull before
attempting to call it.
Signed-off-by: Chip Davis <cdavis@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Marking the function as DECLSPEC_HOTPATCH to avoid reopening
https://bugs.winehq.org/show_bug.cgi?id=36486 . Even with -fno-PIC,
without DECLSPEC_HOTPATCH the generated code has a pushl at offset 7
that triggers the failure.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This will only affect users running with HZ=1000. On an i7-8700 CPU @
3.20GHz it cuts the call cost from ~30ns to ~12ns.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Without this change, for Japan, Wine returns "Korea Standard Time",
not "Tokyo Standard Time" as seen in Bug 42719.
Actually, this is a regression by d666143f88.
The new code relies on offsets from UTC and DST change timings. However,
Northeast Asia regions don't use daylight saving time. Thus, Wine can't
distinguish between these regions.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
The problem is building against the 10.12 or later SDK but deploying to 10.11
or earlier. Support for clock_gettime() is new with 10.12 so configure finds
it and the code uses it, but the symbol is weak linked and resolves to NULL
when running on earlier versions.
Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
When there are no further time changes, the function find_dst_change() will
return (year_end + 1). This patch ensures that we don't lookup the wrong
DynamicDST entry in such a case.