Skip to content

Commit 8045d43

Browse files
nicholasbishopphip1611
authored andcommitted
uefi: Make the allocator module unconditionally enabled
The `global_allocator` feature now only controls whether the `#[global_allocator]` attribute is set on `Allocator`; the `Allocator` itself is now always available.
1 parent c170ff7 commit 8045d43

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
### Changed
66

7-
- The `uefi::global_allocator` module has been renamed to `uefi::allocator`.
7+
- The `global_allocator` module has been renamed to `allocator`, and is now
8+
available regardless of whether the `global_allocator` feature is enabled. The
9+
`global_allocator` feature now only controls whether `allocator::Allocator` is
10+
set as Rust's global allocator.
811

912
## uefi-macros - [Unreleased]
1013

uefi/src/allocator.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This module implements Rust's global allocator interface using UEFI's memory allocation functions.
22
//!
3-
//! Enabling the `alloc` optional feature in your app will allow you to use Rust's higher-level data structures,
4-
//! like boxes, vectors, hash maps, linked lists and so on.
3+
//! If the `global_allocator` feature is enabled, the [`Allocator`] will be used
4+
//! as the global Rust allocator.
55
//!
66
//! # Usage
77
//!
@@ -112,5 +112,6 @@ unsafe impl GlobalAlloc for Allocator {
112112
}
113113
}
114114

115+
#[cfg(feature = "global_allocator")]
115116
#[global_allocator]
116117
static ALLOCATOR: Allocator = Allocator;

uefi/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
//! `Vec` rather than filling a statically-sized array. This requires
4444
//! a global allocator; you can use the `global_allocator` feature or
4545
//! provide your own.
46-
//! - `global_allocator`: Implement a [global allocator] using UEFI
47-
//! functions. This is a simple allocator that relies on the UEFI pool
46+
//! - `global_allocator`: Set [`allocator::Allocator`] as the global Rust
47+
//! allocator. This is a simple allocator that relies on the UEFI pool
4848
//! allocator. You can choose to provide your own allocator instead of
4949
//! using this feature, or no allocator at all if you don't need to
5050
//! dynamically allocate any memory.
@@ -108,7 +108,6 @@ pub mod proto;
108108

109109
pub mod prelude;
110110

111-
#[cfg(feature = "global_allocator")]
112111
pub mod allocator;
113112

114113
#[cfg(feature = "logger")]

0 commit comments

Comments
 (0)