Skip to content

Commit 898484d

Browse files
committed
fix: build on windows
1 parent 8b63059 commit 898484d

File tree

1 file changed

+13
-4
lines changed
  • crates/codspeed/src/instrument_hooks

1 file changed

+13
-4
lines changed

crates/codspeed/src/instrument_hooks/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ mod ffi;
33

44
#[cfg(use_instrument_hooks)]
55
mod linux_impl {
6-
use nix::sys::time::TimeValLike;
76

87
use super::ffi;
98
use std::ffi::CString;
@@ -116,9 +115,19 @@ mod linux_impl {
116115

117116
#[inline(always)]
118117
pub fn current_timestamp() -> u64 {
119-
nix::time::clock_gettime(nix::time::ClockId::CLOCK_MONOTONIC)
120-
.expect("Failed to get current time")
121-
.num_nanoseconds() as u64
118+
#[cfg(target_os = "linux")]
119+
{
120+
use nix::sys::time::TimeValLike;
121+
122+
nix::time::clock_gettime(nix::time::ClockId::CLOCK_MONOTONIC)
123+
.expect("Failed to get current time")
124+
.num_nanoseconds() as u64
125+
}
126+
127+
#[cfg(not(target_os = "linux"))]
128+
unsafe {
129+
ffi::instrument_hooks_current_timestamp()
130+
}
122131
}
123132
}
124133

0 commit comments

Comments
 (0)