diff --git a/measureme/Cargo.toml b/measureme/Cargo.toml index 9c9f879..059d7f2 100644 --- a/measureme/Cargo.toml +++ b/measureme/Cargo.toml @@ -16,6 +16,6 @@ smallvec.workspace = true [features] nightly = [] -[target.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.dependencies] +[target.'cfg(all(target_arch = "x86_64", target_os = "linux", not(target_env = "ohos")))'.dependencies] memmap2.workspace = true perf-event-open-sys.workspace = true diff --git a/measureme/src/counters.rs b/measureme/src/counters.rs index f513527..18d5e63 100644 --- a/measureme/src/counters.rs +++ b/measureme/src/counters.rs @@ -303,7 +303,7 @@ const BUG_REPORT_MSG: &str = "please report this to https://github.com/rust-lang/measureme/issues/new"; /// Linux x86_64 implementation based on `perf_event_open` and `rdpmc`. -#[cfg(all(target_arch = "x86_64", target_os = "linux"))] +#[cfg(all(target_arch = "x86_64", target_os = "linux", not(target_env = "ohos")))] mod hw { use memmap2::{Mmap, MmapOptions}; use perf_event_open_sys::{bindings::*, perf_event_open}; @@ -935,7 +935,7 @@ mod hw { } } -#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))] +#[cfg(not(all(target_arch = "x86_64", target_os = "linux", not(target_env = "ohos"))))] mod hw { use std::error::Error; @@ -994,6 +994,10 @@ mod hw { add_error("only supported OS is Linux"); } + if cfg!(target_env = "ohos") { + add_error("unsupported OHOS environment"); + } + Err(msg.into()) } }