1
0
Fork 0
forked from wry/wry

it: use single-pixel buffer instead of shm

This commit is contained in:
Julian Orth 2024-04-02 10:23:55 +02:00
parent aaed003ec8
commit f562f887f0
17 changed files with 280 additions and 76 deletions

View file

@ -13,6 +13,7 @@ pub struct TestMem {
}
impl TestMem {
#[allow(dead_code)]
pub fn new(size: usize) -> Result<Rc<Self>, TestError> {
let fd = uapi::memfd_create("test_pool", c::MFD_CLOEXEC | c::MFD_ALLOW_SEALING)?;
uapi::fcntl_add_seals(fd.raw(), c::F_SEAL_SHRINK)?;
@ -24,6 +25,7 @@ impl TestMem {
}))
}
#[allow(dead_code)]
pub fn grow(&self, size: usize) -> Result<Rc<Self>, TestError> {
let cur_len = uapi::fstat(self.fd.raw())?;
if size > cur_len.st_size as _ {
@ -45,6 +47,7 @@ impl Deref for TestMem {
}
}
#[allow(dead_code)]
fn map(fd: c::c_int, size: usize) -> Result<*const [Cell<u8>], TestError> {
if size == 0 {
return Ok(&[]);