Skip to content

Commit 5c974c4

Browse files
committed
TimerQueue: fix windows support
1 parent 5618282 commit 5c974c4

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/minilib/TimerQueue.zig

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,10 @@ fn now(clock: Clock) !u128 {
8686
break :D result;
8787
},
8888
.realtime => D: {
89-
// FileTime has a granularity of 100 nanoseconds and uses the NTFS/Windows epoch,
89+
// RtlGetSystemTimePrecise() has a granularity of 100 nanoseconds and uses the NTFS/Windows epoch,
9090
// which is 1601-01-01.
9191
const epoch_adj = std.time.epoch.windows * (std.time.ns_per_s / 100);
92-
var ft: std.os.windows.FILETIME = undefined;
93-
std.os.windows.kernel32.GetSystemTimeAsFileTime(&ft);
94-
const ft64 = (@as(u64, ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
95-
const adjusted = @as(i64, @bitCast(ft64)) + epoch_adj;
96-
std.debug.assert(adjusted > 0);
97-
break :D @as(u128, @intCast(adjusted)) * 100;
92+
break :D @intCast(@as(i128, std.os.windows.ntdll.RtlGetSystemTimePrecise() + epoch_adj) * 100);
9893
},
9994
},
10095
.uefi => D: {

0 commit comments

Comments
 (0)