about summary refs log tree commit diff
path: root/library/std/src/sys/unix/futex.rs
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2022-05-03 12:32:41 +0200
committerMara Bos <m-ou.se@m-ou.se>2022-05-03 12:37:52 +0200
commit8ee9b93c4f5b6a7f035540c2e4a151232cd1c6cf (patch)
tree370a376667ef8d94c5d44973d09cf4324962a3c1 /library/std/src/sys/unix/futex.rs
parent7b7d1d6c4835d4e84517cc825aacb817d6435696 (diff)
downloadrust-8ee9b93c4f5b6a7f035540c2e4a151232cd1c6cf.tar.gz
rust-8ee9b93c4f5b6a7f035540c2e4a151232cd1c6cf.zip
Add #[cfg] in cfg_if for linux in unix/futex.
Diffstat (limited to 'library/std/src/sys/unix/futex.rs')
-rw-r--r--library/std/src/sys/unix/futex.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/library/std/src/sys/unix/futex.rs b/library/std/src/sys/unix/futex.rs
index f91367da89c..6156cc6b7d2 100644
--- a/library/std/src/sys/unix/futex.rs
+++ b/library/std/src/sys/unix/futex.rs
@@ -33,8 +33,6 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
             return true;
         }
 
-        // Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT to be able to give an
-        // absolute time rather than a relative time.
         let r = unsafe {
             cfg_if::cfg_if! {
                 if #[cfg(target_os = "freebsd")] {
@@ -56,7 +54,9 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
                         crate::ptr::invalid_mut(umtx_timeout_size),
                         umtx_timeout_ptr as *mut _,
                     )
-                } else {
+                } else if #[cfg(any(target_os = "linux", target_os = "android"))] {
+                    // Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT to be able to give an
+                    // absolute time rather than a relative time.
                     libc::syscall(
                         libc::SYS_futex,
                         futex as *const AtomicU32,
@@ -66,6 +66,8 @@ pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -
                         null::<u32>(), // This argument is unused for FUTEX_WAIT_BITSET.
                         !0u32,         // A full bitmask, to make it behave like a regular FUTEX_WAIT.
                     )
+                } else {
+                    compile_error!("unknown target_os");
                 }
             }
         };