diff --git a/Cargo.toml b/Cargo.toml index 4390efb..08ee95d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ features = [ ] [target.'cfg(target_os = "redox")'.dependencies] -libredox = "0.1.18" +redox_syscall = "0.5" [build-dependencies] cfg_aliases = "0.2.0" diff --git a/src/orbital.rs b/src/orbital.rs index fae3cd8..50428ab 100644 --- a/src/orbital.rs +++ b/src/orbital.rs @@ -11,24 +11,22 @@ struct OrbitalMap { } impl OrbitalMap { - unsafe fn new(fd: usize, size_unaligned: usize) -> std::io::Result { - // from redox_syscall - const PAGE_SIZE: usize = 4096; + unsafe fn new(fd: usize, size_unaligned: usize) -> syscall::Result { // Page align size - let pages = (size_unaligned + PAGE_SIZE - 1) / PAGE_SIZE; - let size = pages * PAGE_SIZE; + let pages = (size_unaligned + syscall::PAGE_SIZE - 1) / syscall::PAGE_SIZE; + let size = pages * syscall::PAGE_SIZE; // Map window buffer let address = unsafe { - libredox::call::mmap(libredox::call::MmapArgs { - addr: core::ptr::null_mut(), - length: size, - prot: libredox::flag::PROT_READ | libredox::flag::PROT_WRITE, - flags: libredox::flag::MAP_SHARED, + syscall::fmap( fd, - offset: 0, - })? - .addr() + &syscall::Map { + offset: 0, + size, + flags: syscall::PROT_READ | syscall::PROT_WRITE | syscall::MAP_SHARED, + address: 0, + }, + )? }; Ok(Self { @@ -51,8 +49,7 @@ impl Drop for OrbitalMap { fn drop(&mut self) { unsafe { // Unmap window buffer on drop - libredox::call::munmap(self.address as _, self.size) - .expect("failed to unmap orbital window"); + syscall::funmap(self.address, self.size).expect("failed to unmap orbital window"); } } } @@ -111,7 +108,7 @@ impl OrbitalImpl { let mut window_height = 0; let mut buf: [u8; 4096] = [0; 4096]; - let count = libredox::call::fpath(self.window_fd(), &mut buf).unwrap(); + let count = syscall::fpath(self.window_fd(), &mut buf).unwrap(); let path = str::from_utf8(&buf[..count]).unwrap(); // orbital:/x/y/w/h/t let mut parts = path.split('/').skip(3); @@ -226,14 +223,14 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> { // Tell orbital to show the latest window data if damage.is_empty() { - libredox::call::fsync(self.imp.window_fd()).expect("failed to sync orbital window"); + syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window"); } else { use std::fmt::Write; let mut damage_buf = "Y".to_string(); for m in damage { let _ = write!(damage_buf, ",{},{},{},{}", m.x, m.y, m.width, m.height); } - libredox::call::write(self.imp.window_fd(), damage_buf.as_bytes()) + syscall::write(self.imp.window_fd(), damage_buf.as_bytes()) .expect("failed to sync orbital window"); }