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
This commit is contained in:
Alex Rønne Petersen 2025-10-18 11:34:48 +02:00
parent e59f2995a5
commit adcfdce6be
No known key found for this signature in database

View File

@ -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),