Skip to content

Commit

Permalink
minilib: TimerQueue: add uefi nows
Browse files Browse the repository at this point in the history
Uefi really isn't supported as TimerQueue requires threads, but maybe
someone somedays makes std.Thread implementation using uefi services
  • Loading branch information
Cloudef committed Jul 7, 2024
1 parent 36b985a commit b5a4073
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/minilib/TimerQueue.zig
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ const MonotonicQueue = struct {
const result = (@as(u96, qpc) * scale) >> 32;
return result;
},
.uefi => {
var value: std.os.uefi.Time = undefined;
std.debug.assert(std.os.uefi.system_table.runtime_services.getTime(&value, null) == .Success);
return value.toEpoch();
},
.wasi => {
var ns: std.os.wasi.timestamp_t = undefined;
const rc = std.os.wasi.clock_time_get(.MONOTONIC, 1, &ns);
Expand All @@ -177,7 +182,6 @@ const MonotonicQueue = struct {
},
.macos, .ios, .tvos, .watchos, .visionos => std.posix.CLOCK.UPTIME_RAW,
.linux => std.posix.CLOCK.MONOTONIC,
.uefi => @compileError("unsupported"),
else => std.posix.CLOCK.BOOTTIME,
};
var ts: std.posix.timespec = undefined;
Expand Down Expand Up @@ -222,6 +226,11 @@ const BoottimeQueue = struct {
const result = (@as(u96, qpc) * scale) >> 32;
return result;
},
.uefi => {
var value: std.os.uefi.Time = undefined;
std.debug.assert(std.os.uefi.system_table.runtime_services.getTime(&value, null) == .Success);
return value.toEpoch();
},
.wasi => {
var ns: std.os.wasi.timestamp_t = undefined;
const rc = std.os.wasi.clock_time_get(.MONOTONIC, 1, &ns);
Expand All @@ -230,7 +239,6 @@ const BoottimeQueue = struct {
},
.macos, .ios, .tvos, .watchos, .visionos => std.posix.CLOCK.MONOTONIC_RAW,
.linux => std.posix.CLOCK.BOOTTIME,
.uefi => @compileError("unsupported"),
else => std.posix.CLOCK.MONOTONIC,
};
var ts: std.posix.timespec = undefined;
Expand Down

0 comments on commit b5a4073

Please sign in to comment.