Skip to content

Commit

Permalink
Use same nightly as Tock
Browse files Browse the repository at this point in the history
- Deprecates reorder_imported_names rustfmt option
- Requires new Allocator API
  • Loading branch information
Woyten committed May 1, 2018
1 parent 9873498 commit e74a2bf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"editor.formatOnSave": true,
"rust-client.channel": "nightly-2018-04-12",
}
"rust-client.channel": "nightly-2018-04-19",
}
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Tock Project Developers <[email protected]>"]
license = "MIT/Apache-2.0"

[dependencies]
linked_list_allocator = "0.5.0"
linked_list_allocator = "0.6.0"

[dev-dependencies]
corepack = { version = "0.3.1", default-features = false, features = ["alloc"] }
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2018-04-12
nightly-2018-04-19
1 change: 0 additions & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
reorder_imports = true
reorder_imported_names = true
reorder_modules = true
use_field_init_shorthand = true
use_try_shorthand = true
18 changes: 10 additions & 8 deletions src/entry_point.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
extern crate linked_list_allocator;

use self::linked_list_allocator::Heap;
use alloc::allocator::Alloc;
use alloc::allocator::AllocErr;
use alloc::allocator::Layout;
use core::alloc::Alloc;
use core::alloc::GlobalAlloc;
use core::alloc::Layout;
use core::alloc::Opaque;
use core::mem;
use core::ptr;
use core::ptr::NonNull;
use syscalls;

const HEAP_SIZE: usize = 0x400;
Expand Down Expand Up @@ -36,13 +38,13 @@ impl TockAllocator {
}
}

unsafe impl<'a> Alloc for &'a TockAllocator {
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
self.heap().alloc(layout)
unsafe impl GlobalAlloc for TockAllocator {
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
self.heap().alloc(layout).unwrap().as_ptr()
}

unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
self.heap().dealloc(ptr, layout)
unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) {
self.heap().dealloc(NonNull::new_unchecked(ptr), layout)
}
}

Expand Down

0 comments on commit e74a2bf

Please sign in to comment.