Skip to content

Commit

Permalink
Drop perf counter dependencies for ohos target (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuuuXXX authored Dec 22, 2024
1 parent 730aa7e commit 476f9b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion measureme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 6 additions & 2 deletions measureme/src/counters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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())
}
}
Expand Down

0 comments on commit 476f9b5

Please sign in to comment.