Zebediah Figura : server: Fill the TimeZoneBias member of KSHARED_USER_DATA.

Alexandre Julliard julliard at winehq.org
Mon Sep 6 16:15:04 CDT 2021


Module: wine
Branch: master
Commit: dd9eacff4ea2c9eff9f4b8a368bb680df86df9bb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=dd9eacff4ea2c9eff9f4b8a368bb680df86df9bb

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Fri Sep  3 16:15:27 2021 -0500

server: Fill the TimeZoneBias member of KSHARED_USER_DATA.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/time.c |  8 ++++++++
 server/fd.c             | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/dlls/ntdll/tests/time.c b/dlls/ntdll/tests/time.c
index 7ea506337a4..549db5b22b6 100644
--- a/dlls/ntdll/tests/time.c
+++ b/dlls/ntdll/tests/time.c
@@ -410,7 +410,9 @@ static ULONGLONG read_ksystem_time(volatile KSYSTEM_TIME *time)
 static void test_user_shared_data_time(void)
 {
     KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000;
+    SYSTEM_TIMEOFDAY_INFORMATION timeofday;
     ULONGLONG t1, t2, t3;
+    NTSTATUS status;
     int i = 0;
 
     i = 0;
@@ -464,6 +466,12 @@ static void test_user_shared_data_time(void)
         ok(t2 <= t3, "USD InterruptTime / RtlQueryUnbiasedInterruptTime are out of order %s %s\n",
            wine_dbgstr_longlong(t2), wine_dbgstr_longlong(t3));
     }
+
+    t1 = read_ksystem_time(&user_shared_data->TimeZoneBias);
+    status = NtQuerySystemInformation(SystemTimeOfDayInformation, &timeofday, sizeof(timeofday), NULL);
+    ok(!status, "failed to query time of day, status %#x\n", status);
+    ok(timeofday.TimeZoneBias.QuadPart == t1, "got USD bias %I64u, ntdll bias %I64u\n",
+            t1, timeofday.TimeZoneBias.QuadPart);
 }
 
 START_TEST(time)
diff --git a/server/fd.c b/server/fd.c
index 8ef01e0ce40..01185429244 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -410,6 +410,26 @@ static void atomic_store_long(volatile LONG *ptr, LONG value)
 static void set_user_shared_data_time(void)
 {
     timeout_t tick_count = monotonic_time / 10000;
+    static timeout_t last_timezone_update;
+    timeout_t timezone_bias;
+    struct tm *tm;
+    time_t now;
+
+    if (monotonic_time - last_timezone_update > TICKS_PER_SEC)
+    {
+        now = time( NULL );
+        tm = gmtime( &now );
+        timezone_bias = mktime( tm ) - now;
+        tm = localtime( &now );
+        if (tm->tm_isdst) timezone_bias -= 3600;
+        timezone_bias *= TICKS_PER_SEC;
+
+        atomic_store_long(&user_shared_data->TimeZoneBias.High2Time, timezone_bias >> 32);
+        atomic_store_ulong(&user_shared_data->TimeZoneBias.LowPart, timezone_bias);
+        atomic_store_long(&user_shared_data->TimeZoneBias.High1Time, timezone_bias >> 32);
+
+        last_timezone_update = monotonic_time;
+    }
 
     atomic_store_long(&user_shared_data->SystemTime.High2Time, current_time >> 32);
     atomic_store_ulong(&user_shared_data->SystemTime.LowPart, current_time);




More information about the wine-cvs mailing list