wiggle: get BorrowChecker from GuestMemory method

This commit is contained in:
Pat Hickey
2020-05-21 12:37:14 -07:00
parent 3920d8c1f3
commit 96d6884d33
13 changed files with 112 additions and 128 deletions

View File

@@ -1,7 +1,7 @@
use proptest::prelude::*;
use std::cell::UnsafeCell;
use std::marker;
use wiggle::GuestMemory;
use wiggle::{BorrowChecker, GuestMemory};
#[derive(Debug, Clone)]
pub struct MemAreas(Vec<MemArea>);
@@ -45,11 +45,13 @@ impl Into<Vec<MemArea>> for MemAreas {
#[repr(align(4096))]
pub struct HostMemory {
buffer: UnsafeCell<[u8; 4096]>,
bc: BorrowChecker,
}
impl HostMemory {
pub fn new() -> Self {
HostMemory {
buffer: UnsafeCell::new([0; 4096]),
bc: unsafe { BorrowChecker::new() },
}
}
@@ -111,6 +113,9 @@ unsafe impl GuestMemory for HostMemory {
((*ptr).as_mut_ptr(), (*ptr).len() as u32)
}
}
fn borrow_checker(&self) -> &BorrowChecker {
&self.bc
}
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]