diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-09-27 14:53:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-27 14:53:52 -0400 |
| commit | 70e934f116f3b889fcee755380a708fdceaaf699 (patch) | |
| tree | 87d1d26bd2475bbb492e4361bfeccd62be11aaa3 /lib/std/os/linux.zig | |
| parent | 805f9b309bee2d1a6c4fa34f1bc2746a8e60c35f (diff) | |
| parent | 9ad0541f2c06e0eb3419b3da7fe721affa3aa3b5 (diff) | |
| download | zig-70e934f116f3b889fcee755380a708fdceaaf699.tar.gz zig-70e934f116f3b889fcee755380a708fdceaaf699.zip | |
Merge pull request #3326 from LemonBoy/misc-misc
Miscellaneous and very small patches regarding mipsel and musl libc
Diffstat (limited to 'lib/std/os/linux.zig')
| -rw-r--r-- | lib/std/os/linux.zig | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index eb2f71cf99..9550518842 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -193,9 +193,29 @@ pub fn umount2(special: [*]const u8, flags: u32) usize { pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: u32, fd: i32, offset: u64) usize { if (@hasDecl(@This(), "SYS_mmap2")) { - return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), @truncate(usize, offset / MMAP2_UNIT)); + // Make sure the offset is also specified in multiples of page size + if ((offset & (MMAP2_UNIT - 1)) != 0) + return @bitCast(usize, isize(-EINVAL)); + + return syscall6( + SYS_mmap2, + @ptrToInt(address), + length, + prot, + flags, + @bitCast(usize, isize(fd)), + @truncate(usize, offset / MMAP2_UNIT), + ); } else { - return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @bitCast(usize, isize(fd)), offset); + return syscall6( + SYS_mmap, + @ptrToInt(address), + length, + prot, + flags, + @bitCast(usize, isize(fd)), + offset, + ); } } |
