Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f0202ba

Browse files
committed
rename crate features
To prevent confusion, this renames the `alloc` crate feature to `global_allocator` and the `exts` feature to `alloc` to match the conventions of the ecosystem.
1 parent c901eda commit f0202ba

File tree

25 files changed

+108
-72
lines changed

25 files changed

+108
-72
lines changed

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
### Changed
3232

33+
- Renamed crate feature `alloc` to `global_allocator`.
34+
- Renamed crate feature `exts` to `alloc`.
3335
- Fixed the definition of `AllocateType` so that `MaxAddress` and
3436
`Address` always take a 64-bit value, regardless of target platform.
3537
- The conversion methods on `DevicePathToText` and `DevicePathFromText`

‎README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@ Check out [the UEFI application template](template) for a quick start.
3131
This project contains multiple sub-crates:
3232

3333
- `uefi` (top directory): defines the standard UEFI tables / interfaces.
34-
The objective is to stay unopionated and safely wrap most interfaces.
34+
The objective is to stay opinionated and safely wrap most interfaces.
3535

36-
Optional features:
37-
- `alloc`: implements a global allocator using UEFI functions.
38-
- This allows you to allocate objects on the heap.
36+
**Optional crate features:**
37+
38+
- `alloc`: Enables functionality requiring the `alloc` crate from the Rust standard library.
39+
- For example, this allows many convenient `uefi-rs` functions to operate on heap data (`Box`).
40+
- It is up to the user to provide a `#[global_allocator]`.
41+
- `global_allocator`: implements a `#[global_allocator]` using UEFI functions.
42+
- This allows you to use all abstractions from the `alloc` crate from the Rust standard library
43+
during runtime. Hence, `Vec`, `Box`, etc. will be able to allocate memory.
44+
**This is optional**, so you can provide a custom `#[global_allocator]` as well.
3945
- There's no guarantee of the efficiency of UEFI's allocator.
40-
- `logger`: logging implementation for the standard [log] crate.
41-
- Prints output to console.
46+
- `logger`: logging implementation for the standard [`log`] crate.
47+
- Prints output to UEFI console.
4248
- No buffering is done: this is not a high-performance logger.
43-
- `exts`: extensions providing utility functions for common patterns.
44-
- Requires the `alloc` crate (either enable the `alloc` optional feature or your own custom allocator).
4549

4650
- `uefi-macros`: procedural macros that are used to derive some traits in `uefi`.
4751

‎book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Running in a VM](tutorial/vm.md)
88
- [How-to](how_to/introduction.md)
99
- [Using Protocols](how_to/protocols.md)
10+
- [Crate Features](how_to/crate_features.md)
1011
- [Concepts](concepts/introduction.md)
1112
- [Boot Stages](concepts/boot_stages.md)
1213
- [Tables](concepts/tables.md)

‎book/src/how_to/crate_features.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Optional Crate Features
2+
3+
There are several optional crate features provided by the `uefi` crate.
4+
5+
- `alloc`: Enables functionality requiring the `alloc` crate from the Rust standard library.
6+
- For example, this allows many convenient `uefi-rs` functions to operate on heap data (`Box`).
7+
- It is up to the user to provide a `#[global allocator]`.
8+
- `global_allocator`: implements a `#[global allocator]` using UEFI functions.
9+
- This allows you to use all abstractions from the `alloc` crate from the Rust standard library
10+
during runtime. Hence, `Vec`, `Box`, etc. will be able to allocate memory.
11+
**This is optional**, so you can provide a custom `#[global allocator]` as well.
12+
- There's no guarantee of the efficiency of UEFI's allocator.
13+
- `logger`: logging implementation for the standard [`log`] crate.
14+
- Prints output to the UEFI boot services standard text output.
15+
- No buffering is done: this is not a high-performance logger.

‎template/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ edition = "2021"
55
publish = false
66

77
[dependencies]
8-
uefi = { version = "0.18.0", features = ["exts"] }
8+
uefi = { version = "0.18.0", features = ["alloc"] }
99
uefi-services = "0.15.0"

‎uefi-services/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ is-it-maintained-issue-resolution = { repository = "rust-osdev/uefi-rs" }
1515
is-it-maintained-open-issues = { repository = "rust-osdev/uefi-rs" }
1616

1717
[dependencies]
18-
uefi = { version = "0.18.0", features = ["alloc"] }
18+
uefi = { version = "0.18.0", features = ["global_allocator"] }
1919
log = { version = "0.4.5", default-features = false }
2020
cfg-if = "1.0.0"
2121
qemu-exit = { version = "3.0.1", optional = true }

‎uefi-services/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn init(st: &mut SystemTable<Boot>) -> Result {
8383
init_logger(st);
8484

8585
let boot_services = st.boot_services();
86-
uefi::alloc::init(boot_services);
86+
uefi::global_allocator::init(boot_services);
8787

8888
// Schedule these tools to be disabled on exit from UEFI boot services
8989
boot_services
@@ -181,7 +181,7 @@ unsafe extern "efiapi" fn exit_boot_services(_e: Event, _ctx: Option<NonNull<c_v
181181
logger.disable();
182182
}
183183

184-
uefi::alloc::exit_boot_services();
184+
uefi::global_allocator::exit_boot_services();
185185
}
186186

187187
#[cfg(feature = "panic_handler")]

‎uefi-test-runner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ publish = false
66
edition = "2021"
77

88
[dependencies]
9-
uefi = { path = "../uefi", features = ['exts'] }
9+
uefi = { path = "../uefi", features = ['alloc'] }
1010
uefi-services = { path = "../uefi-services" }
1111

1212
log = { version = "0.4.11", default-features = false }

‎uefi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ license = "MPL-2.0"
1313
[features]
1414
default = ["panic-on-logger-errors"]
1515
alloc = []
16-
exts = []
16+
global_allocator = []
1717
logger = []
1818
# Ignore text output errors in logger as a workaround for firmware issues that
1919
# were observed on the VirtualBox UEFI implementation (see uefi-rs#121).

‎uefi/src/data_types/guid.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,8 @@ pub use uefi_macros::unsafe_guid;
141141

142142
#[cfg(test)]
143143
mod tests {
144-
use uefi::{guid, unsafe_guid};
145-
extern crate alloc;
146144
use super::*;
145+
use uefi::{guid, unsafe_guid};
147146

148147
#[test]
149148
fn test_guid_display() {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /