diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-18 11:34:48 +0200 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-10-18 11:36:26 +0200 |
| commit | adcfdce6be955d7d8e3237be5c34f84478cf4636 (patch) | |
| tree | 71c21ebf5b947899385791078ad77f69fefded11 /lib/std/Thread.zig | |
| parent | e59f2995a50f5a01181fbd903c8d077339aec61b (diff) | |
| download | zig-adcfdce6be955d7d8e3237be5c34f84478cf4636.tar.gz zig-adcfdce6be955d7d8e3237be5c34f84478cf4636.zip | |
std.Thread: fix some issues in x86_64/x32 inline asm
Wrong syscall on x32; return exit code 0 instead of 1 on both.
ref https://github.com/ziglang/zig/issues/22189
Diffstat (limited to 'lib/std/Thread.zig')
| -rw-r--r-- | lib/std/Thread.zig | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 3cbe8c8e84..c299fb626c 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1191,12 +1191,22 @@ const LinuxThreadImpl = struct { : [ptr] "r" (@intFromPtr(self.mapped.ptr)), [len] "r" (self.mapped.len), : .{ .memory = true }), - .x86_64 => asm volatile ( - \\ movq $11, %%rax # SYS_munmap - \\ syscall - \\ movq $60, %%rax # SYS_exit - \\ movq $1, %%rdi - \\ syscall + .x86_64 => asm volatile (switch (target.abi) { + .gnux32, .muslx32 => + \\ movl $0x4000000b, %%eax # SYS_munmap + \\ syscall + \\ movl $0x4000003c, %%eax # SYS_exit + \\ xor %%rdi, %%rdi + \\ syscall + , + else => + \\ movl $11, %%eax # SYS_munmap + \\ syscall + \\ movl $60, %%eax # SYS_exit + \\ xor %%rdi, %%rdi + \\ syscall + , + } : : [ptr] "{rdi}" (@intFromPtr(self.mapped.ptr)), [len] "{rsi}" (self.mapped.len), |
