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

This commit is contained in:
Carmen 2025-04-01 10:10:10 -07:00 committed by GitHub
parent fa86e09fb3
commit 9720bade7a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 4 deletions

View File

@ -7,6 +7,7 @@ pub const hii = @import("uefi/hii.zig");
/// Status codes returned by EFI interfaces
pub const Status = @import("uefi/status.zig").Status;
pub const Error = UnexpectedError || Status.Error;
pub const tables = @import("uefi/tables.zig");
/// The memory type to allocate when using the pool.

View File

@ -211,13 +211,24 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
root.main();
return 0;
},
usize => {
return root.main();
},
uefi.Status => {
return @intFromEnum(root.main());
},
else => @compileError("expected return type of main to be 'void', 'noreturn', 'usize', or 'std.os.uefi.Status'"),
uefi.Error!void => {
root.main() catch |err| switch (err) {
error.Unexpected => @panic("EfiMain: unexpected error"),
else => {
const status = uefi.Status.fromError(@errorCast(err));
return @intFromEnum(status);
},
};
return 0;
},
else => @compileError(
"expected return type of main to be 'void', 'noreturn', " ++
"'uefi.Status', or 'uefi.Error!void'",
),
}
}