about summary refs log tree commit diff
path: root/library/std/src/thread
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/thread')
-rw-r--r--library/std/src/thread/parker/futex.rs (renamed from library/std/src/thread/parker/linux.rs)35
-rw-r--r--library/std/src/thread/parker/mod.rs4
2 files changed, 3 insertions, 36 deletions
diff --git a/library/std/src/thread/parker/linux.rs b/library/std/src/thread/parker/futex.rs
index 090c83fbb40..2d7a7770508 100644
--- a/library/std/src/thread/parker/linux.rs
+++ b/library/std/src/thread/parker/futex.rs
@@ -1,5 +1,6 @@
 use crate::sync::atomic::AtomicI32;
 use crate::sync::atomic::Ordering::{Acquire, Release};
+use crate::sys::futex::{futex_wait, futex_wake};
 use crate::time::Duration;
 
 const PARKED: i32 = -1;
@@ -70,37 +71,3 @@ impl Parker {
         }
     }
 }
-
-fn futex_wait(futex: &AtomicI32, expected: i32, timeout: Option<Duration>) {
-    let timespec;
-    let timespec_ptr = match timeout {
-        Some(timeout) => {
-            timespec = libc::timespec {
-                tv_sec: timeout.as_secs() as _,
-                tv_nsec: timeout.subsec_nanos() as _,
-            };
-            &timespec as *const libc::timespec
-        }
-        None => crate::ptr::null(),
-    };
-    unsafe {
-        libc::syscall(
-            libc::SYS_futex,
-            futex as *const AtomicI32,
-            libc::FUTEX_WAIT | libc::FUTEX_PRIVATE_FLAG,
-            expected,
-            timespec_ptr,
-        );
-    }
-}
-
-fn futex_wake(futex: &AtomicI32) {
-    unsafe {
-        libc::syscall(
-            libc::SYS_futex,
-            futex as *const AtomicI32,
-            libc::FUTEX_WAKE | libc::FUTEX_PRIVATE_FLAG,
-            1,
-        );
-    }
-}
diff --git a/library/std/src/thread/parker/mod.rs b/library/std/src/thread/parker/mod.rs
index 4dc5e1aa271..23c17c8e2cf 100644
--- a/library/std/src/thread/parker/mod.rs
+++ b/library/std/src/thread/parker/mod.rs
@@ -1,7 +1,7 @@
 cfg_if::cfg_if! {
     if #[cfg(any(target_os = "linux", target_os = "android"))] {
-        mod linux;
-        pub use linux::Parker;
+        mod futex;
+        pub use futex::Parker;
     } else {
         mod generic;
         pub use generic::Parker;