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; return true;
} }
use core::mem::MaybeUninit; 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)); temp_data[..].copy_from_slice(self.get_page_slice_mut(addr));
self.unmap_shared(addr); self.unmap_shared(addr);

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

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

@ -212,7 +212,7 @@ impl PageTableImpl {
PageTableImpl { PageTableImpl {
page_table: MappedPageTable::new(table, frame_to_page_table), page_table: MappedPageTable::new(table, frame_to_page_table),
root_frame: frame, 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 { PageTableImpl {
page_table: MappedPageTable::new(table, frame_to_page_table), page_table: MappedPageTable::new(table, frame_to_page_table),
root_frame: frame, root_frame: frame,
entry: core::mem::MaybeUninit::uninitialized().into_initialized(), entry: core::mem::MaybeUninit::uninit().assume_init(),
} }
} }
} }

@ -155,7 +155,7 @@ impl PageTableImpl {
PageTableImpl { PageTableImpl {
page_table: TwoLevelPageTable::new(table), page_table: TwoLevelPageTable::new(table),
root_frame: frame, 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 { PageTableImpl {
page_table: TwoLevelPageTable::new(table), page_table: TwoLevelPageTable::new(table),
root_frame: frame, 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 { PageTableImpl {
page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET), page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET),
root_frame: frame, 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 { PageTableImpl {
page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET), page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET),
root_frame: frame, 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); let table = &mut *frame_to_page_table(frame);
PageTableImpl( PageTableImpl(
MappedPageTable::new(table, frame_to_page_table), MappedPageTable::new(table, frame_to_page_table),
core::mem::MaybeUninit::uninitialized().into_initialized(), core::mem::MaybeUninit::uninit().assume_init(),
frame, frame,
) )
} }
@ -217,7 +217,7 @@ impl PageTableExt for PageTableImpl {
unsafe { unsafe {
PageTableImpl( PageTableImpl(
MappedPageTable::new(table, frame_to_page_table), MappedPageTable::new(table, frame_to_page_table),
core::mem::MaybeUninit::uninitialized().into_initialized(), core::mem::MaybeUninit::uninit().assume_init(),
frame, frame,
) )
} }

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

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

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

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

Loading…
Cancel
Save