diff options
| author | vnc5 <vnc5@users.noreply.github.com> | 2021-10-09 14:04:16 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-01-27 19:49:12 +0200 |
| commit | 1adb6440db30e5906f685ca5c188ce87bbe0d475 (patch) | |
| tree | bd51aebeed4e91335798ead06c57f62a7f088888 /lib | |
| parent | 80ac022c4667e1995ccdf70fff90e5af26b6eb97 (diff) | |
| download | zig-1adb6440db30e5906f685ca5c188ce87bbe0d475.tar.gz zig-1adb6440db30e5906f685ca5c188ce87bbe0d475.zip | |
fix startup procedure for async WinMain
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/start.zig | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 29b254c0f9..a3cc3d00a8 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -511,9 +511,9 @@ inline fn initEventLoopAndCallWinMain() std.os.windows.INT { }; defer loop.deinit(); - var result: u8 = undefined; - var frame: @Frame(callMainAsync) = undefined; - _ = @asyncCall(&frame, &result, callMainAsync, .{loop}); + var result: std.os.windows.INT = undefined; + var frame: @Frame(callWinMainAsync) = undefined; + _ = @asyncCall(&frame, &result, callWinMainAsync, .{loop}); loop.run(); return result; } @@ -532,6 +532,14 @@ fn callMainAsync(loop: *std.event.Loop) callconv(.Async) u8 { return callMain(); } +fn callWinMainAsync(loop: *std.event.Loop) callconv(.Async) std.os.windows.INT { + // This prevents the event loop from terminating at least until main() has returned. + // TODO This shouldn't be needed here; it should be in the event loop code. + loop.beginOneEvent(); + defer loop.finishOneEvent(); + return call_wWinMain(); +} + // This is not marked inline because it is called with @asyncCall when // there is an event loop. pub fn callMain() u8 { |
