Skip to content

Commit 909f3ad

Browse files
author
morimolymoly
committed
alloc: update to new allocator and bump up r-efi version to 4
Needed since rust-lang/wg-allocators#76 Signed-off-by: Mizuho MORI <morimolymoly@gmail.com>
1 parent 3bcc031 commit 909f3ad

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

Cargo.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ name = "hello-world"
3838
required-features = ["examples"]
3939

4040
[dependencies]
41-
r-efi = "2.2.0"
41+
r-efi = "4.0.0"

src/alloc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
//! exports an `Allocator` type that wraps a System-Table together with a UEFI memory type and
55
//! forwards memory requests to the UEFI pool allocator.
66
//!
7-
//! The allocator implements the `core::alloc::AllocRef` API defined by the rust standard library.
7+
//! The allocator implements the `core::alloc::Allocator` API defined by the rust standard library.
88
//! Apart from the constructors, no private extensions are defined. For documentation on the
99
//! allocation-API, see the rust standard library.
1010
//!
11-
//! Note that `core::alloc::AllocRef` is marked unstable as of time of this crate-release. That
11+
//! Note that `core::alloc::Allocator` is marked unstable as of time of this crate-release. That
1212
//! is, future versions of this trait definition might be incompatible to the current version.
1313
//! Make sure you use a crate-version that matches your standard-library.
1414
@@ -92,7 +92,7 @@ unsafe fn unalign_block(ptr: *mut u8, align: usize) -> *mut u8 {
9292
/// allocator. It takes a System-Table as input, as well as the memory type to use as backing, and
9393
/// then forwards all memory allocation requests to the `AllocatePool()` UEFI system.
9494
///
95-
/// The `core::alloc::AllocRef` trait is implemented for this allocator. Hence, this allocator can
95+
/// The `core::alloc::Allocator` trait is implemented for this allocator. Hence, this allocator can
9696
/// also be used to back the global memory-allocator of `liballoc` (or `libstd`). See the `Global`
9797
/// type for an implementation of the global allocator.
9898
pub struct Allocator {
@@ -124,8 +124,8 @@ impl Allocator {
124124
}
125125
}
126126

127-
unsafe impl core::alloc::AllocRef for Allocator {
128-
fn alloc(
127+
unsafe impl core::alloc::Allocator for Allocator {
128+
fn allocate(
129129
&self,
130130
layout: core::alloc::Layout,
131131
) -> Result<core::ptr::NonNull<[u8]>, core::alloc::AllocError> {
@@ -165,7 +165,7 @@ unsafe impl core::alloc::AllocRef for Allocator {
165165
).unwrap())
166166
}
167167

168-
unsafe fn dealloc(&self, ptr: core::ptr::NonNull<u8>, layout: core::alloc::Layout) {
168+
unsafe fn deallocate(&self, ptr: core::ptr::NonNull<u8>, layout: core::alloc::Layout) {
169169
if layout.size() != 0 {
170170
// The spec allows returning errors from `FreePool()`. However, it
171171
// must serve any valid requests. Only `INVALID_PARAMETER` is

src/global.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ unsafe impl core::alloc::GlobalAlloc for Bridge {
131131
return core::ptr::null_mut();
132132
}
133133

134-
core::alloc::AllocRef::alloc(&mut *allocator, layout)
134+
core::alloc::Allocator::allocate(&mut *allocator, layout)
135135
.map(|mut mem| mem.as_mut().as_mut_ptr())
136136
.unwrap_or(core::ptr::null_mut())
137137
}
@@ -141,7 +141,7 @@ unsafe impl core::alloc::GlobalAlloc for Bridge {
141141

142142
assert!(!allocator.is_null());
143143

144-
core::alloc::AllocRef::dealloc(
144+
core::alloc::Allocator::deallocate(
145145
&mut *allocator,
146146
core::ptr::NonNull::new_unchecked(ptr),
147147
layout,

0 commit comments

Comments
 (0)