aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/std/os/linux.zig14
-rw-r--r--lib/std/os/linux/tls.zig14
2 files changed, 26 insertions, 2 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index aaf08395fa..40dfcb933b 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -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,
diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig
index 7dab38024c..d1292e86dd 100644
--- a/lib/std/os/linux/tls.zig
+++ b/lib/std/os/linux/tls.zig
@@ -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,