Skip to content

Commit 8ee9b93

Browse files
committed
Add #[cfg] in cfg_if for linux in unix/futex.
1 parent 7b7d1d6 commit 8ee9b93

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

library/std/src/sys/unix/futex.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
3333
return true;
3434
}
3535

36-
// Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT to be able to give an
37-
// absolute time rather than a relative time.
3836
let r = unsafe {
3937
cfg_if::cfg_if! {
4038
if #[cfg(target_os = "freebsd")] {
@@ -56,7 +54,9 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
5654
crate::ptr::invalid_mut(umtx_timeout_size),
5755
umtx_timeout_ptr as *mut _,
5856
)
59-
} else {
57+
} else if #[cfg(any(target_os = "linux", target_os = "android"))] {
58+
// Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT to be able to give an
59+
// absolute time rather than a relative time.
6060
libc::syscall(
6161
libc::SYS_futex,
6262
futex as *const AtomicU32,
@@ -66,6 +66,8 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
6666
null::<u32>(), // This argument is unused for FUTEX_WAIT_BITSET.
6767
!0u32, // A full bitmask, to make it behave like a regular FUTEX_WAIT.
6868
)
69+
} else {
70+
compile_error!("unknown target_os");
6971
}
7072
}
7173
};

0 commit comments

Comments
 (0)