mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
std.start: allow return uefi error union in main (#23425)
This commit is contained in:
parent
fa86e09fb3
commit
9720bade7a
@ -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.
|
||||
|
||||
@ -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'",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user