diff --git a/.reuse/dep5 b/.reuse/dep5 index 2c3adf1bfa1ba..6c39025b5de0d 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -52,7 +52,7 @@ Copyright: 2019 The Crossbeam Project Developers The Rust Project Developers (see https://thanks.rust-lang.org) License: MIT OR Apache-2.0 -Files: library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs +Files: library/std/src/sys/locks/mutex/fuchsia.rs Copyright: 2016 The Fuchsia Authors The Rust Project Developers (see https://thanks.rust-lang.org) License: BSD-2-Clause AND (MIT OR Apache-2.0) diff --git a/library/std/src/sys/pal/unix/locks/futex_condvar.rs b/library/std/src/sys/locks/condvar/futex.rs similarity index 98% rename from library/std/src/sys/pal/unix/locks/futex_condvar.rs rename to library/std/src/sys/locks/condvar/futex.rs index 4bd65dd25c292..3ad93ce07f753 100644 --- a/library/std/src/sys/pal/unix/locks/futex_condvar.rs +++ b/library/std/src/sys/locks/condvar/futex.rs @@ -1,6 +1,6 @@ -use super::Mutex; use crate::sync::atomic::{AtomicU32, Ordering::Relaxed}; use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; +use crate::sys::locks::Mutex; use crate::time::Duration; pub struct Condvar { diff --git a/library/std/src/sys/pal/itron/condvar.rs b/library/std/src/sys/locks/condvar/itron.rs similarity index 98% rename from library/std/src/sys/pal/itron/condvar.rs rename to library/std/src/sys/locks/condvar/itron.rs index 7a47cc6696a34..4c6f5e9dad269 100644 --- a/library/std/src/sys/pal/itron/condvar.rs +++ b/library/std/src/sys/locks/condvar/itron.rs @@ -1,5 +1,7 @@ //! POSIX conditional variable implementation based on user-space wait queues. -use super::{abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong}; +use crate::sys::pal::itron::{ + abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong, +}; use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration}; // The implementation is inspired by the queue-based implementation shown in diff --git a/library/std/src/sys/locks/condvar/mod.rs b/library/std/src/sys/locks/condvar/mod.rs new file mode 100644 index 0000000000000..126a42a2a4c00 --- /dev/null +++ b/library/std/src/sys/locks/condvar/mod.rs @@ -0,0 +1,36 @@ +cfg_if::cfg_if! { + if #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "freebsd", + target_os = "openbsd", + target_os = "dragonfly", + target_os = "fuchsia", + all(target_family = "wasm", target_feature = "atomics"), + target_os = "hermit", + ))] { + mod futex; + pub use futex::Condvar; + } else if #[cfg(target_family = "unix")] { + mod pthread; + pub use pthread::Condvar; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::Condvar; + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::Condvar; + } else if #[cfg(target_os = "solid_asp3")] { + mod itron; + pub use itron::Condvar; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + pub use teeos::Condvar; + } else if #[cfg(target_os = "xous")] { + mod xous; + pub use xous::Condvar; + } else { + mod no_threads; + pub use no_threads::Condvar; + } +} diff --git a/library/std/src/sys/pal/unsupported/locks/condvar.rs b/library/std/src/sys/locks/condvar/no_threads.rs similarity index 100% rename from library/std/src/sys/pal/unsupported/locks/condvar.rs rename to library/std/src/sys/locks/condvar/no_threads.rs diff --git a/library/std/src/sys/pal/unix/locks/pthread_condvar.rs b/library/std/src/sys/locks/condvar/pthread.rs similarity index 97% rename from library/std/src/sys/pal/unix/locks/pthread_condvar.rs rename to library/std/src/sys/locks/condvar/pthread.rs index 2dc1b0c601e78..094738d5a3f2c 100644 --- a/library/std/src/sys/pal/unix/locks/pthread_condvar.rs +++ b/library/std/src/sys/locks/condvar/pthread.rs @@ -1,7 +1,7 @@ use crate::cell::UnsafeCell; use crate::ptr; use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed}; -use crate::sys::locks::{pthread_mutex, Mutex}; +use crate::sys::locks::{mutex, Mutex}; #[cfg(not(target_os = "nto"))] use crate::sys::time::TIMESPEC_MAX; #[cfg(target_os = "nto")] @@ -112,7 +112,7 @@ impl Condvar { #[inline] pub unsafe fn wait(&self, mutex: &Mutex) { - let mutex = pthread_mutex::raw(mutex); + let mutex = mutex::raw(mutex); self.verify(mutex); let r = libc::pthread_cond_wait(raw(self), mutex); debug_assert_eq!(r, 0); @@ -134,7 +134,7 @@ impl Condvar { pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool { use crate::sys::time::Timespec; - let mutex = pthread_mutex::raw(mutex); + let mutex = mutex::raw(mutex); self.verify(mutex); #[cfg(not(target_os = "nto"))] @@ -170,7 +170,7 @@ impl Condvar { use crate::sys::time::SystemTime; use crate::time::Instant; - let mutex = pthread_mutex::raw(mutex); + let mutex = mutex::raw(mutex); self.verify(mutex); // OSX implementation of `pthread_cond_timedwait` is buggy diff --git a/library/std/src/sys/pal/sgx/condvar.rs b/library/std/src/sys/locks/condvar/sgx.rs similarity index 94% rename from library/std/src/sys/pal/sgx/condvar.rs rename to library/std/src/sys/locks/condvar/sgx.rs index aa1174664aeb0..cabd3250275a8 100644 --- a/library/std/src/sys/pal/sgx/condvar.rs +++ b/library/std/src/sys/locks/condvar/sgx.rs @@ -1,9 +1,8 @@ use crate::sys::locks::Mutex; +use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable}; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; use crate::time::Duration; -use super::waitqueue::{SpinMutex, WaitQueue, WaitVariable}; - /// FIXME: `UnsafeList` is not movable. struct AllocatedCondvar(SpinMutex>); diff --git a/library/std/src/sys/pal/teeos/locks/condvar.rs b/library/std/src/sys/locks/condvar/teeos.rs similarity index 100% rename from library/std/src/sys/pal/teeos/locks/condvar.rs rename to library/std/src/sys/locks/condvar/teeos.rs diff --git a/library/std/src/sys/pal/windows/locks/condvar.rs b/library/std/src/sys/locks/condvar/windows.rs similarity index 95% rename from library/std/src/sys/pal/windows/locks/condvar.rs rename to library/std/src/sys/locks/condvar/windows.rs index 953bcc27dee0d..28a288335d2fb 100644 --- a/library/std/src/sys/pal/windows/locks/condvar.rs +++ b/library/std/src/sys/locks/condvar/windows.rs @@ -27,7 +27,7 @@ impl Condvar { let r = c::SleepConditionVariableSRW( self.inner.get(), mutex::raw(mutex), - crate::sys::pal::windows::dur2timeout(dur), + crate::sys::pal::dur2timeout(dur), 0, ); if r == 0 { diff --git a/library/std/src/sys/pal/xous/locks/condvar.rs b/library/std/src/sys/locks/condvar/xous.rs similarity index 99% rename from library/std/src/sys/pal/xous/locks/condvar.rs rename to library/std/src/sys/locks/condvar/xous.rs index 510235046e195..0e51449e0afa4 100644 --- a/library/std/src/sys/pal/xous/locks/condvar.rs +++ b/library/std/src/sys/locks/condvar/xous.rs @@ -1,6 +1,6 @@ -use super::mutex::Mutex; use crate::os::xous::ffi::{blocking_scalar, scalar}; use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; +use crate::sys::locks::Mutex; use crate::time::Duration; use core::sync::atomic::{AtomicUsize, Ordering}; diff --git a/library/std/src/sys/pal/unsupported/locks/mod.rs b/library/std/src/sys/locks/mod.rs similarity index 99% rename from library/std/src/sys/pal/unsupported/locks/mod.rs rename to library/std/src/sys/locks/mod.rs index 0e0f9eccb2137..0bdc4a1e1db81 100644 --- a/library/std/src/sys/pal/unsupported/locks/mod.rs +++ b/library/std/src/sys/locks/mod.rs @@ -1,6 +1,7 @@ mod condvar; mod mutex; mod rwlock; + pub use condvar::Condvar; pub use mutex::Mutex; pub use rwlock::RwLock; diff --git a/library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs b/library/std/src/sys/locks/mutex/fuchsia.rs similarity index 100% rename from library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs rename to library/std/src/sys/locks/mutex/fuchsia.rs diff --git a/library/std/src/sys/pal/unix/locks/futex_mutex.rs b/library/std/src/sys/locks/mutex/futex.rs similarity index 100% rename from library/std/src/sys/pal/unix/locks/futex_mutex.rs rename to library/std/src/sys/locks/mutex/futex.rs diff --git a/library/std/src/sys/pal/itron/mutex.rs b/library/std/src/sys/locks/mutex/itron.rs similarity index 85% rename from library/std/src/sys/pal/itron/mutex.rs rename to library/std/src/sys/locks/mutex/itron.rs index 1f6cc41947602..a134eb2d1beca 100644 --- a/library/std/src/sys/pal/itron/mutex.rs +++ b/library/std/src/sys/locks/mutex/itron.rs @@ -1,6 +1,6 @@ //! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and //! `TA_INHERIT` are available. -use super::{ +use crate::sys::pal::itron::{ abi, error::{expect_success, expect_success_aborting, fail, ItronError}, spin::SpinIdOnceCell, @@ -66,20 +66,3 @@ impl Drop for Mutex { } } } - -pub(super) struct MutexGuard<'a>(&'a Mutex); - -impl<'a> MutexGuard<'a> { - #[inline] - pub(super) fn lock(x: &'a Mutex) -> Self { - x.lock(); - Self(x) - } -} - -impl Drop for MutexGuard<'_> { - #[inline] - fn drop(&mut self) { - unsafe { self.0.unlock() }; - } -} diff --git a/library/std/src/sys/locks/mutex/mod.rs b/library/std/src/sys/locks/mutex/mod.rs new file mode 100644 index 0000000000000..710cb91fb1473 --- /dev/null +++ b/library/std/src/sys/locks/mutex/mod.rs @@ -0,0 +1,38 @@ +cfg_if::cfg_if! { + if #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "freebsd", + target_os = "openbsd", + target_os = "dragonfly", + all(target_family = "wasm", target_feature = "atomics"), + target_os = "hermit", + ))] { + mod futex; + pub use futex::Mutex; + } else if #[cfg(target_os = "fuchsia")] { + mod fuchsia; + pub use fuchsia::Mutex; + } else if #[cfg(any( + target_family = "unix", + target_os = "teeos", + ))] { + mod pthread; + pub use pthread::{Mutex, raw}; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::{Mutex, raw}; + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::Mutex; + } else if #[cfg(target_os = "solid_asp3")] { + mod itron; + pub use itron::Mutex; + } else if #[cfg(target_os = "xous")] { + mod xous; + pub use xous::Mutex; + } else { + mod no_threads; + pub use no_threads::Mutex; + } +} diff --git a/library/std/src/sys/pal/unsupported/locks/mutex.rs b/library/std/src/sys/locks/mutex/no_threads.rs similarity index 100% rename from library/std/src/sys/pal/unsupported/locks/mutex.rs rename to library/std/src/sys/locks/mutex/no_threads.rs diff --git a/library/std/src/sys/pal/unix/locks/pthread_mutex.rs b/library/std/src/sys/locks/mutex/pthread.rs similarity index 100% rename from library/std/src/sys/pal/unix/locks/pthread_mutex.rs rename to library/std/src/sys/locks/mutex/pthread.rs diff --git a/library/std/src/sys/pal/sgx/mutex.rs b/library/std/src/sys/locks/mutex/sgx.rs similarity index 94% rename from library/std/src/sys/pal/sgx/mutex.rs rename to library/std/src/sys/locks/mutex/sgx.rs index 0dbf020ebe06a..d37bd02adf8dd 100644 --- a/library/std/src/sys/pal/sgx/mutex.rs +++ b/library/std/src/sys/locks/mutex/sgx.rs @@ -1,4 +1,4 @@ -use super::waitqueue::{try_lock_or_false, SpinMutex, WaitQueue, WaitVariable}; +use crate::sys::pal::waitqueue::{try_lock_or_false, SpinMutex, WaitQueue, WaitVariable}; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; /// FIXME: `UnsafeList` is not movable. diff --git a/library/std/src/sys/pal/windows/locks/mutex.rs b/library/std/src/sys/locks/mutex/windows.rs similarity index 100% rename from library/std/src/sys/pal/windows/locks/mutex.rs rename to library/std/src/sys/locks/mutex/windows.rs diff --git a/library/std/src/sys/pal/xous/locks/mutex.rs b/library/std/src/sys/locks/mutex/xous.rs similarity index 100% rename from library/std/src/sys/pal/xous/locks/mutex.rs rename to library/std/src/sys/locks/mutex/xous.rs diff --git a/library/std/src/sys/pal/unix/locks/futex_rwlock.rs b/library/std/src/sys/locks/rwlock/futex.rs similarity index 100% rename from library/std/src/sys/pal/unix/locks/futex_rwlock.rs rename to library/std/src/sys/locks/rwlock/futex.rs diff --git a/library/std/src/sys/locks/rwlock/mod.rs b/library/std/src/sys/locks/rwlock/mod.rs new file mode 100644 index 0000000000000..0564f1fe6fab9 --- /dev/null +++ b/library/std/src/sys/locks/rwlock/mod.rs @@ -0,0 +1,36 @@ +cfg_if::cfg_if! { + if #[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "freebsd", + target_os = "openbsd", + target_os = "dragonfly", + target_os = "fuchsia", + all(target_family = "wasm", target_feature = "atomics"), + target_os = "hermit", + ))] { + mod futex; + pub use futex::RwLock; + } else if #[cfg(target_family = "unix")] { + mod queue; + pub use queue::RwLock; + } else if #[cfg(target_os = "windows")] { + mod windows; + pub use windows::RwLock; + } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { + mod sgx; + pub use sgx::RwLock; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + pub use solid::RwLock; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + pub use teeos::RwLock; + } else if #[cfg(target_os = "xous")] { + mod xous; + pub use xous::RwLock; + } else { + mod no_threads; + pub use no_threads::RwLock; + } +} diff --git a/library/std/src/sys/pal/unsupported/locks/rwlock.rs b/library/std/src/sys/locks/rwlock/no_threads.rs similarity index 100% rename from library/std/src/sys/pal/unsupported/locks/rwlock.rs rename to library/std/src/sys/locks/rwlock/no_threads.rs diff --git a/library/std/src/sys/pal/unix/locks/queue_rwlock.rs b/library/std/src/sys/locks/rwlock/queue.rs similarity index 100% rename from library/std/src/sys/pal/unix/locks/queue_rwlock.rs rename to library/std/src/sys/locks/rwlock/queue.rs diff --git a/library/std/src/sys/pal/sgx/rwlock.rs b/library/std/src/sys/locks/rwlock/sgx.rs similarity index 99% rename from library/std/src/sys/pal/sgx/rwlock.rs rename to library/std/src/sys/locks/rwlock/sgx.rs index ebae1cff0ee17..136dea597bb0c 100644 --- a/library/std/src/sys/pal/sgx/rwlock.rs +++ b/library/std/src/sys/locks/rwlock/sgx.rs @@ -1,13 +1,12 @@ #[cfg(test)] mod tests; +use crate::alloc::Layout; use crate::num::NonZero; -use crate::sys_common::lazy_box::{LazyBox, LazyInit}; - -use super::waitqueue::{ +use crate::sys::pal::waitqueue::{ try_lock_or_false, NotifiedTcs, SpinMutex, SpinMutexGuard, WaitQueue, WaitVariable, }; -use crate::alloc::Layout; +use crate::sys_common::lazy_box::{LazyBox, LazyInit}; struct AllocatedRwLock { readers: SpinMutex>>>, diff --git a/library/std/src/sys/pal/solid/rwlock.rs b/library/std/src/sys/locks/rwlock/solid.rs similarity index 99% rename from library/std/src/sys/pal/solid/rwlock.rs rename to library/std/src/sys/locks/rwlock/solid.rs index ecb4eb83b9b05..9bf6f5dbb731e 100644 --- a/library/std/src/sys/pal/solid/rwlock.rs +++ b/library/std/src/sys/locks/rwlock/solid.rs @@ -1,5 +1,5 @@ //! A readers-writer lock implementation backed by the SOLID kernel extension. -use super::{ +use crate::sys::pal::{ abi, itron::{ error::{expect_success, expect_success_aborting, fail, ItronError}, diff --git a/library/std/src/sys/pal/teeos/locks/rwlock.rs b/library/std/src/sys/locks/rwlock/teeos.rs similarity index 100% rename from library/std/src/sys/pal/teeos/locks/rwlock.rs rename to library/std/src/sys/locks/rwlock/teeos.rs diff --git a/library/std/src/sys/pal/windows/locks/rwlock.rs b/library/std/src/sys/locks/rwlock/windows.rs similarity index 100% rename from library/std/src/sys/pal/windows/locks/rwlock.rs rename to library/std/src/sys/locks/rwlock/windows.rs diff --git a/library/std/src/sys/pal/xous/locks/rwlock.rs b/library/std/src/sys/locks/rwlock/xous.rs similarity index 100% rename from library/std/src/sys/pal/xous/locks/rwlock.rs rename to library/std/src/sys/locks/rwlock/xous.rs diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index fae21636897b8..d77ac7eb027dc 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -6,6 +6,7 @@ mod pal; mod personality; pub mod cmath; +pub mod locks; pub mod os_str; pub mod path; diff --git a/library/std/src/sys/pal/hermit/mod.rs b/library/std/src/sys/pal/hermit/mod.rs index 57cc656e266a1..ada408107dc36 100644 --- a/library/std/src/sys/pal/hermit/mod.rs +++ b/library/std/src/sys/pal/hermit/mod.rs @@ -39,16 +39,6 @@ pub mod thread_local_dtor; pub mod thread_local_key; pub mod time; -#[path = "../unix/locks"] -pub mod locks { - mod futex_condvar; - mod futex_mutex; - mod futex_rwlock; - pub(crate) use futex_condvar::Condvar; - pub(crate) use futex_mutex::Mutex; - pub(crate) use futex_rwlock::RwLock; -} - use crate::io::ErrorKind; use crate::os::hermit::abi; diff --git a/library/std/src/sys/pal/sgx/mod.rs b/library/std/src/sys/pal/sgx/mod.rs index 46f3e5b401da5..8ef3495884f2a 100644 --- a/library/std/src/sys/pal/sgx/mod.rs +++ b/library/std/src/sys/pal/sgx/mod.rs @@ -9,8 +9,6 @@ use crate::io::ErrorKind; use crate::sync::atomic::{AtomicBool, Ordering}; pub mod abi; -mod waitqueue; - pub mod alloc; pub mod args; pub mod env; @@ -31,16 +29,7 @@ pub mod thread; pub mod thread_local_key; pub mod thread_parking; pub mod time; - -mod condvar; -mod mutex; -mod rwlock; - -pub mod locks { - pub use super::condvar::*; - pub use super::mutex::*; - pub use super::rwlock::*; -} +pub mod waitqueue; // SAFETY: must be called only once during runtime initialization. // NOTE: this is not guaranteed to run, for example when Rust code is called externally. diff --git a/library/std/src/sys/pal/solid/abi/fs.rs b/library/std/src/sys/pal/solid/abi/fs.rs index 32800bd9a9d0a..49526f4c9cd4d 100644 --- a/library/std/src/sys/pal/solid/abi/fs.rs +++ b/library/std/src/sys/pal/solid/abi/fs.rs @@ -1,9 +1,8 @@ //! `solid_fs.h` use crate::os::raw::{c_char, c_int, c_uchar}; pub use libc::{ - blksize_t, dev_t, ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, - O_TRUNC, O_WRONLY, SEEK_CUR, SEEK_END, SEEK_SET, S_IEXEC, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, - S_IFMT, S_IFREG, S_IREAD, S_IWRITE, + ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, + SEEK_CUR, SEEK_END, SEEK_SET, S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFMT, S_IFREG, S_IWRITE, }; pub const O_ACCMODE: c_int = 0x3; diff --git a/library/std/src/sys/pal/solid/abi/sockets.rs b/library/std/src/sys/pal/solid/abi/sockets.rs index eb06a6dd927e6..11c430360ce88 100644 --- a/library/std/src/sys/pal/solid/abi/sockets.rs +++ b/library/std/src/sys/pal/solid/abi/sockets.rs @@ -1,5 +1,5 @@ use crate::os::raw::{c_char, c_uint, c_void}; -pub use libc::{c_int, c_long, size_t, ssize_t, suseconds_t, time_t, timeval}; +pub use libc::{c_int, c_long, size_t, ssize_t, timeval}; pub const SOLID_NET_ERR_BASE: c_int = -2000; pub const EINPROGRESS: c_int = SOLID_NET_ERR_BASE - libc::EINPROGRESS; diff --git a/library/std/src/sys/pal/solid/mod.rs b/library/std/src/sys/pal/solid/mod.rs index be8e00339021f..9ada7d130f050 100644 --- a/library/std/src/sys/pal/solid/mod.rs +++ b/library/std/src/sys/pal/solid/mod.rs @@ -2,19 +2,17 @@ #![allow(missing_docs, nonstandard_style)] #![deny(unsafe_op_in_unsafe_fn)] -mod abi; +pub mod abi; #[path = "../itron"] -mod itron { - pub(super) mod abi; - pub mod condvar; - pub(super) mod error; - pub mod mutex; - pub(super) mod spin; - pub(super) mod task; +pub mod itron { + pub mod abi; + pub mod error; + pub mod spin; + pub mod task; pub mod thread; pub mod thread_parking; - pub(super) mod time; + pub mod time; use super::unsupported; } @@ -41,14 +39,6 @@ pub mod thread_local_key; pub use self::itron::thread_parking; pub mod time; -mod rwlock; - -pub mod locks { - pub use super::itron::condvar::*; - pub use super::itron::mutex::*; - pub use super::rwlock::*; -} - // SAFETY: must be called only once during runtime initialization. // NOTE: this is not guaranteed to run, for example when Rust code is called externally. pub unsafe fn init(_argc: isize, _argv: *const *const u8, _sigpipe: u8) {} diff --git a/library/std/src/sys/pal/teeos/locks/mod.rs b/library/std/src/sys/pal/teeos/locks/mod.rs deleted file mode 100644 index c58e9c7fd4541..0000000000000 --- a/library/std/src/sys/pal/teeos/locks/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod condvar; -#[path = "../../unix/locks/pthread_mutex.rs"] -pub mod mutex; -pub mod rwlock; - -pub(crate) use condvar::Condvar; -pub(crate) use mutex::Mutex; -pub(crate) use rwlock::RwLock; diff --git a/library/std/src/sys/pal/teeos/mod.rs b/library/std/src/sys/pal/teeos/mod.rs index 7953104486c56..51ef96a69a0f9 100644 --- a/library/std/src/sys/pal/teeos/mod.rs +++ b/library/std/src/sys/pal/teeos/mod.rs @@ -13,7 +13,6 @@ pub mod alloc; pub mod args; #[path = "../unsupported/env.rs"] pub mod env; -pub mod locks; //pub mod fd; #[path = "../unsupported/fs.rs"] pub mod fs; diff --git a/library/std/src/sys/pal/uefi/mod.rs b/library/std/src/sys/pal/uefi/mod.rs index 5a96b8f1c3a07..ff8e3bd32adfe 100644 --- a/library/std/src/sys/pal/uefi/mod.rs +++ b/library/std/src/sys/pal/uefi/mod.rs @@ -19,8 +19,6 @@ pub mod env; pub mod fs; #[path = "../unsupported/io.rs"] pub mod io; -#[path = "../unsupported/locks/mod.rs"] -pub mod locks; #[path = "../unsupported/net.rs"] pub mod net; #[path = "../unsupported/once.rs"] diff --git a/library/std/src/sys/pal/unix/locks/mod.rs b/library/std/src/sys/pal/unix/locks/mod.rs deleted file mode 100644 index a49247310b54c..0000000000000 --- a/library/std/src/sys/pal/unix/locks/mod.rs +++ /dev/null @@ -1,31 +0,0 @@ -cfg_if::cfg_if! { - if #[cfg(any( - target_os = "linux", - target_os = "android", - all(target_os = "emscripten", target_feature = "atomics"), - target_os = "freebsd", - target_os = "openbsd", - target_os = "dragonfly", - ))] { - mod futex_mutex; - mod futex_rwlock; - mod futex_condvar; - pub(crate) use futex_mutex::Mutex; - pub(crate) use futex_rwlock::RwLock; - pub(crate) use futex_condvar::Condvar; - } else if #[cfg(target_os = "fuchsia")] { - mod fuchsia_mutex; - mod futex_rwlock; - mod futex_condvar; - pub(crate) use fuchsia_mutex::Mutex; - pub(crate) use futex_rwlock::RwLock; - pub(crate) use futex_condvar::Condvar; - } else { - mod pthread_mutex; - mod pthread_condvar; - mod queue_rwlock; - pub(crate) use pthread_mutex::Mutex; - pub(crate) use queue_rwlock::RwLock; - pub(crate) use pthread_condvar::Condvar; - } -} diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 976a437c17ff9..04b8c5ca91604 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -20,7 +20,6 @@ pub mod io; pub mod kernel_copy; #[cfg(target_os = "l4re")] mod l4re; -pub mod locks; pub mod memchr; #[cfg(not(target_os = "l4re"))] pub mod net; diff --git a/library/std/src/sys/pal/unsupported/mod.rs b/library/std/src/sys/pal/unsupported/mod.rs index 88f939cbab924..9ce275ee72d58 100644 --- a/library/std/src/sys/pal/unsupported/mod.rs +++ b/library/std/src/sys/pal/unsupported/mod.rs @@ -5,7 +5,6 @@ pub mod args; pub mod env; pub mod fs; pub mod io; -pub mod locks; pub mod net; pub mod once; pub mod os; diff --git a/library/std/src/sys/pal/wasi/mod.rs b/library/std/src/sys/pal/wasi/mod.rs index 116878ee99681..084b8e0e21639 100644 --- a/library/std/src/sys/pal/wasi/mod.rs +++ b/library/std/src/sys/pal/wasi/mod.rs @@ -43,20 +43,7 @@ pub mod thread_local_key; pub mod time; cfg_if::cfg_if! { - if #[cfg(target_feature = "atomics")] { - #[path = "../unix/locks"] - pub mod locks { - #![allow(unsafe_op_in_unsafe_fn)] - mod futex_condvar; - mod futex_mutex; - mod futex_rwlock; - pub(crate) use futex_condvar::Condvar; - pub(crate) use futex_mutex::Mutex; - pub(crate) use futex_rwlock::RwLock; - } - } else { - #[path = "../unsupported/locks/mod.rs"] - pub mod locks; + if #[cfg(not(target_feature = "atomics"))] { #[path = "../unsupported/once.rs"] pub mod once; #[path = "../unsupported/thread_parking.rs"] diff --git a/library/std/src/sys/pal/wasm/mod.rs b/library/std/src/sys/pal/wasm/mod.rs index 567555118d707..40b15120e6daa 100644 --- a/library/std/src/sys/pal/wasm/mod.rs +++ b/library/std/src/sys/pal/wasm/mod.rs @@ -43,23 +43,11 @@ pub mod time; cfg_if::cfg_if! { if #[cfg(target_feature = "atomics")] { - #[path = "../unix/locks"] - pub mod locks { - #![allow(unsafe_op_in_unsafe_fn)] - mod futex_condvar; - mod futex_mutex; - mod futex_rwlock; - pub(crate) use futex_condvar::Condvar; - pub(crate) use futex_mutex::Mutex; - pub(crate) use futex_rwlock::RwLock; - } #[path = "atomics/futex.rs"] pub mod futex; #[path = "atomics/thread.rs"] pub mod thread; } else { - #[path = "../unsupported/locks/mod.rs"] - pub mod locks; #[path = "../unsupported/once.rs"] pub mod once; #[path = "../unsupported/thread.rs"] diff --git a/library/std/src/sys/pal/windows/locks/mod.rs b/library/std/src/sys/pal/windows/locks/mod.rs deleted file mode 100644 index 0e0f9eccb2137..0000000000000 --- a/library/std/src/sys/pal/windows/locks/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod condvar; -mod mutex; -mod rwlock; -pub use condvar::Condvar; -pub use mutex::Mutex; -pub use rwlock::RwLock; diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs index 726a4509f280f..b47d213df343a 100644 --- a/library/std/src/sys/pal/windows/mod.rs +++ b/library/std/src/sys/pal/windows/mod.rs @@ -19,7 +19,6 @@ pub mod env; pub mod fs; pub mod handle; pub mod io; -pub mod locks; pub mod memchr; pub mod net; pub mod os; diff --git a/library/std/src/sys/pal/xous/locks/mod.rs b/library/std/src/sys/pal/xous/locks/mod.rs deleted file mode 100644 index f3c5c5d9fb0ce..0000000000000 --- a/library/std/src/sys/pal/xous/locks/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod condvar; -mod mutex; -mod rwlock; - -pub use condvar::*; -pub use mutex::*; -pub use rwlock::*; diff --git a/library/std/src/sys/pal/xous/mod.rs b/library/std/src/sys/pal/xous/mod.rs index c9bad4ef019b5..7914a255aeaa1 100644 --- a/library/std/src/sys/pal/xous/mod.rs +++ b/library/std/src/sys/pal/xous/mod.rs @@ -9,7 +9,6 @@ pub mod env; pub mod fs; #[path = "../unsupported/io.rs"] pub mod io; -pub mod locks; pub mod net; pub mod os; #[path = "../unsupported/pipe.rs"] diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs index e859269831aa9..016c977dc33d6 100644 --- a/library/std/src/sys/pal/zkvm/mod.rs +++ b/library/std/src/sys/pal/zkvm/mod.rs @@ -33,8 +33,6 @@ pub mod thread_local_key; #[path = "../unsupported/time.rs"] pub mod time; -#[path = "../unsupported/locks/mod.rs"] -pub mod locks; #[path = "../unsupported/thread.rs"] pub mod thread; diff --git a/tests/debuginfo/mutex.rs b/tests/debuginfo/mutex.rs index 7a58c5c2224be..ab9fb8b7e81d9 100644 --- a/tests/debuginfo/mutex.rs +++ b/tests/debuginfo/mutex.rs @@ -10,7 +10,7 @@ // // cdb-command:dx m,d // cdb-check:m,d [Type: std::sync::mutex::Mutex] -// cdb-check: [...] inner [Type: std::sys::pal::windows::locks::mutex::Mutex] +// cdb-check: [...] inner [Type: std::sys::locks::mutex::windows::Mutex] // cdb-check: [...] poison [Type: std::sync::poison::Flag] // cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell] diff --git a/tests/debuginfo/rwlock-read.rs b/tests/debuginfo/rwlock-read.rs index 4ed1ebd0b37c4..7e9838871ba43 100644 --- a/tests/debuginfo/rwlock-read.rs +++ b/tests/debuginfo/rwlock-read.rs @@ -16,7 +16,7 @@ // cdb-command:dx r // cdb-check:r [Type: std::sync::rwlock::RwLockReadGuard] // cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull] -// cdb-check: [...] inner_lock : [...] [Type: std::sys::pal::windows::locks::rwlock::RwLock *] +// cdb-check: [...] inner_lock : [...] [Type: std::sys::locks::rwlock::windows::RwLock *] #[allow(unused_variables)]