sys_mman: adding madvise.

This commit is contained in:
David Carlier
2023-04-15 10:40:52 +01:00
parent d5c88c7ca6
commit 116583cdc7
5 changed files with 20 additions and 2 deletions
+5
View File
@@ -87,6 +87,11 @@ pub unsafe extern "C" fn munmap(addr: *mut c_void, len: size_t) -> c_int {
Sys::munmap(addr, len)
}
#[no_mangle]
pub unsafe extern "C" fn madvise(addr: *mut c_void, len: size_t, flags: c_int) -> c_int {
Sys::madvise(addr, len, flags)
}
#[cfg(target_os = "linux")]
static SHM_PATH: &'static [u8] = b"/dev/shm/";
+4
View File
@@ -355,6 +355,10 @@ impl Pal for Sys {
e(syscall!(MUNMAP, addr, len)) as c_int
}
unsafe fn madvise(addr: *mut c_void, len: usize, flags: c_int) -> c_int {
e(syscall!(MADVISE, addr, len, flags)) as c_int
}
fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
e(unsafe { syscall!(NANOSLEEP, rqtp, rmtp) }) as c_int
}
+2
View File
@@ -139,6 +139,8 @@ pub trait Pal {
unsafe fn munlock(addr: *const c_void, len: usize) -> c_int;
unsafe fn madvise(addr: *mut c_void, len: usize, flags: c_int) -> c_int;
fn munlockall() -> c_int;
unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int;
+5
View File
@@ -694,6 +694,11 @@ impl Pal for Sys {
0
}
unsafe fn madvise(addr: *mut c_void, len: usize, flags: c_int) -> c_int {
eprintln!("madvise {:p} {:x} {:x}", addr, len, flags);
e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int
}
fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
let redox_rqtp = unsafe { redox_timespec::from(&*rqtp) };
let mut redox_rmtp: redox_timespec;