authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-01 12:15:10+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-04 00:26:53+02:00
logcd6795fc06affbb13c0223346c0c3fd47f5ab28f
treea2440201e394fcc89769bd158fbbd67a5c71b4f6
parent07c943598d25c479d90ae51f89ba6dfe83b2d97e
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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.

2 files changed, 26 insertions(+), 2 deletions(-)

lib/std/os/linux.zig+13-1
......@@ -904,7 +904,19 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, of
904904 @truncate(@as(u64, @bitCast(offset)) / MMAP2_UNIT),
905905 );
906906 } else {
907 return syscall6(
907 // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so
908 // it takes a single pointer to an array of arguments instead.
909 return if (native_arch == .s390x) syscall1(
910 .mmap,
911 @intFromPtr(&[_]usize{
912 @intFromPtr(address),
913 length,
914 prot,
915 @as(u32, @bitCast(flags)),
916 @bitCast(@as(isize, fd)),
917 @as(u64, @bitCast(offset)),
918 }),
919 ) else syscall6(
908920 .mmap,
909921 @intFromPtr(address),
910922 length,
lib/std/os/linux/tls.zig+13-1
......@@ -541,7 +541,19 @@ inline fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: linux.MAP, fd
541541 @as(usize, @truncate(@as(u64, @bitCast(offset)) / linux.MMAP2_UNIT)),
542542 });
543543 } else {
544 return @call(.always_inline, linux.syscall6, .{
544 // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so
545 // it takes a single pointer to an array of arguments instead.
546 return if (native_arch == .s390x) @call(.always_inline, linux.syscall1, .{
547 .mmap,
548 @intFromPtr(&[_]usize{
549 @intFromPtr(address),
550 length,
551 prot,
552 @as(u32, @bitCast(flags)),
553 @as(usize, @bitCast(@as(isize, fd))),
554 @as(u64, @bitCast(offset)),
555 }),
556 }) else @call(.always_inline, linux.syscall6, .{
545557 .mmap,
546558 @intFromPtr(address),
547559 length,