authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2024-04-20 13:11:15+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-22 15:27:05-07:00
logfefdbca6e62145a20777789961262f15c2bf6cbe
tree7d7a2e0a1cc8df16f740bf1101d5ce879f42bba2
parent5d745d94fbe30334ce0695cdf7118fb526313aed

Fix WASI threads, again

Properly call the entrypoint when it doesn't return an optional error, and use the per-thread copy of the arguments list.

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/Thread.zig+3-3
...@@ -844,19 +844,19 @@ const WasiThreadImpl = struct {...@@ -844,19 +844,19 @@ const WasiThreadImpl = struct {
844 const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'";844 const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'";
845 switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {845 switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {
846 .NoReturn, .Void => {846 .NoReturn, .Void => {
847 @call(.auto, w, args);847 @call(.auto, f, w.args);
848 },848 },
849 .Int => |info| {849 .Int => |info| {
850 if (info.bits != 8) {850 if (info.bits != 8) {
851 @compileError(bad_fn_ret);851 @compileError(bad_fn_ret);
852 }852 }
853 _ = @call(.auto, w, args); // WASI threads don't support exit status, ignore value853 _ = @call(.auto, f, w.args); // WASI threads don't support exit status, ignore value
854 },854 },
855 .ErrorUnion => |info| {855 .ErrorUnion => |info| {
856 if (info.payload != void) {856 if (info.payload != void) {
857 @compileError(bad_fn_ret);857 @compileError(bad_fn_ret);
858 }858 }
859 @call(.auto, f, args) catch |err| {859 @call(.auto, f, w.args) catch |err| {
860 std.debug.print("error: {s}\n", .{@errorName(err)});860 std.debug.print("error: {s}\n", .{@errorName(err)});
861 if (@errorReturnTrace()) |trace| {861 if (@errorReturnTrace()) |trace| {
862 std.debug.dumpStackTrace(trace.*);862 std.debug.dumpStackTrace(trace.*);