zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d6e87da47b61ac31fe93a212d4f47eae55fec492 (tree)
parent 3b09262c1252de0d9f946630e701be65bc5b2fc7
Author: Martin Wickham <spexguy070@gmail.com>
Date:   Wed,  1 Sep 2021 14:32:02 -0500

Make stage2 start.zig work on Windows

Diffstat:
Mlib/std/start.zig | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/lib/std/start.zig b/lib/std/start.zig @@ -28,6 +28,8 @@ comptime { if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) { @export(main2, .{ .name = "main" }); } + } else if (builtin.stage2_os == .windows) { + @export(wWinMainCRTStartup2, .{ .name = "wWinMainCRTStartup" }); } else { if (!@hasDecl(root, "_start")) { @export(_start2, .{ .name = "_start" }); @@ -96,6 +98,11 @@ fn callMain2() noreturn { exit2(0); } +fn wWinMainCRTStartup2() callconv(.C) noreturn { + root.main(); + exit2(0); +} + fn exit2(code: usize) noreturn { switch (native_os) { .linux => switch (builtin.stage2_arch) { @@ -148,11 +155,16 @@ fn exit2(code: usize) noreturn { }, else => @compileError("TODO"), }, + .windows => { + ExitProcess(@truncate(u32, code)); + }, else => @compileError("TODO"), } unreachable; } +extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn; + //////////////////////////////////////////////////////////////////////////////// fn _DllMainCRTStartup(