Skip to content

Commit 658d267

Browse files
committed
Use same nightly as Tock
- Deprecates reorder_imported_names rustfmt option - Requires new Allocator API
1 parent b6f1a1d commit 658d267

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"editor.formatOnSave": true,
3-
"rust-client.channel": "nightly-2018-04-12",
3+
"rust-client.channel": "nightly-2018-04-19",
44
"rust.target": "thumbv7em-none-eabi",
5-
}
5+
}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Tock Project Developers <[email protected]>"]
55
license = "MIT/Apache-2.0"
66

77
[dependencies]
8-
linked_list_allocator = "0.5.0"
8+
linked_list_allocator = "0.6.0"
99

1010
[dev-dependencies]
1111
corepack = { version = "0.3.1", default-features = false, features = ["alloc"] }

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2018-04-12
1+
nightly-2018-04-19

rustfmt.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
reorder_imports = true
2-
reorder_imported_names = true
32
reorder_modules = true
43
use_field_init_shorthand = true
54
use_try_shorthand = true

src/entry_point.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
extern crate linked_list_allocator;
22

33
use self::linked_list_allocator::Heap;
4-
use alloc::allocator::Alloc;
5-
use alloc::allocator::AllocErr;
6-
use alloc::allocator::Layout;
4+
use core::alloc::Alloc;
5+
use core::alloc::GlobalAlloc;
6+
use core::alloc::Layout;
7+
use core::alloc::Opaque;
78
use core::mem;
89
use core::ptr;
10+
use core::ptr::NonNull;
911
use syscalls;
1012

1113
const HEAP_SIZE: usize = 0x400;
@@ -36,13 +38,13 @@ impl TockAllocator {
3638
}
3739
}
3840

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

44-
unsafe fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
45-
self.heap().dealloc(ptr, layout)
46+
unsafe fn dealloc(&self, ptr: *mut Opaque, layout: Layout) {
47+
self.heap().dealloc(NonNull::new_unchecked(ptr), layout)
4648
}
4749
}
4850

0 commit comments

Comments
 (0)