std.os.linux: Fix mmap() syscall invocation for s390x.

The s390x mmap() syscall existed before Linux supported syscalls with 5+
parameters, so it takes a single pointer to an array of arguments instead.
This commit is contained in:
Alex Rønne Petersen 2024-10-01 12:15:10 +02:00
parent 07c943598d
commit cd6795fc06
No known key found for this signature in database
2 changed files with 26 additions and 2 deletions

View File

@ -904,7 +904,19 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, of
@truncate(@as(u64, @bitCast(offset)) / MMAP2_UNIT),
);
} else {
return syscall6(
// The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so
// it takes a single pointer to an array of arguments instead.
return if (native_arch == .s390x) syscall1(
.mmap,
@intFromPtr(&[_]usize{
@intFromPtr(address),
length,
prot,
@as(u32, @bitCast(flags)),
@bitCast(@as(isize, fd)),
@as(u64, @bitCast(offset)),
}),
) else syscall6(
.mmap,
@intFromPtr(address),
length,

View File

@ -541,7 +541,19 @@ inline fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: linux.MAP, fd
@as(usize, @truncate(@as(u64, @bitCast(offset)) / linux.MMAP2_UNIT)),
});
} else {
return @call(.always_inline, linux.syscall6, .{
// The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so
// it takes a single pointer to an array of arguments instead.
return if (native_arch == .s390x) @call(.always_inline, linux.syscall1, .{
.mmap,
@intFromPtr(&[_]usize{
@intFromPtr(address),
length,
prot,
@as(u32, @bitCast(flags)),
@as(usize, @bitCast(@as(isize, fd))),
@as(u64, @bitCast(offset)),
}),
}) else @call(.always_inline, linux.syscall6, .{
.mmap,
@intFromPtr(address),
length,