Skip to content

Commit 476f9b5

Browse files
authored
Drop perf counter dependencies for ohos target (#238)
1 parent 730aa7e commit 476f9b5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

measureme/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ smallvec.workspace = true
1616
[features]
1717
nightly = []
1818

19-
[target.'cfg(all(target_arch = "x86_64", target_os = "linux"))'.dependencies]
19+
[target.'cfg(all(target_arch = "x86_64", target_os = "linux", not(target_env = "ohos")))'.dependencies]
2020
memmap2.workspace = true
2121
perf-event-open-sys.workspace = true

measureme/src/counters.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ const BUG_REPORT_MSG: &str =
303303
"please report this to https://github.com/rust-lang/measureme/issues/new";
304304

305305
/// Linux x86_64 implementation based on `perf_event_open` and `rdpmc`.
306-
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
306+
#[cfg(all(target_arch = "x86_64", target_os = "linux", not(target_env = "ohos")))]
307307
mod hw {
308308
use memmap2::{Mmap, MmapOptions};
309309
use perf_event_open_sys::{bindings::*, perf_event_open};
@@ -935,7 +935,7 @@ mod hw {
935935
}
936936
}
937937

938-
#[cfg(not(all(target_arch = "x86_64", target_os = "linux")))]
938+
#[cfg(not(all(target_arch = "x86_64", target_os = "linux", not(target_env = "ohos"))))]
939939
mod hw {
940940
use std::error::Error;
941941

@@ -994,6 +994,10 @@ mod hw {
994994
add_error("only supported OS is Linux");
995995
}
996996

997+
if cfg!(target_env = "ohos") {
998+
add_error("unsupported OHOS environment");
999+
}
1000+
9971001
Err(msg.into())
9981002
}
9991003
}

0 commit comments

Comments
 (0)