Skip to content
Snippets Groups Projects
Verified Commit 2ac349d2 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Add msync function and stub for Redox

parent 15e6d235
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,10 @@ pub const MAP_FIXED: c_int = 0x0010;
pub const MAP_ANON: c_int = 0x0020;
pub const MAP_ANONYMOUS: c_int = MAP_ANON;
pub const MS_ASYNC: c_int = 0x0001;
pub const MS_INVALIDATE: c_int = 0x0002;
pub const MS_SYNC: c_int = 0x0004;
// #[no_mangle]
pub extern "C" fn mlock(addr: *const c_void, len: usize) -> c_int {
unimplemented!();
......@@ -44,13 +48,13 @@ pub unsafe extern "C" fn mmap(
}
#[no_mangle]
pub unsafe extern "C" fn mprotect(addr: *mut c_void, len: usize, prot: c_int) -> c_int {
pub unsafe extern "C" fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int {
Sys::mprotect(addr, len, prot)
}
// #[no_mangle]
pub extern "C" fn msync(addr: *mut c_void, len: usize, flags: c_int) -> c_int {
unimplemented!();
#[no_mangle]
pub unsafe extern "C" fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int {
Sys::msync(addr, len, flags)
}
// #[no_mangle]
......
......@@ -310,6 +310,10 @@ impl Pal for Sys {
e(syscall!(MPROTECT, addr, len, prot)) as c_int
}
unsafe fn msync(addr: *mut c_void, len: usize, flags: c_int) -> c_int {
e(syscall!(MSYNC, addr, len, flags)) as c_int
}
unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int {
e(syscall!(MUNMAP, addr, len)) as c_int
}
......
......@@ -118,6 +118,8 @@ pub trait Pal {
unsafe fn mprotect(addr: *mut c_void, len: usize, prot: c_int) -> c_int;
unsafe fn msync(addr: *mut c_void, len: usize, flags: c_int) -> c_int;
unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int;
fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int;
......
......@@ -675,6 +675,18 @@ impl Pal for Sys {
)) as c_int
}
unsafe fn msync(addr: *mut c_void, len: usize, flags: c_int) -> c_int {
eprintln!("msync {:p} {:x} {:x}", addr, len, flags);
e(Err(syscall::Error::new(syscall::ENOSYS))) as c_int
/* TODO
e(syscall::msync(
addr as usize,
len,
flags
)) as c_int
*/
}
unsafe fn munmap(addr: *mut c_void, _len: usize) -> c_int {
if e(syscall::funmap(addr as usize)) == !0 {
return !0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment