diff options
| author | bors <bors@rust-lang.org> | 2024-02-19 18:04:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-19 18:04:28 +0000 |
| commit | ccb1415eac3289b5ebf64691c0190dc52e0e3d0e (patch) | |
| tree | 5fbc2cd803828a9f583c526b41c6dee011af1788 | |
| parent | 02438348b9c26c0d657cc7b990fd1f45a8c0c736 (diff) | |
| parent | 1b1b6dd95f805daa1503627ad0c7288f7889616a (diff) | |
| download | rust-ccb1415eac3289b5ebf64691c0190dc52e0e3d0e.tar.gz rust-ccb1415eac3289b5ebf64691c0190dc52e0e3d0e.zip | |
Auto merge of #121177 - joboet:move_pal_locks, r=ChrisDenton
Move locks to `sys` Part of #117276. r? `@ChrisDenton`
| -rw-r--r-- | .reuse/dep5 | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/futex.rs (renamed from library/std/src/sys/pal/unix/locks/futex_condvar.rs) | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/itron.rs (renamed from library/std/src/sys/pal/itron/condvar.rs) | 4 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/mod.rs | 36 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/no_threads.rs (renamed from library/std/src/sys/pal/unsupported/locks/condvar.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/pthread.rs (renamed from library/std/src/sys/pal/unix/locks/pthread_condvar.rs) | 8 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/sgx.rs (renamed from library/std/src/sys/pal/sgx/condvar.rs) | 3 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/teeos.rs (renamed from library/std/src/sys/pal/teeos/locks/condvar.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/windows.rs (renamed from library/std/src/sys/pal/windows/locks/condvar.rs) | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/condvar/xous.rs (renamed from library/std/src/sys/pal/xous/locks/condvar.rs) | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mod.rs (renamed from library/std/src/sys/pal/unsupported/locks/mod.rs) | 1 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/fuchsia.rs (renamed from library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/futex.rs (renamed from library/std/src/sys/pal/unix/locks/futex_mutex.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/itron.rs (renamed from library/std/src/sys/pal/itron/mutex.rs) | 19 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/mod.rs | 38 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/no_threads.rs (renamed from library/std/src/sys/pal/unsupported/locks/mutex.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/pthread.rs (renamed from library/std/src/sys/pal/unix/locks/pthread_mutex.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/sgx.rs (renamed from library/std/src/sys/pal/sgx/mutex.rs) | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/windows.rs (renamed from library/std/src/sys/pal/windows/locks/mutex.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/mutex/xous.rs (renamed from library/std/src/sys/pal/xous/locks/mutex.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/futex.rs (renamed from library/std/src/sys/pal/unix/locks/futex_rwlock.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/mod.rs | 36 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/no_threads.rs (renamed from library/std/src/sys/pal/unsupported/locks/rwlock.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/queue.rs (renamed from library/std/src/sys/pal/unix/locks/queue_rwlock.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/sgx.rs (renamed from library/std/src/sys/pal/sgx/rwlock.rs) | 7 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/solid.rs (renamed from library/std/src/sys/pal/solid/rwlock.rs) | 2 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/teeos.rs (renamed from library/std/src/sys/pal/teeos/locks/rwlock.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/windows.rs (renamed from library/std/src/sys/pal/windows/locks/rwlock.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/locks/rwlock/xous.rs (renamed from library/std/src/sys/pal/xous/locks/rwlock.rs) | 0 | ||||
| -rw-r--r-- | library/std/src/sys/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/hermit/mod.rs | 10 | ||||
| -rw-r--r-- | library/std/src/sys/pal/sgx/mod.rs | 13 | ||||
| -rw-r--r-- | library/std/src/sys/pal/solid/abi/fs.rs | 5 | ||||
| -rw-r--r-- | library/std/src/sys/pal/solid/abi/sockets.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/pal/solid/mod.rs | 24 | ||||
| -rw-r--r-- | library/std/src/sys/pal/teeos/locks/mod.rs | 8 | ||||
| -rw-r--r-- | library/std/src/sys/pal/teeos/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/uefi/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/pal/unix/locks/mod.rs | 31 | ||||
| -rw-r--r-- | library/std/src/sys/pal/unix/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/unsupported/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/wasi/mod.rs | 15 | ||||
| -rw-r--r-- | library/std/src/sys/pal/wasm/mod.rs | 12 | ||||
| -rw-r--r-- | library/std/src/sys/pal/windows/locks/mod.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/pal/windows/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/xous/locks/mod.rs | 7 | ||||
| -rw-r--r-- | library/std/src/sys/pal/xous/mod.rs | 1 | ||||
| -rw-r--r-- | library/std/src/sys/pal/zkvm/mod.rs | 2 | ||||
| -rw-r--r-- | tests/debuginfo/mutex.rs | 2 | ||||
| -rw-r--r-- | tests/debuginfo/rwlock-read.rs | 2 |
50 files changed, 144 insertions, 167 deletions
diff --git a/.reuse/dep5 b/.reuse/dep5 index 2c3adf1bfa1..6c39025b5de 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 index 4bd65dd25c2..3ad93ce07f7 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 index 7a47cc6696a..4c6f5e9dad2 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 00000000000..126a42a2a4c --- /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 index 3f0943b50ee..3f0943b50ee 100644 --- a/library/std/src/sys/pal/unsupported/locks/condvar.rs +++ b/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 index 2dc1b0c601e..094738d5a3f 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 index aa1174664ae..cabd3250275 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<WaitVariable<()>>); diff --git a/library/std/src/sys/pal/teeos/locks/condvar.rs b/library/std/src/sys/locks/condvar/teeos.rs index c08e8145b8c..c08e8145b8c 100644 --- a/library/std/src/sys/pal/teeos/locks/condvar.rs +++ b/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 index 953bcc27dee..28a288335d2 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 index 510235046e1..0e51449e0af 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 index 0e0f9eccb21..0bdc4a1e1db 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 index 5d89e5a13fd..5d89e5a13fd 100644 --- a/library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs +++ b/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 index c01229586c3..c01229586c3 100644 --- a/library/std/src/sys/pal/unix/locks/futex_mutex.rs +++ b/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 index 1f6cc419476..a134eb2d1be 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 00000000000..710cb91fb14 --- /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 index 4a13c55fb8b..4a13c55fb8b 100644 --- a/library/std/src/sys/pal/unsupported/locks/mutex.rs +++ b/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 index ee0794334fb..ee0794334fb 100644 --- a/library/std/src/sys/pal/unix/locks/pthread_mutex.rs +++ b/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 index 0dbf020ebe0..d37bd02adf8 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 index ef2f84082cd..ef2f84082cd 100644 --- a/library/std/src/sys/pal/windows/locks/mutex.rs +++ b/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 index a8c9518ff0b..a8c9518ff0b 100644 --- a/library/std/src/sys/pal/xous/locks/mutex.rs +++ b/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 index aa0de900238..aa0de900238 100644 --- a/library/std/src/sys/pal/unix/locks/futex_rwlock.rs +++ b/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 00000000000..0564f1fe6fa --- /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 index 789ef9b29e5..789ef9b29e5 100644 --- a/library/std/src/sys/pal/unsupported/locks/rwlock.rs +++ b/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 index 0f02a98dfdd..0f02a98dfdd 100644 --- a/library/std/src/sys/pal/unix/locks/queue_rwlock.rs +++ b/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 index ebae1cff0ee..136dea597bb 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<WaitVariable<Option<NonZero<usize>>>>, diff --git a/library/std/src/sys/pal/solid/rwlock.rs b/library/std/src/sys/locks/rwlock/solid.rs index ecb4eb83b9b..9bf6f5dbb73 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 index 27cdb88788f..27cdb88788f 100644 --- a/library/std/src/sys/pal/teeos/locks/rwlock.rs +++ b/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 index e69415baac4..e69415baac4 100644 --- a/library/std/src/sys/pal/windows/locks/rwlock.rs +++ b/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 index ab45b33e1f6..ab45b33e1f6 100644 --- a/library/std/src/sys/pal/xous/locks/rwlock.rs +++ b/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 fae21636897..d77ac7eb027 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 57cc656e266..ada408107dc 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 46f3e5b401d..8ef3495884f 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 32800bd9a9d..49526f4c9cd 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 eb06a6dd927..11c430360ce 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 be8e0033902..9ada7d130f0 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 c58e9c7fd45..00000000000 --- 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 7953104486c..51ef96a69a0 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 5a96b8f1c3a..ff8e3bd32ad 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 a49247310b5..00000000000 --- 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 976a437c17f..04b8c5ca916 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 88f939cbab9..9ce275ee72d 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 116878ee996..084b8e0e216 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 567555118d7..40b15120e6d 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 0e0f9eccb21..00000000000 --- 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 726a4509f28..b47d213df34 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 f3c5c5d9fb0..00000000000 --- 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 c9bad4ef019..7914a255aea 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 e859269831a..016c977dc33 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 7a58c5c2224..ab9fb8b7e81 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<i32>] -// 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<i32>] diff --git a/tests/debuginfo/rwlock-read.rs b/tests/debuginfo/rwlock-read.rs index 4ed1ebd0b37..7e9838871ba 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<i32>] // cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull<i32>] -// 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)] |
