aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartin Wickham <spexguy070@gmail.com>2021-09-01 14:32:02 -0500
committerMartin Wickham <spexguy070@gmail.com>2021-09-22 13:58:49 -0500
commitd6e87da47b61ac31fe93a212d4f47eae55fec492 (patch)
treed57a5ef5d791385d9b55072f338735a79c8f5ba4 /lib
parent3b09262c1252de0d9f946630e701be65bc5b2fc7 (diff)
downloadzig-d6e87da47b61ac31fe93a212d4f47eae55fec492.tar.gz
zig-d6e87da47b61ac31fe93a212d4f47eae55fec492.zip
Make stage2 start.zig work on Windows
Diffstat (limited to 'lib')
-rw-r--r--lib/std/start.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig
index 057fde62f6..9e561df5ec 100644
--- 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(