Skip to content

Commit b4c0712

Browse files
allow deprecation warning on musl
time_t will change the type from a 32 bit value to a 64 bit value on 32-bit architectures (it's defined as c_ulong). This should have no impact for the products (that we know of) using vmm-sys-util because they're running on 64 bit anyway. Signed-off-by: Andreea Florescu <[email protected]>
1 parent d9da493 commit b4c0712

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/linux/timerfd.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,21 @@ impl TimerFd {
6666
pub fn reset(&mut self, dur: Duration, interval: Option<Duration>) -> Result<()> {
6767
// Safe because we are zero-initializing a struct with only primitive member fields.
6868
let mut spec: libc::itimerspec = unsafe { mem::zeroed() };
69-
spec.it_value.tv_sec = dur.as_secs() as libc::time_t;
69+
// https://github.com/rust-lang/libc/issues/1848
70+
#[cfg_attr(target_env = "musl", allow(deprecated))]
71+
{
72+
spec.it_value.tv_sec = dur.as_secs() as libc::time_t;
73+
}
7074
// nsec always fits in i32 because subsec_nanos is defined to be less than one billion.
7175
let nsec = dur.subsec_nanos() as i32;
7276
spec.it_value.tv_nsec = libc::c_long::from(nsec);
7377

7478
if let Some(int) = interval {
75-
spec.it_interval.tv_sec = int.as_secs() as libc::time_t;
79+
// https://github.com/rust-lang/libc/issues/1848
80+
#[cfg_attr(target_env = "musl", allow(deprecated))]
81+
{
82+
spec.it_interval.tv_sec = int.as_secs() as libc::time_t;
83+
}
7684
// nsec always fits in i32 because subsec_nanos is defined to be less than one billion.
7785
let nsec = int.subsec_nanos() as i32;
7886
spec.it_interval.tv_nsec = libc::c_long::from(nsec);

0 commit comments

Comments
 (0)