1
0
Fork 0

Support nightly-may-16-2018

This commit is contained in:
Mark Swanson 2018-05-25 15:21:50 -04:00 committed by edef
parent b79dcf3d79
commit 1d97ab9d02
2 changed files with 6 additions and 5 deletions

View File

@ -4,7 +4,7 @@
extern crate alloc; extern crate alloc;
use core::slice; use core::slice;
use self::alloc::heap::Heap; use self::alloc::heap::Global;
use self::alloc::allocator::{Alloc, Layout}; use self::alloc::allocator::{Alloc, Layout};
use self::alloc::boxed::Box; use self::alloc::boxed::Box;
use stack::Stack; use stack::Stack;
@ -19,8 +19,8 @@ impl OwnedStack {
pub fn new(size: usize) -> OwnedStack { pub fn new(size: usize) -> OwnedStack {
unsafe { unsafe {
let aligned_size = size & !(::STACK_ALIGNMENT - 1); let aligned_size = size & !(::STACK_ALIGNMENT - 1);
let ptr = Heap.alloc(Layout::from_size_align_unchecked(aligned_size, ::STACK_ALIGNMENT)).unwrap(); let ptr = Global.alloc(Layout::from_size_align_unchecked(aligned_size, ::STACK_ALIGNMENT)).unwrap();
OwnedStack(Box::from_raw(slice::from_raw_parts_mut(ptr, aligned_size))) OwnedStack(Box::from_raw(slice::from_raw_parts_mut(ptr.as_ptr() as *mut u8, aligned_size)))
} }
} }
} }

View File

@ -9,14 +9,15 @@
extern crate alloc; extern crate alloc;
extern crate fringe; extern crate fringe;
use alloc::heap::Heap; use alloc::heap::Global;
use alloc::allocator::{Alloc, Layout}; use alloc::allocator::{Alloc, Layout};
use alloc::boxed::Box; use alloc::boxed::Box;
use std::slice; use std::slice;
use fringe::{STACK_ALIGNMENT, Stack, SliceStack, OwnedStack, OsStack}; use fringe::{STACK_ALIGNMENT, Stack, SliceStack, OwnedStack, OsStack};
unsafe fn heap_allocate(size: usize, align: usize) -> *mut u8 { unsafe fn heap_allocate(size: usize, align: usize) -> *mut u8 {
Heap.alloc(Layout::from_size_align_unchecked(size, align)).expect("couldn't allocate") let ptr = Global.alloc(Layout::from_size_align_unchecked(size, align)).expect("couldn't allocate");
ptr.as_ptr() as *mut u8
} }
#[test] #[test]