Compiles and works: 2019-04-14

master
Harry Cheng 5 years ago
parent a708ee401d
commit 605680401f

@ -110,7 +110,7 @@ impl<T: PageTable> CowExt<T> {
return true;
}
use core::mem::MaybeUninit;
let mut temp_data: [u8; PAGE_SIZE] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut temp_data: [u8; PAGE_SIZE] = unsafe { MaybeUninit::uninit().assume_init() };
temp_data[..].copy_from_slice(self.get_page_slice_mut(addr));
self.unmap_shared(addr);

@ -147,7 +147,7 @@ impl MockPageTable {
use core::mem::MaybeUninit;
MockPageTable {
entries: [MockEntry::default(); PAGE_COUNT],
data: unsafe { MaybeUninit::uninitialized().into_initialized() },
data: unsafe { MaybeUninit::uninit().assume_init() },
page_fault_handler: None,
}
}

@ -17,7 +17,7 @@ pub struct MockSwapper {
impl Swapper for MockSwapper {
fn swap_out(&mut self, data: &[u8]) -> Result<usize, ()> {
let id = self.alloc_id();
let mut slice: [u8; PAGE_SIZE] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut slice: [u8; PAGE_SIZE] = unsafe { MaybeUninit::uninit().assume_init() };
slice.copy_from_slice(data);
self.map.insert(id, slice);
Ok(id)
@ -27,7 +27,7 @@ impl Swapper for MockSwapper {
if !self.map.contains_key(&token) {
return Err(());
}
let mut slice: [u8; PAGE_SIZE] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut slice: [u8; PAGE_SIZE] = unsafe { MaybeUninit::uninit().assume_init() };
slice.copy_from_slice(data);
self.map.insert(token, slice);
Ok(())
@ -64,8 +64,8 @@ mod test {
#[test]
fn swap_out_in() {
let mut swapper = MockSwapper::default();
let mut data: [u8; 4096] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let data1: [u8; 4096] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut data: [u8; 4096] = unsafe { MaybeUninit::uninit().assume_init() };
let data1: [u8; 4096] = unsafe { MaybeUninit::uninit().assume_init() };
let token = swapper.swap_out(&data1).unwrap();
swapper.swap_in(token, &mut data).unwrap();
assert_data_eq(&data, &data1);
@ -74,9 +74,9 @@ mod test {
#[test]
fn swap_update() {
let mut swapper = MockSwapper::default();
let mut data: [u8; 4096] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let data1: [u8; 4096] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let data2: [u8; 4096] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut data: [u8; 4096] = unsafe { MaybeUninit::uninit().assume_init() };
let data1: [u8; 4096] = unsafe { MaybeUninit::uninit().assume_init() };
let data2: [u8; 4096] = unsafe { MaybeUninit::uninit().assume_init() };
let token = swapper.swap_out(&data1).unwrap();
swapper.swap_update(token, &data2).unwrap();
swapper.swap_in(token, &mut data).unwrap();
@ -86,7 +86,7 @@ mod test {
#[test]
fn invalid_token() {
let mut swapper = MockSwapper::default();
let mut data: [u8; 4096] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut data: [u8; 4096] = unsafe { MaybeUninit::uninit().assume_init() };
assert_eq!(swapper.swap_in(0, &mut data), Err(()));
}
}

@ -212,7 +212,7 @@ impl PageTableImpl {
PageTableImpl {
page_table: MappedPageTable::new(table, frame_to_page_table),
root_frame: frame,
entry: core::mem::MaybeUninit::uninitialized().into_initialized(),
entry: core::mem::MaybeUninit::uninit().assume_init(),
}
}
}
@ -227,7 +227,7 @@ impl PageTableExt for PageTableImpl {
PageTableImpl {
page_table: MappedPageTable::new(table, frame_to_page_table),
root_frame: frame,
entry: core::mem::MaybeUninit::uninitialized().into_initialized(),
entry: core::mem::MaybeUninit::uninit().assume_init(),
}
}
}

@ -155,7 +155,7 @@ impl PageTableImpl {
PageTableImpl {
page_table: TwoLevelPageTable::new(table),
root_frame: frame,
entry: unsafe { core::mem::MaybeUninit::uninitialized().into_initialized() },
entry: unsafe { core::mem::MaybeUninit::uninit().assume_init() },
}
}
}
@ -171,7 +171,7 @@ impl PageTableExt for PageTableImpl {
PageTableImpl {
page_table: TwoLevelPageTable::new(table),
root_frame: frame,
entry: unsafe { core::mem::MaybeUninit::uninitialized().into_initialized() },
entry: unsafe { core::mem::MaybeUninit::uninit().assume_init() },
}
}

@ -157,7 +157,7 @@ impl PageTableImpl {
PageTableImpl {
page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET),
root_frame: frame,
entry: unsafe { core::mem::MaybeUninit::uninitialized().into_initialized() },
entry: unsafe { core::mem::MaybeUninit::uninit().assume_init() },
}
}
}
@ -173,7 +173,7 @@ impl PageTableExt for PageTableImpl {
PageTableImpl {
page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET),
root_frame: frame,
entry: unsafe { core::mem::MaybeUninit::uninitialized().into_initialized() },
entry: unsafe { core::mem::MaybeUninit::uninit().assume_init() },
}
}

@ -202,7 +202,7 @@ impl PageTableImpl {
let table = &mut *frame_to_page_table(frame);
PageTableImpl(
MappedPageTable::new(table, frame_to_page_table),
core::mem::MaybeUninit::uninitialized().into_initialized(),
core::mem::MaybeUninit::uninit().assume_init(),
frame,
)
}
@ -217,7 +217,7 @@ impl PageTableExt for PageTableImpl {
unsafe {
PageTableImpl(
MappedPageTable::new(table, frame_to_page_table),
core::mem::MaybeUninit::uninitialized().into_initialized(),
core::mem::MaybeUninit::uninit().assume_init(),
frame,
)
}

@ -1,6 +1,7 @@
#![no_std] // don't link the Rust standard library
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
#![allow(non_snake_case, unused_imports, unused_variables, unused_assignments)]
#[allow(unused_imports)]
use rcore;

@ -103,7 +103,7 @@ impl Thread {
Box::new(Thread {
context: Context::null(),
// safety: other fields will never be used
..core::mem::MaybeUninit::uninitialized().into_initialized()
..core::mem::MaybeUninit::uninit().assume_init()
})
}
@ -139,14 +139,14 @@ impl Thread {
/// Construct virtual memory of a new user process from ELF `data`.
/// Return `(MemorySet, entry_point, ustack_top)`
pub fn new_user_vm(
inode: &Arc<INode>,
inode: &Arc<dyn INode>,
exec_path: &str,
mut args: Vec<String>,
envs: Vec<String>,
) -> Result<(MemorySet, usize, usize), &'static str> {
// Read ELF header
// 0x3c0: magic number from ld-musl.so
let mut data: [u8; 0x3c0] = unsafe { MaybeUninit::uninitialized().into_initialized() };
let mut data: [u8; 0x3c0] = unsafe { MaybeUninit::uninit().assume_init() };
inode
.read_at(0, &mut data)
.map_err(|_| "failed to read from INode")?;

@ -1487,7 +1487,7 @@ impl FdSet {
debug!("bitset {:?}", bitset);
// save the fdset, and clear it
use alloc::prelude::ToOwned;
use alloc::prelude::v1::ToOwned;
let origin = bitset.to_owned();
bitset.set_all(false);
Ok(FdSet { bitset, origin })

@ -1 +1 @@
nightly-2019-03-05
nightly-2019-04-14

Loading…
Cancel
Save