diff --git a/.reuse/dep5 b/.reuse/dep5 index 6c39025b5de..06afec2b3fa 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/locks/mutex/fuchsia.rs +Files: library/std/src/sys/sync/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/sync/condvar.rs b/library/std/src/sync/condvar.rs index 9c4b926b7ec..b20574e4f14 100644 --- a/library/std/src/sync/condvar.rs +++ b/library/std/src/sync/condvar.rs @@ -3,7 +3,7 @@ use crate::fmt; use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError}; -use crate::sys::locks as sys; +use crate::sys::sync as sys; use crate::time::{Duration, Instant}; /// A type indicating whether a timed wait on a condition variable returned diff --git a/library/std/src/sync/mutex.rs b/library/std/src/sync/mutex.rs index 65ff10e02d4..895fcbd6b7e 100644 --- a/library/std/src/sync/mutex.rs +++ b/library/std/src/sync/mutex.rs @@ -8,7 +8,7 @@ use crate::ops::{Deref, DerefMut}; use crate::ptr::NonNull; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; -use crate::sys::locks as sys; +use crate::sys::sync as sys; /// A mutual exclusion primitive useful for protecting shared data /// diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index 2bb4f3f9e03..608229fd674 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -8,7 +8,7 @@ use crate::fmt; use crate::panic::{RefUnwindSafe, UnwindSafe}; -use crate::sys_common::once as sys; +use crate::sys::sync as sys; /// A synchronization primitive which can be used to run a one-time global /// initialization. Useful for one-time initialization for FFI or related diff --git a/library/std/src/sync/reentrant_lock.rs b/library/std/src/sync/reentrant_lock.rs index 9a44998ebf6..80b9e0cf152 100644 --- a/library/std/src/sync/reentrant_lock.rs +++ b/library/std/src/sync/reentrant_lock.rs @@ -6,7 +6,7 @@ use crate::ops::Deref; use crate::panic::{RefUnwindSafe, UnwindSafe}; use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed}; -use crate::sys::locks as sys; +use crate::sys::sync as sys; /// A re-entrant mutual exclusion lock /// diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 0b3d25c3298..f7f098c082a 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -8,7 +8,7 @@ use crate::ops::{Deref, DerefMut}; use crate::ptr::NonNull; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; -use crate::sys::locks as sys; +use crate::sys::sync as sys; /// A reader-writer lock /// diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 81200e0061e..bbd1d840e92 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -6,9 +6,9 @@ mod personality; pub mod cmath; -pub mod locks; pub mod os_str; pub mod path; +pub mod sync; #[allow(dead_code)] #[allow(unused_imports)] pub mod thread_local; diff --git a/library/std/src/sys/pal/teeos/mod.rs b/library/std/src/sys/pal/teeos/mod.rs index 1fb9d5438de..c392a0ea264 100644 --- a/library/std/src/sys/pal/teeos/mod.rs +++ b/library/std/src/sys/pal/teeos/mod.rs @@ -19,8 +19,6 @@ #[path = "../unsupported/io.rs"] pub mod io; pub mod net; -#[path = "../unsupported/once.rs"] -pub mod once; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; diff --git a/library/std/src/sys/pal/uefi/mod.rs b/library/std/src/sys/pal/uefi/mod.rs index 7c5b37fb490..562b00c2c01 100644 --- a/library/std/src/sys/pal/uefi/mod.rs +++ b/library/std/src/sys/pal/uefi/mod.rs @@ -21,8 +21,6 @@ pub mod io; #[path = "../unsupported/net.rs"] pub mod net; -#[path = "../unsupported/once.rs"] -pub mod once; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; diff --git a/library/std/src/sys/pal/unsupported/mod.rs b/library/std/src/sys/pal/unsupported/mod.rs index 9ce275ee72d..be344fb7cae 100644 --- a/library/std/src/sys/pal/unsupported/mod.rs +++ b/library/std/src/sys/pal/unsupported/mod.rs @@ -6,7 +6,6 @@ pub mod fs; pub mod io; pub mod net; -pub mod once; pub mod os; pub mod pipe; pub mod process; diff --git a/library/std/src/sys/pal/wasi/mod.rs b/library/std/src/sys/pal/wasi/mod.rs index 308dd296004..a78547261ad 100644 --- a/library/std/src/sys/pal/wasi/mod.rs +++ b/library/std/src/sys/pal/wasi/mod.rs @@ -41,8 +41,6 @@ cfg_if::cfg_if! { if #[cfg(not(target_feature = "atomics"))] { - #[path = "../unsupported/once.rs"] - pub mod once; #[path = "../unsupported/thread_parking.rs"] pub mod thread_parking; } diff --git a/library/std/src/sys/pal/wasip2/mod.rs b/library/std/src/sys/pal/wasip2/mod.rs index b12a8d5ea11..d1d444d7b79 100644 --- a/library/std/src/sys/pal/wasip2/mod.rs +++ b/library/std/src/sys/pal/wasip2/mod.rs @@ -51,10 +51,6 @@ if #[cfg(target_feature = "atomics")] { compile_error!("The wasm32-wasip2 target does not support atomics"); } else { - #[path = "../unsupported/locks/mod.rs"] - pub mod locks; - #[path = "../unsupported/once.rs"] - pub mod once; #[path = "../unsupported/thread_parking.rs"] pub mod thread_parking; } diff --git a/library/std/src/sys/pal/wasm/mod.rs b/library/std/src/sys/pal/wasm/mod.rs index 40b15120e6d..5cbc3e45341 100644 --- a/library/std/src/sys/pal/wasm/mod.rs +++ b/library/std/src/sys/pal/wasm/mod.rs @@ -48,8 +48,6 @@ #[path = "atomics/thread.rs"] pub mod thread; } else { - #[path = "../unsupported/once.rs"] - pub mod once; #[path = "../unsupported/thread.rs"] pub mod thread; #[path = "../unsupported/thread_parking.rs"] diff --git a/library/std/src/sys/pal/zkvm/mod.rs b/library/std/src/sys/pal/zkvm/mod.rs index 6c714f76309..228a976dbab 100644 --- a/library/std/src/sys/pal/zkvm/mod.rs +++ b/library/std/src/sys/pal/zkvm/mod.rs @@ -21,8 +21,6 @@ pub mod io; #[path = "../unsupported/net.rs"] pub mod net; -#[path = "../unsupported/once.rs"] -pub mod once; pub mod os; #[path = "../unsupported/pipe.rs"] pub mod pipe; diff --git a/library/std/src/sys/locks/condvar/futex.rs b/library/std/src/sys/sync/condvar/futex.rs similarity index 98% rename from library/std/src/sys/locks/condvar/futex.rs rename to library/std/src/sys/sync/condvar/futex.rs index 3ad93ce07f7..4586d0fd941 100644 --- a/library/std/src/sys/locks/condvar/futex.rs +++ b/library/std/src/sys/sync/condvar/futex.rs @@ -1,6 +1,6 @@ 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::sys::sync::Mutex; use crate::time::Duration; pub struct Condvar { diff --git a/library/std/src/sys/locks/condvar/itron.rs b/library/std/src/sys/sync/condvar/itron.rs similarity index 99% rename from library/std/src/sys/locks/condvar/itron.rs rename to library/std/src/sys/sync/condvar/itron.rs index 4c6f5e9dad2..9b64d241efd 100644 --- a/library/std/src/sys/locks/condvar/itron.rs +++ b/library/std/src/sys/sync/condvar/itron.rs @@ -2,7 +2,7 @@ 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}; +use crate::{mem::replace, ptr::NonNull, sys::sync::Mutex, time::Duration}; // The implementation is inspired by the queue-based implementation shown in // Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores" diff --git a/library/std/src/sys/locks/condvar/mod.rs b/library/std/src/sys/sync/condvar/mod.rs similarity index 100% rename from library/std/src/sys/locks/condvar/mod.rs rename to library/std/src/sys/sync/condvar/mod.rs diff --git a/library/std/src/sys/locks/condvar/no_threads.rs b/library/std/src/sys/sync/condvar/no_threads.rs similarity index 94% rename from library/std/src/sys/locks/condvar/no_threads.rs rename to library/std/src/sys/sync/condvar/no_threads.rs index 3f0943b50ee..36b89c5f5be 100644 --- a/library/std/src/sys/locks/condvar/no_threads.rs +++ b/library/std/src/sys/sync/condvar/no_threads.rs @@ -1,4 +1,4 @@ -use crate::sys::locks::Mutex; +use crate::sys::sync::Mutex; use crate::time::Duration; pub struct Condvar {} diff --git a/library/std/src/sys/locks/condvar/pthread.rs b/library/std/src/sys/sync/condvar/pthread.rs similarity index 99% rename from library/std/src/sys/locks/condvar/pthread.rs rename to library/std/src/sys/sync/condvar/pthread.rs index 094738d5a3f..728371685ee 100644 --- a/library/std/src/sys/locks/condvar/pthread.rs +++ b/library/std/src/sys/sync/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::{mutex, Mutex}; +use crate::sys::sync::{mutex, Mutex}; #[cfg(not(target_os = "nto"))] use crate::sys::time::TIMESPEC_MAX; #[cfg(target_os = "nto")] diff --git a/library/std/src/sys/locks/condvar/sgx.rs b/library/std/src/sys/sync/condvar/sgx.rs similarity index 97% rename from library/std/src/sys/locks/condvar/sgx.rs rename to library/std/src/sys/sync/condvar/sgx.rs index cabd3250275..ecb5872f60d 100644 --- a/library/std/src/sys/locks/condvar/sgx.rs +++ b/library/std/src/sys/sync/condvar/sgx.rs @@ -1,5 +1,5 @@ -use crate::sys::locks::Mutex; use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable}; +use crate::sys::sync::Mutex; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; use crate::time::Duration; diff --git a/library/std/src/sys/locks/condvar/teeos.rs b/library/std/src/sys/sync/condvar/teeos.rs similarity index 98% rename from library/std/src/sys/locks/condvar/teeos.rs rename to library/std/src/sys/sync/condvar/teeos.rs index c08e8145b8c..0a931f407d2 100644 --- a/library/std/src/sys/locks/condvar/teeos.rs +++ b/library/std/src/sys/sync/condvar/teeos.rs @@ -1,7 +1,7 @@ use crate::cell::UnsafeCell; use crate::ptr; use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed}; -use crate::sys::locks::mutex::{self, Mutex}; +use crate::sys::sync::mutex::{self, Mutex}; use crate::sys::time::TIMESPEC_MAX; use crate::sys_common::lazy_box::{LazyBox, LazyInit}; use crate::time::Duration; diff --git a/library/std/src/sys/locks/condvar/windows7.rs b/library/std/src/sys/sync/condvar/windows7.rs similarity index 96% rename from library/std/src/sys/locks/condvar/windows7.rs rename to library/std/src/sys/sync/condvar/windows7.rs index 28a288335d2..07fa5fdd698 100644 --- a/library/std/src/sys/locks/condvar/windows7.rs +++ b/library/std/src/sys/sync/condvar/windows7.rs @@ -1,7 +1,7 @@ use crate::cell::UnsafeCell; use crate::sys::c; -use crate::sys::locks::{mutex, Mutex}; use crate::sys::os; +use crate::sys::sync::{mutex, Mutex}; use crate::time::Duration; pub struct Condvar { diff --git a/library/std/src/sys/locks/condvar/xous.rs b/library/std/src/sys/sync/condvar/xous.rs similarity index 99% rename from library/std/src/sys/locks/condvar/xous.rs rename to library/std/src/sys/sync/condvar/xous.rs index 0e51449e0af..7b218818ef8 100644 --- a/library/std/src/sys/locks/condvar/xous.rs +++ b/library/std/src/sys/sync/condvar/xous.rs @@ -1,6 +1,6 @@ use crate::os::xous::ffi::{blocking_scalar, scalar}; use crate::os::xous::services::{ticktimer_server, TicktimerScalar}; -use crate::sys::locks::Mutex; +use crate::sys::sync::Mutex; use crate::time::Duration; use core::sync::atomic::{AtomicUsize, Ordering}; diff --git a/library/std/src/sys/locks/mod.rs b/library/std/src/sys/sync/mod.rs similarity index 71% rename from library/std/src/sys/locks/mod.rs rename to library/std/src/sys/sync/mod.rs index 0bdc4a1e1db..623e6bccd51 100644 --- a/library/std/src/sys/locks/mod.rs +++ b/library/std/src/sys/sync/mod.rs @@ -1,7 +1,9 @@ mod condvar; mod mutex; +mod once; mod rwlock; pub use condvar::Condvar; pub use mutex::Mutex; +pub use once::{Once, OnceState}; pub use rwlock::RwLock; diff --git a/library/std/src/sys/locks/mutex/fuchsia.rs b/library/std/src/sys/sync/mutex/fuchsia.rs similarity index 100% rename from library/std/src/sys/locks/mutex/fuchsia.rs rename to library/std/src/sys/sync/mutex/fuchsia.rs diff --git a/library/std/src/sys/locks/mutex/futex.rs b/library/std/src/sys/sync/mutex/futex.rs similarity index 100% rename from library/std/src/sys/locks/mutex/futex.rs rename to library/std/src/sys/sync/mutex/futex.rs diff --git a/library/std/src/sys/locks/mutex/itron.rs b/library/std/src/sys/sync/mutex/itron.rs similarity index 100% rename from library/std/src/sys/locks/mutex/itron.rs rename to library/std/src/sys/sync/mutex/itron.rs diff --git a/library/std/src/sys/locks/mutex/mod.rs b/library/std/src/sys/sync/mutex/mod.rs similarity index 100% rename from library/std/src/sys/locks/mutex/mod.rs rename to library/std/src/sys/sync/mutex/mod.rs diff --git a/library/std/src/sys/locks/mutex/no_threads.rs b/library/std/src/sys/sync/mutex/no_threads.rs similarity index 100% rename from library/std/src/sys/locks/mutex/no_threads.rs rename to library/std/src/sys/sync/mutex/no_threads.rs diff --git a/library/std/src/sys/locks/mutex/pthread.rs b/library/std/src/sys/sync/mutex/pthread.rs similarity index 100% rename from library/std/src/sys/locks/mutex/pthread.rs rename to library/std/src/sys/sync/mutex/pthread.rs diff --git a/library/std/src/sys/locks/mutex/sgx.rs b/library/std/src/sys/sync/mutex/sgx.rs similarity index 100% rename from library/std/src/sys/locks/mutex/sgx.rs rename to library/std/src/sys/sync/mutex/sgx.rs diff --git a/library/std/src/sys/locks/mutex/windows7.rs b/library/std/src/sys/sync/mutex/windows7.rs similarity index 100% rename from library/std/src/sys/locks/mutex/windows7.rs rename to library/std/src/sys/sync/mutex/windows7.rs diff --git a/library/std/src/sys/locks/mutex/xous.rs b/library/std/src/sys/sync/mutex/xous.rs similarity index 100% rename from library/std/src/sys/locks/mutex/xous.rs rename to library/std/src/sys/sync/mutex/xous.rs diff --git a/library/std/src/sys_common/once/futex.rs b/library/std/src/sys/sync/once/futex.rs similarity index 100% rename from library/std/src/sys_common/once/futex.rs rename to library/std/src/sys/sync/once/futex.rs diff --git a/library/std/src/sys_common/once/mod.rs b/library/std/src/sys/sync/once/mod.rs similarity index 94% rename from library/std/src/sys_common/once/mod.rs rename to library/std/src/sys/sync/once/mod.rs index ec57568c54c..61b29713fa1 100644 --- a/library/std/src/sys_common/once/mod.rs +++ b/library/std/src/sys/sync/once/mod.rs @@ -30,6 +30,7 @@ mod queue; pub use queue::{Once, OnceState}; } else { - pub use crate::sys::once::{Once, OnceState}; + mod no_threads; + pub use no_threads::{Once, OnceState}; } } diff --git a/library/std/src/sys/pal/unsupported/once.rs b/library/std/src/sys/sync/once/no_threads.rs similarity index 100% rename from library/std/src/sys/pal/unsupported/once.rs rename to library/std/src/sys/sync/once/no_threads.rs diff --git a/library/std/src/sys_common/once/queue.rs b/library/std/src/sys/sync/once/queue.rs similarity index 100% rename from library/std/src/sys_common/once/queue.rs rename to library/std/src/sys/sync/once/queue.rs diff --git a/library/std/src/sys/locks/rwlock/futex.rs b/library/std/src/sys/sync/rwlock/futex.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/futex.rs rename to library/std/src/sys/sync/rwlock/futex.rs diff --git a/library/std/src/sys/locks/rwlock/mod.rs b/library/std/src/sys/sync/rwlock/mod.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/mod.rs rename to library/std/src/sys/sync/rwlock/mod.rs diff --git a/library/std/src/sys/locks/rwlock/no_threads.rs b/library/std/src/sys/sync/rwlock/no_threads.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/no_threads.rs rename to library/std/src/sys/sync/rwlock/no_threads.rs diff --git a/library/std/src/sys/locks/rwlock/queue.rs b/library/std/src/sys/sync/rwlock/queue.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/queue.rs rename to library/std/src/sys/sync/rwlock/queue.rs diff --git a/library/std/src/sys/locks/rwlock/sgx.rs b/library/std/src/sys/sync/rwlock/sgx.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/sgx.rs rename to library/std/src/sys/sync/rwlock/sgx.rs diff --git a/library/std/src/sys/locks/rwlock/sgx/tests.rs b/library/std/src/sys/sync/rwlock/sgx/tests.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/sgx/tests.rs rename to library/std/src/sys/sync/rwlock/sgx/tests.rs diff --git a/library/std/src/sys/locks/rwlock/solid.rs b/library/std/src/sys/sync/rwlock/solid.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/solid.rs rename to library/std/src/sys/sync/rwlock/solid.rs diff --git a/library/std/src/sys/locks/rwlock/teeos.rs b/library/std/src/sys/sync/rwlock/teeos.rs similarity index 95% rename from library/std/src/sys/locks/rwlock/teeos.rs rename to library/std/src/sys/sync/rwlock/teeos.rs index 27cdb88788f..ef9b1ab5154 100644 --- a/library/std/src/sys/locks/rwlock/teeos.rs +++ b/library/std/src/sys/sync/rwlock/teeos.rs @@ -1,4 +1,4 @@ -use crate::sys::locks::mutex::Mutex; +use crate::sys::sync::mutex::Mutex; /// we do not supported rwlock, so use mutex to simulate rwlock. /// it's useful because so many code in std will use rwlock. diff --git a/library/std/src/sys/locks/rwlock/windows7.rs b/library/std/src/sys/sync/rwlock/windows7.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/windows7.rs rename to library/std/src/sys/sync/rwlock/windows7.rs diff --git a/library/std/src/sys/locks/rwlock/xous.rs b/library/std/src/sys/sync/rwlock/xous.rs similarity index 100% rename from library/std/src/sys/locks/rwlock/xous.rs rename to library/std/src/sys/sync/rwlock/xous.rs diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index c9025a81bf3..5410f135a73 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -24,7 +24,6 @@ pub mod fs; pub mod io; pub mod lazy_box; -pub mod once; pub mod process; pub mod thread; pub mod thread_info; diff --git a/tests/debuginfo/mutex.rs b/tests/debuginfo/mutex.rs index affc1558ffa..4f458c0d7e0 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::locks::mutex::futex::Mutex] +// cdb-check: [...] inner [Type: std::sys::sync::mutex::futex::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 76dbc73a1e9..3fd6ac33726 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::locks::rwlock::futex::RwLock *] +// cdb-check: [...] inner_lock : [...] [Type: std::sys::sync::rwlock::futex::RwLock *] #[allow(unused_variables)]