Commit e2a3eecd authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'uefi-fix' into 'master'

Update uefi dep, fix building on nightly

See merge request redox-os/uefi_alloc!2
parents 4a69eba2 f2cc919c
...@@ -11,4 +11,4 @@ repository = "https://gitlab.redox-os.org/redox-os/uefi_alloc" ...@@ -11,4 +11,4 @@ repository = "https://gitlab.redox-os.org/redox-os/uefi_alloc"
name = "uefi_alloc" name = "uefi_alloc"
[dependencies] [dependencies]
redox_uefi = "0.1.0" redox_uefi = "0.1.2"
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(const_fn)] #![feature(try_trait_v2)]
#![feature(try_trait)] #![feature(control_flow_enum)]
#![no_std] #![no_std]
use core::alloc::{GlobalAlloc, Layout}; use core::alloc::{GlobalAlloc, Layout};
use core::ops::Try; use core::ops::{ControlFlow, Try};
use core::ptr::{self, NonNull}; use core::ptr::{self, NonNull};
use uefi::memory::MemoryType; use uefi::memory::MemoryType;
use uefi::system::SystemTable; use uefi::system::SystemTable;
...@@ -21,17 +21,16 @@ unsafe impl GlobalAlloc for Allocator { ...@@ -21,17 +21,16 @@ unsafe impl GlobalAlloc for Allocator {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 { unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
let uefi = UEFI.expect("__rust_allocate: uefi not initialized"); let uefi = UEFI.expect("__rust_allocate: uefi not initialized");
let mut ptr = 0; let mut ptr = 0;
if (uefi.as_ref().BootServices.AllocatePool)( let res = (uefi.as_ref().BootServices.AllocatePool)(
MemoryType::EfiLoaderData, MemoryType::EfiLoaderData,
layout.size(), layout.size(),
&mut ptr, &mut ptr,
) )
.into_result() .branch();
.is_ok()
{ match res {
ptr as *mut u8 ControlFlow::Continue(ptr) => ptr as *mut u8,
} else { ControlFlow::Break(_) => ptr::null_mut(),
ptr::null_mut()
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment