Add msync function and stub for Redox

This commit is contained in:
Jeremy Soller
2019-12-01 10:58:47 -07:00
parent 15e6d23538
commit 2ac349d2d2
4 changed files with 26 additions and 4 deletions
+8 -4
View File
@@ -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]
+4
View File
@@ -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
}
+2
View File
@@ -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;
+12
View File
@@ -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;