Commit 80404cc928

xdBronch <51252236+xdBronch@users.noreply.github.com>
2023-07-04 07:00:37
implement std.time.sleep for uefi
1 parent 2e424e0
Changed files (1)
lib
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);