authorgravatar for carmen@dotcarmen.devCarmen <carmen@dotcarmen.dev> 2025-04-01 10:10:10-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-04-01 17:10:10+00:00
log9720bade7a0165d4e6dc7bf4fafb895f2e458a3b
tree87013145d3ad782a6387800ed334db5d02e495d3
parentfa86e09fb39c8007c7b63e70ed7db1afc7022476
signaturebadge-check Signed by PGP key B5690EEEBB952194

std.start: allow return uefi error union in main (#23425)


2 files changed, 16 insertions(+), 4 deletions(-)

lib/std/os/uefi.zig+1
...@@ -7,6 +7,7 @@ pub const hii = @import("uefi/hii.zig");...@@ -7,6 +7,7 @@ pub const hii = @import("uefi/hii.zig");
77
8/// Status codes returned by EFI interfaces8/// Status codes returned by EFI interfaces
9pub const Status = @import("uefi/status.zig").Status;9pub const Status = @import("uefi/status.zig").Status;
10pub const Error = UnexpectedError || Status.Error;
10pub const tables = @import("uefi/tables.zig");11pub const tables = @import("uefi/tables.zig");
1112
12/// The memory type to allocate when using the pool.13/// The memory type to allocate when using the pool.
lib/std/start.zig+15-4
...@@ -211,13 +211,24 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv...@@ -211,13 +211,24 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
211 root.main();211 root.main();
212 return 0;212 return 0;
213 },213 },
214 usize => {
215 return root.main();
216 },
217 uefi.Status => {214 uefi.Status => {
218 return @intFromEnum(root.main());215 return @intFromEnum(root.main());
219 },216 },
220 else => @compileError("expected return type of main to be 'void', 'noreturn', 'usize', or 'std.os.uefi.Status'"),217 uefi.Error!void => {
218 root.main() catch |err| switch (err) {
219 error.Unexpected => @panic("EfiMain: unexpected error"),
220 else => {
221 const status = uefi.Status.fromError(@errorCast(err));
222 return @intFromEnum(status);
223 },
224 };
225
226 return 0;
227 },
228 else => @compileError(
229 "expected return type of main to be 'void', 'noreturn', " ++
230 "'uefi.Status', or 'uefi.Error!void'",
231 ),
221 }232 }
222}233}
223234