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 {
10181018 return .{ .thread = &instance.thread };
10191019 }
10201020
1021 /// Bootstrap procedure, called by the host environment after thread creation.
1022 export fn wasi_thread_start(tid: i32, arg: *Instance) void {
1023 if (builtin.single_threaded) {
1024 // ensure function is not analyzed in single-threaded mode
1025 return;
1021 comptime {
1022 if (!builtin.single_threaded) {
1023 @export(wasi_thread_start, .{ .name = "wasi_thread_start" });
10261024 }
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);
10271030 __set_stack_pointer(arg.thread.memory.ptr + arg.stack_offset);
10281031 __wasm_init_tls(arg.thread.memory.ptr + arg.tls_offset);
10291032 @atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .seq_cst);