Skip to content

Commit 9b2f885

Browse files
committed
feat(hal-x86_64): make alloc a feature flag (#372)
Currently, some code in `hal-x86_64` depends on `liballoc`, while other code does not. This makes it difficult to use parts of the HAL crate in early boot environments without an allocator. This commit adds an "alloc" feature flag to `hal-x86_64`, which enables code that depends on `liballoc`. This commit was factored out of #371.
1 parent 0cac3f4 commit 9b2f885

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

hal-x86_64/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ edition = "2018"
66
license = "MIT"
77

88
[features]
9+
default = ["alloc"]
910
log = ["tracing/log"]
11+
alloc = []
1012

1113
[dependencies]
1214
acpi = "4.1.1"

hal-x86_64/src/cpu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use mycelium_util::bits;
33

44
pub mod entropy;
55
pub mod intrinsics;
6+
#[cfg(feature = "alloc")]
67
pub mod local;
78
mod msr;
89
pub use self::msr::Msr;

hal-x86_64/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
// Allow const operands in asm.
44
#![feature(asm_const)]
55
#![feature(abi_x86_interrupt)]
6-
#![feature(doc_cfg)]
6+
#![feature(doc_cfg, doc_auto_cfg)]
7+
#![feature(extern_types)]
78
// A bunch of const fn features.
89
#![feature(const_mut_refs)]
910
// Oftentimes it's necessary to write to a value at a particular location in
1011
// memory, and these types don't implement Copy to ensure they aren't
1112
// inadvertantly copied.
1213
#![allow(clippy::trivially_copy_pass_by_ref)]
13-
// Macros generated by `tracing` often generate large amounts of code, which
14-
// causes this lint to complain about relatively simple methods.
15-
#![allow(clippy::cognitive_complexity)]
1614

1715
pub(crate) use hal_core::{PAddr, VAddr};
16+
#[cfg(feature = "alloc")]
1817
extern crate alloc;
1918

2019
pub mod control_regs;

0 commit comments

Comments
 (0)