Skip to content

Commit

Permalink
uefi: Make the allocator module unconditionally enabled
Browse files Browse the repository at this point in the history
The `global_allocator` feature now only controls whether the
`#[global_allocator]` attribute is set on `Allocator`; the `Allocator` itself is
now always available.
  • Loading branch information
nicholasbishop committed Mar 22, 2023
1 parent 874ad0a commit c88304f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,10 @@

### Changed

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

## uefi-macros - [Unreleased]

Expand Down
5 changes: 3 additions & 2 deletions uefi/src/allocator.rs
@@ -1,7 +1,7 @@
//! This module implements Rust's global allocator interface using UEFI's memory allocation functions.
//!
//! Enabling the `alloc` optional feature in your app will allow you to use Rust's higher-level data structures,
//! like boxes, vectors, hash maps, linked lists and so on.
//! If the `global_allocator` feature is enabled, the [`Allocator`] will be used
//! as the global Rust allocator.
//!
//! # Usage
//!
Expand Down Expand Up @@ -112,5 +112,6 @@ unsafe impl GlobalAlloc for Allocator {
}
}

#[cfg(feature = "global_allocator")]
#[global_allocator]
static ALLOCATOR: Allocator = Allocator;
5 changes: 2 additions & 3 deletions uefi/src/lib.rs
Expand Up @@ -43,8 +43,8 @@
//! `Vec` rather than filling a statically-sized array. This requires
//! a global allocator; you can use the `global_allocator` feature or
//! provide your own.
//! - `global_allocator`: Implement a [global allocator] using UEFI
//! functions. This is a simple allocator that relies on the UEFI pool
//! - `global_allocator`: Set [`allocator::Allocator`] as the global Rust
//! allocator. This is a simple allocator that relies on the UEFI pool
//! allocator. You can choose to provide your own allocator instead of
//! using this feature, or no allocator at all if you don't need to
//! dynamically allocate any memory.
Expand Down Expand Up @@ -108,7 +108,6 @@ pub mod proto;

pub mod prelude;

#[cfg(feature = "global_allocator")]
pub mod allocator;

#[cfg(feature = "logger")]
Expand Down

0 comments on commit c88304f

Please sign in to comment.