Skip to content

Commit 7aca6d6

Browse files
committed
cfg out ohos platform in dependencies
1 parent 80567bf commit 7aca6d6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ measureme_10 = { version = "10.1.3", package = "measureme" }
3232
memchr = "2"
3333
memmap2 = "0.2.1"
3434
parking_lot = "0.12.0"
35-
perf-event-open-sys2 = "5.0.6"
35+
perf-event-open-sys = "3.0.0"
3636
prettytable-rs = "0.10"
3737
rustc-hash = "1.0.1"
3838
serde = { version = "1.0", features = ["derive"] }

measureme/Cargo.toml

Lines changed: 2 additions & 2 deletions
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
21-
perf-event-open-sys2.workspace = true
21+
perf-event-open-sys.workspace = true

measureme/src/counters.rs

Lines changed: 8 additions & 6 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};
@@ -349,10 +349,12 @@ mod hw {
349349
type_: perf_type_id,
350350
hw_id: u32,
351351
) -> Result<Self, Box<dyn Error + Send + Sync>> {
352-
let mut attrs = perf_event_attr::default();
353-
attrs.size = mem::size_of::<perf_event_attr>().try_into().unwrap();
354-
attrs.type_ = type_;
355-
attrs.config = hw_id.into();
352+
let mut attrs = perf_event_attr {
353+
size: mem::size_of::<perf_event_attr>().try_into().unwrap(),
354+
type_,
355+
config: hw_id.into(),
356+
..perf_event_attr::default()
357+
};
356358

357359
// Only record same-thread, any CPUs, and only userspace (no kernel/hypervisor).
358360
// NOTE(eddyb) `pid = 0`, despite talking about "process id", means
@@ -933,7 +935,7 @@ mod hw {
933935
}
934936
}
935937

936-
#[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"))))]
937939
mod hw {
938940
use std::error::Error;
939941

0 commit comments

Comments
 (0)