From 605680401f12aa29e8f9bd3eea87ae252155c0de Mon Sep 17 00:00:00 2001 From: Harry Cheng Date: Sun, 28 Jul 2019 14:59:37 +0800 Subject: [PATCH] Compiles and works: 2019-04-14 --- crate/memory/src/cow.rs | 2 +- crate/memory/src/paging/mock_page_table.rs | 2 +- crate/memory/src/swap/mock_swapper.rs | 16 ++++++++-------- kernel/src/arch/aarch64/paging.rs | 4 ++-- kernel/src/arch/mipsel/paging.rs | 4 ++-- kernel/src/arch/riscv32/paging.rs | 4 ++-- kernel/src/arch/x86_64/paging.rs | 4 ++-- kernel/src/main.rs | 1 + kernel/src/process/structs.rs | 6 +++--- kernel/src/syscall/fs.rs | 2 +- rust-toolchain | 2 +- 11 files changed, 24 insertions(+), 23 deletions(-) diff --git a/crate/memory/src/cow.rs b/crate/memory/src/cow.rs index 26b6948..ce4c355 100644 --- a/crate/memory/src/cow.rs +++ b/crate/memory/src/cow.rs @@ -110,7 +110,7 @@ impl CowExt { 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); diff --git a/crate/memory/src/paging/mock_page_table.rs b/crate/memory/src/paging/mock_page_table.rs index 525d56c..35a8b0d 100644 --- a/crate/memory/src/paging/mock_page_table.rs +++ b/crate/memory/src/paging/mock_page_table.rs @@ -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, } } diff --git a/crate/memory/src/swap/mock_swapper.rs b/crate/memory/src/swap/mock_swapper.rs index ec71c39..d988e9d 100644 --- a/crate/memory/src/swap/mock_swapper.rs +++ b/crate/memory/src/swap/mock_swapper.rs @@ -17,7 +17,7 @@ pub struct MockSwapper { impl Swapper for MockSwapper { fn swap_out(&mut self, data: &[u8]) -> Result { 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(())); } } diff --git a/kernel/src/arch/aarch64/paging.rs b/kernel/src/arch/aarch64/paging.rs index 1d27b85..014d3f5 100644 --- a/kernel/src/arch/aarch64/paging.rs +++ b/kernel/src/arch/aarch64/paging.rs @@ -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(), } } } diff --git a/kernel/src/arch/mipsel/paging.rs b/kernel/src/arch/mipsel/paging.rs index 2dd1cdf..a7d9e4e 100644 --- a/kernel/src/arch/mipsel/paging.rs +++ b/kernel/src/arch/mipsel/paging.rs @@ -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() }, } } diff --git a/kernel/src/arch/riscv32/paging.rs b/kernel/src/arch/riscv32/paging.rs index 8baec5f..c339f86 100644 --- a/kernel/src/arch/riscv32/paging.rs +++ b/kernel/src/arch/riscv32/paging.rs @@ -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() }, } } diff --git a/kernel/src/arch/x86_64/paging.rs b/kernel/src/arch/x86_64/paging.rs index 2f8c26e..8ce5507 100644 --- a/kernel/src/arch/x86_64/paging.rs +++ b/kernel/src/arch/x86_64/paging.rs @@ -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, ) } diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 0ce3725..b3a360e 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -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; diff --git a/kernel/src/process/structs.rs b/kernel/src/process/structs.rs index b783b37..d3bf3c1 100644 --- a/kernel/src/process/structs.rs +++ b/kernel/src/process/structs.rs @@ -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: &Arc, exec_path: &str, mut args: Vec, envs: Vec, ) -> 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")?; diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 27f8464..20bdd30 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -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 }) diff --git a/rust-toolchain b/rust-toolchain index a698ea6..e37d6ad 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2019-03-05 +nightly-2019-04-14