From 80404cc928c758f7063da42a0d68669998613969 Mon Sep 17 00:00:00 2001 From: xdBronch <51252236+xdBronch@users.noreply.github.com> Date: Tue, 4 Jul 2023 01:00:37 -0400 Subject: [PATCH] implement std.time.sleep for uefi --- lib/std/time.zig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/std/time.zig b/lib/std/time.zig index a60a0ef959..c078e97793 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -46,6 +46,14 @@ pub fn sleep(nanoseconds: u64) void { return; } + if (builtin.os.tag == .uefi) { + const boot_services = os.uefi.system_table.boot_services.?; + const us_from_ns = nanoseconds / ns_per_us; + const us = math.cast(usize, us_from_ns) orelse math.maxInt(usize); + _ = boot_services.stall(us); + return; + } + const s = nanoseconds / ns_per_s; const ns = nanoseconds % ns_per_s; std.os.nanosleep(s, ns);