Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,37 @@ extern crate vm_memory;

use criterion::{criterion_group, criterion_main, Criterion};

// Include architecture-specific benchmark modules.
// These modules are now expected to define a function (e.g., `benchmarks`)
// that will be called by the main `criterion_benchmark` function.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod x86_64;
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use x86_64::*;

#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
mod fdt;
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
pub use fdt::*;

// Define the main benchmark function which dispatches to architecture-specific benchmarks.
// This centralizes the benchmark entry point and allows for more robust
// #[cfg] handling for 'all-features' compilation scenarios.
// If specific features cause conflicts for certain architectures,
// additional `#[cfg(feature = "...")]` guards can be added here
// around the calls to `x86_64::benchmarks` or `fdt::benchmarks`,
// or within the respective `x86_64` or `fdt` modules themselves.
fn criterion_benchmark(c: &mut Criterion) {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
// The x86_64 module is expected to provide a `benchmarks` function.
x86_64::benchmarks(c);

#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
// The fdt module is expected to provide a `benchmarks` function.
fdt::benchmarks(c);

// If no architecture-specific benchmarks are enabled (e.g., for an unsupported
// target_arch or if specific feature combinations disable benchmarks),
// this function will simply do nothing. This ensures that `criterion_benchmark`
// always exists and compiles, preventing "undefined function" errors from the
// `criterion_group!` macro during `all-features` and `all-targets` builds.
}

criterion_group! {
name = benches;
Expand All @@ -29,4 +51,4 @@ criterion_group! {

criterion_main! {
benches
}
}
3 changes: 2 additions & 1 deletion src/loader_gen/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@

// Hide the autogenerated documentation for bindgen'ed sources.
#[doc(hidden)]
#[cfg(feature = "elf")]
pub mod bootparam;

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

#[cfg(feature = "elf")]
pub mod start_info;
pub mod start_info;