Skip to content

Commit

Permalink
feat(hal-x86_64): make alloc a feature flag (#372)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hawkw committed Nov 16, 2022
1 parent 0cac3f4 commit 9b2f885
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions hal-x86_64/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ edition = "2018"
license = "MIT"

[features]
default = ["alloc"]
log = ["tracing/log"]
alloc = []

[dependencies]
acpi = "4.1.1"
Expand Down
1 change: 1 addition & 0 deletions hal-x86_64/src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use mycelium_util::bits;

pub mod entropy;
pub mod intrinsics;
#[cfg(feature = "alloc")]
pub mod local;
mod msr;
pub use self::msr::Msr;
Expand Down
7 changes: 3 additions & 4 deletions hal-x86_64/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
// Allow const operands in asm.
#![feature(asm_const)]
#![feature(abi_x86_interrupt)]
#![feature(doc_cfg)]
#![feature(doc_cfg, doc_auto_cfg)]
#![feature(extern_types)]
// A bunch of const fn features.
#![feature(const_mut_refs)]
// Oftentimes it's necessary to write to a value at a particular location in
// memory, and these types don't implement Copy to ensure they aren't
// inadvertantly copied.
#![allow(clippy::trivially_copy_pass_by_ref)]
// Macros generated by `tracing` often generate large amounts of code, which
// causes this lint to complain about relatively simple methods.
#![allow(clippy::cognitive_complexity)]

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

pub mod control_regs;
Expand Down

0 comments on commit 9b2f885

Please sign in to comment.