| ... | @@ -1118,6 +1118,14 @@ pub fn pivot_root(new_root: [*:0]const u8, put_old: [*:0]const u8) usize { | ... | @@ -1118,6 +1118,14 @@ pub fn pivot_root(new_root: [*:0]const u8, put_old: [*:0]const u8) usize { |
| 1118 | return syscall2(.pivot_root, @intFromPtr(new_root), @intFromPtr(put_old)); | 1118 | return syscall2(.pivot_root, @intFromPtr(new_root), @intFromPtr(put_old)); |
| 1119 | } | 1119 | } |
| 1120 | | 1120 | |
| | 1121 | fn mmap2Unit() u64 { |
| | 1122 | return switch (native_arch) { |
| | 1123 | .arc, .arceb, .m68k => std.heap.pageSize(), |
| | 1124 | .or1k => 8 << 10, |
| | 1125 | else => 4 << 10, |
| | 1126 | }; |
| | 1127 | } |
| | 1128 | |
| 1121 | pub fn mmap(address: ?[*]u8, length: usize, prot: PROT, flags: MAP, fd: i32, offset: i64) usize { | 1129 | pub fn mmap(address: ?[*]u8, length: usize, prot: PROT, flags: MAP, fd: i32, offset: i64) usize { |
| 1122 | if (@hasField(SYS, "mmap2")) { | 1130 | if (@hasField(SYS, "mmap2")) { |
| 1123 | return syscall6( | 1131 | return syscall6( |
| ... | @@ -1127,7 +1135,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: PROT, flags: MAP, fd: i32, off | ... | @@ -1127,7 +1135,7 @@ pub fn mmap(address: ?[*]u8, length: usize, prot: PROT, flags: MAP, fd: i32, off |
| 1127 | @as(u32, @bitCast(prot)), | 1135 | @as(u32, @bitCast(prot)), |
| 1128 | @as(u32, @bitCast(flags)), | 1136 | @as(u32, @bitCast(flags)), |
| 1129 | @bitCast(@as(isize, fd)), | 1137 | @bitCast(@as(isize, fd)), |
| 1130 | @truncate(@as(u64, @bitCast(offset)) / std.heap.pageSize()), | 1138 | @truncate(@as(u64, @bitCast(offset)) / mmap2Unit()), |
| 1131 | ); | 1139 | ); |
| 1132 | } else { | 1140 | } else { |
| 1133 | // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so | 1141 | // The s390x mmap() syscall existed before Linux supported syscalls with 5+ parameters, so |