diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-12-15 20:51:46 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 15:11:35 -0800 |
| commit | 70414c1f434dea4d749f1d1445816dffc88a7a68 (patch) | |
| tree | 2e154331fe66b74c5ec59b037491600a5ea5d859 /lib/std | |
| parent | 0555fe8d5b026c8544c62acde83e9d3b1f6c01b8 (diff) | |
| download | zig-70414c1f434dea4d749f1d1445816dffc88a7a68.tar.gz zig-70414c1f434dea4d749f1d1445816dffc88a7a68.zip | |
std.Thread: don't export wasi_thread_start in single-threaded mode
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Thread.zig | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index aa21a8a0ea..69dbcf3947 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1018,12 +1018,15 @@ const WasiThreadImpl = struct { return .{ .thread = &instance.thread }; } - /// Bootstrap procedure, called by the host environment after thread creation. - export fn wasi_thread_start(tid: i32, arg: *Instance) void { - if (builtin.single_threaded) { - // ensure function is not analyzed in single-threaded mode - return; + comptime { + if (!builtin.single_threaded) { + @export(wasi_thread_start, .{ .name = "wasi_thread_start" }); } + } + + /// Called by the host environment after thread creation. + fn wasi_thread_start(tid: i32, arg: *Instance) callconv(.c) void { + comptime assert(!builtin.single_threaded); __set_stack_pointer(arg.thread.memory.ptr + arg.stack_offset); __wasm_init_tls(arg.thread.memory.ptr + arg.tls_offset); @atomicStore(u32, &WasiThreadImpl.tls_thread_id, @intCast(tid), .seq_cst); |
