Skip to content

Commit 4115fd6

Browse files
committed
fc_util: correctly label x86_64 specific func
On other architectures different than x86_64, the function will return a dummy value. Signed-off-by: Diana Popa <[email protected]>
1 parent b172068 commit 4115fd6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fc_util/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ extern crate libc;
55

66
pub mod validators;
77

8-
#[cfg(target_arch = "x86_64")]
98
pub fn timestamp_cycles() -> u64 {
9+
#[cfg(target_arch = "x86_64")]
1010
// Safe because there's nothing that can go wrong with this call.
11-
unsafe { std::arch::x86_64::_rdtsc() as u64 }
11+
unsafe {
12+
std::arch::x86_64::_rdtsc() as u64
13+
}
14+
#[cfg(not(target_arch = "x86_64"))]
15+
0
1216
}
1317

1418
fn timespec_to_us(time_struct: &libc::timespec) -> u64 {
@@ -29,6 +33,7 @@ pub fn now_cputime_us() -> u64 {
2933
mod tests {
3034
use super::*;
3135

36+
#[cfg(target_arch = "x86_64")]
3237
#[test]
3338
fn test_timestamp_cycles() {
3439
for _ in 0..1000 {

0 commit comments

Comments
 (0)