diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/memmap2/src/unix.rs | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/memmap2/src/unix.rs')
-rw-r--r-- | vendor/memmap2/src/unix.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/vendor/memmap2/src/unix.rs b/vendor/memmap2/src/unix.rs index faa3b36d3..1df5691e9 100644 --- a/vendor/memmap2/src/unix.rs +++ b/vendor/memmap2/src/unix.rs @@ -6,8 +6,6 @@ use std::os::unix::io::{FromRawFd, RawFd}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::{io, ptr}; -use crate::advice::Advice; - #[cfg(any( all(target_os = "linux", not(target_arch = "mips")), target_os = "freebsd", @@ -48,7 +46,7 @@ pub struct MmapInner { impl MmapInner { /// Creates a new `MmapInner`. /// - /// This is a thin wrapper around the `mmap` sytem call. + /// This is a thin wrapper around the `mmap` system call. fn new( len: usize, prot: libc::c_int, @@ -59,7 +57,7 @@ impl MmapInner { let alignment = offset % page_size() as u64; let aligned_offset = offset - alignment; - let (map_len, map_offset) = Self::adjust_mmap_params(len as usize, alignment as usize)?; + let (map_len, map_offset) = Self::adjust_mmap_params(len, alignment as usize)?; unsafe { let ptr = mmap( @@ -197,7 +195,7 @@ impl MmapInner { debug_assert!(offset < page_size(), "offset larger than page size"); Self { - ptr: ptr.offset(offset as isize), + ptr: ptr.add(offset), len, } } @@ -342,12 +340,12 @@ impl MmapInner { self.len } - pub fn advise(&self, advice: Advice, offset: usize, len: usize) -> io::Result<()> { + pub fn advise(&self, advice: libc::c_int, offset: usize, len: usize) -> io::Result<()> { let alignment = (self.ptr as usize + offset) % page_size(); let offset = offset as isize - alignment as isize; let len = len + alignment; unsafe { - if libc::madvise(self.ptr.offset(offset), len, advice as i32) != 0 { + if libc::madvise(self.ptr.offset(offset), len, advice) != 0 { Err(io::Error::last_os_error()) } else { Ok(()) |