authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-15 20:51:46-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:35-08:00
log70414c1f434dea4d749f1d1445816dffc88a7a68
tree2e154331fe66b74c5ec59b037491600a5ea5d859
parent0555fe8d5b026c8544c62acde83e9d3b1f6c01b8

std.Thread: don't export wasi_thread_start in single-threaded mode


1 files changed, 8 insertions(+), 5 deletions(-)

lib/std/Thread.zig+8-5
...@@ -1018,12 +1018,15 @@ const WasiThreadImpl = struct {...@@ -1018,12 +1018,15 @@ const WasiThreadImpl = struct {
1018 return .{ .thread = &instance.thread };1018 return .{ .thread = &instance.thread };
1019 }1019 }
10201020
1021 /// Bootstrap procedure, called by the host environment after thread creation.1021 comptime {
1022 export fn wasi_thread_start(tid: i32, arg: *Instance) void {1022 if (!builtin.single_threaded) {
1023 if (builtin.single_threaded) {1023 @export(wasi_thread_start, .{ .name = "wasi_thread_start" });
1024 // ensure function is not analyzed in single-threaded mode
1025 return;
1026 }1024 }
1025 }
1026
1027 /// Called by the host environment after thread creation.
1028 fn wasi_thread_start(tid: i32, arg: *Instance) callconv(.c) void {
1029 comptime assert(!builtin.single_threaded);
1027 __set_stack_pointer(arg.thread.memory.ptr + arg.stack_offset);1030 __set_stack_pointer(arg.thread.memory.ptr + arg.stack_offset);
1028 __wasm_init_tls(arg.thread.memory.ptr + arg.tls_offset);1031 __wasm_init_tls(arg.thread.memory.ptr + arg.tls_offset);
1029 @atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .seq_cst);1032 @atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .seq_cst);