about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/std/src/sys/hermit/condvar.rs2
-rw-r--r--library/std/src/sys/hermit/mod.rs13
-rw-r--r--library/std/src/sys/hermit/rwlock.rs3
-rw-r--r--library/std/src/sys/itron/condvar.rs2
-rw-r--r--library/std/src/sys/sgx/condvar.rs2
-rw-r--r--library/std/src/sys/sgx/mod.rs13
-rw-r--r--library/std/src/sys/solid/mod.rs11
-rw-r--r--library/std/src/sys/unix/locks/mod.rs8
-rw-r--r--library/std/src/sys/unix/locks/pthread_condvar.rs (renamed from library/std/src/sys/unix/condvar.rs)8
-rw-r--r--library/std/src/sys/unix/locks/pthread_mutex.rs (renamed from library/std/src/sys/unix/mutex.rs)44
-rw-r--r--library/std/src/sys/unix/locks/pthread_remutex.rs46
-rw-r--r--library/std/src/sys/unix/locks/pthread_rwlock.rs (renamed from library/std/src/sys/unix/rwlock.rs)0
-rw-r--r--library/std/src/sys/unix/mod.rs4
-rw-r--r--library/std/src/sys/unsupported/locks/condvar.rs (renamed from library/std/src/sys/unsupported/condvar.rs)2
-rw-r--r--library/std/src/sys/unsupported/locks/mod.rs6
-rw-r--r--library/std/src/sys/unsupported/locks/mutex.rs (renamed from library/std/src/sys/unsupported/mutex.rs)0
-rw-r--r--library/std/src/sys/unsupported/locks/rwlock.rs (renamed from library/std/src/sys/unsupported/rwlock.rs)0
-rw-r--r--library/std/src/sys/unsupported/mod.rs4
-rw-r--r--library/std/src/sys/wasi/mod.rs8
-rw-r--r--library/std/src/sys/wasm/atomics/condvar.rs2
-rw-r--r--library/std/src/sys/wasm/atomics/rwlock.rs3
-rw-r--r--library/std/src/sys/wasm/mod.rs19
-rw-r--r--library/std/src/sys/windows/locks/condvar.rs (renamed from library/std/src/sys/windows/condvar.rs)4
-rw-r--r--library/std/src/sys/windows/locks/mod.rs6
-rw-r--r--library/std/src/sys/windows/locks/mutex.rs (renamed from library/std/src/sys/windows/mutex.rs)0
-rw-r--r--library/std/src/sys/windows/locks/rwlock.rs (renamed from library/std/src/sys/windows/rwlock.rs)0
-rw-r--r--library/std/src/sys/windows/mod.rs4
-rw-r--r--library/std/src/sys_common/condvar.rs5
-rw-r--r--library/std/src/sys_common/condvar/check.rs8
-rw-r--r--library/std/src/sys_common/mutex.rs2
-rw-r--r--library/std/src/sys_common/remutex.rs2
-rw-r--r--library/std/src/sys_common/rwlock.rs2
32 files changed, 133 insertions, 100 deletions
diff --git a/library/std/src/sys/hermit/condvar.rs b/library/std/src/sys/hermit/condvar.rs
index b62f21a9dac..f6083530005 100644
--- a/library/std/src/sys/hermit/condvar.rs
+++ b/library/std/src/sys/hermit/condvar.rs
@@ -2,7 +2,7 @@ use crate::ffi::c_void;
 use crate::ptr;
 use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
 use crate::sys::hermit::abi;
-use crate::sys::mutex::Mutex;
+use crate::sys::locks::Mutex;
 use crate::time::Duration;
 
 // The implementation is inspired by Andrew D. Birrell's paper
diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs
index b798c97448b..08eca423802 100644
--- a/library/std/src/sys/hermit/mod.rs
+++ b/library/std/src/sys/hermit/mod.rs
@@ -22,14 +22,12 @@ pub mod alloc;
 pub mod args;
 #[path = "../unix/cmath.rs"]
 pub mod cmath;
-pub mod condvar;
 pub mod env;
 pub mod fd;
 pub mod fs;
 #[path = "../unsupported/io.rs"]
 pub mod io;
 pub mod memchr;
-pub mod mutex;
 pub mod net;
 pub mod os;
 #[path = "../unix/os_str.rs"]
@@ -40,7 +38,6 @@ pub mod path;
 pub mod pipe;
 #[path = "../unsupported/process.rs"]
 pub mod process;
-pub mod rwlock;
 pub mod stdio;
 pub mod thread;
 pub mod thread_local_dtor;
@@ -48,6 +45,16 @@ pub mod thread_local_dtor;
 pub mod thread_local_key;
 pub mod time;
 
+mod condvar;
+mod mutex;
+mod rwlock;
+
+pub mod locks {
+    pub use super::condvar::*;
+    pub use super::mutex::*;
+    pub use super::rwlock::*;
+}
+
 use crate::io::ErrorKind;
 
 #[allow(unused_extern_crates)]
diff --git a/library/std/src/sys/hermit/rwlock.rs b/library/std/src/sys/hermit/rwlock.rs
index 64eaa2fc482..1cca809764c 100644
--- a/library/std/src/sys/hermit/rwlock.rs
+++ b/library/std/src/sys/hermit/rwlock.rs
@@ -1,6 +1,5 @@
 use crate::cell::UnsafeCell;
-use crate::sys::condvar::Condvar;
-use crate::sys::mutex::Mutex;
+use crate::sys::locks::{Condvar, Mutex};
 
 pub struct RWLock {
     lock: Mutex,
diff --git a/library/std/src/sys/itron/condvar.rs b/library/std/src/sys/itron/condvar.rs
index 2992a6a5429..ed26c528027 100644
--- a/library/std/src/sys/itron/condvar.rs
+++ b/library/std/src/sys/itron/condvar.rs
@@ -1,6 +1,6 @@
 //! 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::{mem::replace, ptr::NonNull, sys::mutex::Mutex, time::Duration};
+use crate::{mem::replace, ptr::NonNull, sys::locks::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/sgx/condvar.rs b/library/std/src/sys/sgx/condvar.rs
index 55ac052d975..c9736880b08 100644
--- a/library/std/src/sys/sgx/condvar.rs
+++ b/library/std/src/sys/sgx/condvar.rs
@@ -1,4 +1,4 @@
-use crate::sys::mutex::Mutex;
+use crate::sys::locks::Mutex;
 use crate::time::Duration;
 
 use super::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
diff --git a/library/std/src/sys/sgx/mod.rs b/library/std/src/sys/sgx/mod.rs
index 158c92e7a77..1333edb9881 100644
--- a/library/std/src/sys/sgx/mod.rs
+++ b/library/std/src/sys/sgx/mod.rs
@@ -15,7 +15,6 @@ pub mod alloc;
 pub mod args;
 #[path = "../unix/cmath.rs"]
 pub mod cmath;
-pub mod condvar;
 pub mod env;
 pub mod fd;
 #[path = "../unsupported/fs.rs"]
@@ -23,7 +22,6 @@ pub mod fs;
 #[path = "../unsupported/io.rs"]
 pub mod io;
 pub mod memchr;
-pub mod mutex;
 pub mod net;
 pub mod os;
 #[path = "../unix/os_str.rs"]
@@ -33,12 +31,21 @@ pub mod path;
 pub mod pipe;
 #[path = "../unsupported/process.rs"]
 pub mod process;
-pub mod rwlock;
 pub mod stdio;
 pub mod thread;
 pub mod thread_local_key;
 pub mod time;
 
+mod condvar;
+mod mutex;
+mod rwlock;
+
+pub mod locks {
+    pub use super::condvar::*;
+    pub use super::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) {
diff --git a/library/std/src/sys/solid/mod.rs b/library/std/src/sys/solid/mod.rs
index 049460755d6..492b1a55475 100644
--- a/library/std/src/sys/solid/mod.rs
+++ b/library/std/src/sys/solid/mod.rs
@@ -37,14 +37,21 @@ pub mod path;
 pub mod pipe;
 #[path = "../unsupported/process.rs"]
 pub mod process;
-pub mod rwlock;
 pub mod stdio;
-pub use self::itron::{condvar, mutex, thread};
+pub use self::itron::thread;
 pub mod memchr;
 pub mod thread_local_dtor;
 pub mod thread_local_key;
 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) {}
diff --git a/library/std/src/sys/unix/locks/mod.rs b/library/std/src/sys/unix/locks/mod.rs
new file mode 100644
index 00000000000..f07a9f93b79
--- /dev/null
+++ b/library/std/src/sys/unix/locks/mod.rs
@@ -0,0 +1,8 @@
+mod pthread_condvar;
+mod pthread_mutex;
+mod pthread_remutex;
+mod pthread_rwlock;
+pub use pthread_condvar::{Condvar, MovableCondvar};
+pub use pthread_mutex::{MovableMutex, Mutex};
+pub use pthread_remutex::ReentrantMutex;
+pub use pthread_rwlock::{MovableRWLock, RWLock};
diff --git a/library/std/src/sys/unix/condvar.rs b/library/std/src/sys/unix/locks/pthread_condvar.rs
index 61261c0aa84..099aa68706f 100644
--- a/library/std/src/sys/unix/condvar.rs
+++ b/library/std/src/sys/unix/locks/pthread_condvar.rs
@@ -1,5 +1,5 @@
 use crate::cell::UnsafeCell;
-use crate::sys::mutex::{self, Mutex};
+use crate::sys::locks::{pthread_mutex, Mutex};
 use crate::time::Duration;
 
 pub struct Condvar {
@@ -79,7 +79,7 @@ impl Condvar {
 
     #[inline]
     pub unsafe fn wait(&self, mutex: &Mutex) {
-        let r = libc::pthread_cond_wait(self.inner.get(), mutex::raw(mutex));
+        let r = libc::pthread_cond_wait(self.inner.get(), pthread_mutex::raw(mutex));
         debug_assert_eq!(r, 0);
     }
 
@@ -111,7 +111,7 @@ impl Condvar {
         let timeout =
             sec.map(|s| libc::timespec { tv_sec: s, tv_nsec: nsec as _ }).unwrap_or(TIMESPEC_MAX);
 
-        let r = libc::pthread_cond_timedwait(self.inner.get(), mutex::raw(mutex), &timeout);
+        let r = libc::pthread_cond_timedwait(self.inner.get(), pthread_mutex::raw(mutex), &timeout);
         assert!(r == libc::ETIMEDOUT || r == 0);
         r == 0
     }
@@ -169,7 +169,7 @@ impl Condvar {
             .unwrap_or(TIMESPEC_MAX);
 
         // And wait!
-        let r = libc::pthread_cond_timedwait(self.inner.get(), mutex::raw(mutex), &timeout);
+        let r = libc::pthread_cond_timedwait(self.inner.get(), pthread_mutex::raw(mutex), &timeout);
         debug_assert!(r == libc::ETIMEDOUT || r == 0);
 
         // ETIMEDOUT is not a totally reliable method of determining timeout due
diff --git a/library/std/src/sys/unix/mutex.rs b/library/std/src/sys/unix/locks/pthread_mutex.rs
index 89c55eb859d..09cfa2f50ec 100644
--- a/library/std/src/sys/unix/mutex.rs
+++ b/library/std/src/sys/unix/locks/pthread_mutex.rs
@@ -90,49 +90,7 @@ impl Mutex {
     }
 }
 
-pub struct ReentrantMutex {
-    inner: UnsafeCell<libc::pthread_mutex_t>,
-}
-
-unsafe impl Send for ReentrantMutex {}
-unsafe impl Sync for ReentrantMutex {}
-
-impl ReentrantMutex {
-    pub const unsafe fn uninitialized() -> ReentrantMutex {
-        ReentrantMutex { inner: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER) }
-    }
-
-    pub unsafe fn init(&self) {
-        let mut attr = MaybeUninit::<libc::pthread_mutexattr_t>::uninit();
-        cvt_nz(libc::pthread_mutexattr_init(attr.as_mut_ptr())).unwrap();
-        let attr = PthreadMutexAttr(&mut attr);
-        cvt_nz(libc::pthread_mutexattr_settype(attr.0.as_mut_ptr(), libc::PTHREAD_MUTEX_RECURSIVE))
-            .unwrap();
-        cvt_nz(libc::pthread_mutex_init(self.inner.get(), attr.0.as_ptr())).unwrap();
-    }
-
-    pub unsafe fn lock(&self) {
-        let result = libc::pthread_mutex_lock(self.inner.get());
-        debug_assert_eq!(result, 0);
-    }
-
-    #[inline]
-    pub unsafe fn try_lock(&self) -> bool {
-        libc::pthread_mutex_trylock(self.inner.get()) == 0
-    }
-
-    pub unsafe fn unlock(&self) {
-        let result = libc::pthread_mutex_unlock(self.inner.get());
-        debug_assert_eq!(result, 0);
-    }
-
-    pub unsafe fn destroy(&self) {
-        let result = libc::pthread_mutex_destroy(self.inner.get());
-        debug_assert_eq!(result, 0);
-    }
-}
-
-struct PthreadMutexAttr<'a>(&'a mut MaybeUninit<libc::pthread_mutexattr_t>);
+pub(super) struct PthreadMutexAttr<'a>(pub &'a mut MaybeUninit<libc::pthread_mutexattr_t>);
 
 impl Drop for PthreadMutexAttr<'_> {
     fn drop(&mut self) {
diff --git a/library/std/src/sys/unix/locks/pthread_remutex.rs b/library/std/src/sys/unix/locks/pthread_remutex.rs
new file mode 100644
index 00000000000..b006181ee3a
--- /dev/null
+++ b/library/std/src/sys/unix/locks/pthread_remutex.rs
@@ -0,0 +1,46 @@
+use super::pthread_mutex::PthreadMutexAttr;
+use crate::cell::UnsafeCell;
+use crate::mem::MaybeUninit;
+use crate::sys::cvt_nz;
+
+pub struct ReentrantMutex {
+    inner: UnsafeCell<libc::pthread_mutex_t>,
+}
+
+unsafe impl Send for ReentrantMutex {}
+unsafe impl Sync for ReentrantMutex {}
+
+impl ReentrantMutex {
+    pub const unsafe fn uninitialized() -> ReentrantMutex {
+        ReentrantMutex { inner: UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER) }
+    }
+
+    pub unsafe fn init(&self) {
+        let mut attr = MaybeUninit::<libc::pthread_mutexattr_t>::uninit();
+        cvt_nz(libc::pthread_mutexattr_init(attr.as_mut_ptr())).unwrap();
+        let attr = PthreadMutexAttr(&mut attr);
+        cvt_nz(libc::pthread_mutexattr_settype(attr.0.as_mut_ptr(), libc::PTHREAD_MUTEX_RECURSIVE))
+            .unwrap();
+        cvt_nz(libc::pthread_mutex_init(self.inner.get(), attr.0.as_ptr())).unwrap();
+    }
+
+    pub unsafe fn lock(&self) {
+        let result = libc::pthread_mutex_lock(self.inner.get());
+        debug_assert_eq!(result, 0);
+    }
+
+    #[inline]
+    pub unsafe fn try_lock(&self) -> bool {
+        libc::pthread_mutex_trylock(self.inner.get()) == 0
+    }
+
+    pub unsafe fn unlock(&self) {
+        let result = libc::pthread_mutex_unlock(self.inner.get());
+        debug_assert_eq!(result, 0);
+    }
+
+    pub unsafe fn destroy(&self) {
+        let result = libc::pthread_mutex_destroy(self.inner.get());
+        debug_assert_eq!(result, 0);
+    }
+}
diff --git a/library/std/src/sys/unix/rwlock.rs b/library/std/src/sys/unix/locks/pthread_rwlock.rs
index 1318c5b8e3a..1318c5b8e3a 100644
--- a/library/std/src/sys/unix/rwlock.rs
+++ b/library/std/src/sys/unix/locks/pthread_rwlock.rs
diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs
index 7423d90263d..e65c11b6d09 100644
--- a/library/std/src/sys/unix/mod.rs
+++ b/library/std/src/sys/unix/mod.rs
@@ -14,7 +14,6 @@ pub mod android;
 pub mod args;
 #[path = "../unix/cmath.rs"]
 pub mod cmath;
-pub mod condvar;
 pub mod env;
 pub mod fd;
 pub mod fs;
@@ -24,8 +23,8 @@ pub mod io;
 pub mod kernel_copy;
 #[cfg(target_os = "l4re")]
 mod l4re;
+pub mod locks;
 pub mod memchr;
-pub mod mutex;
 #[cfg(not(target_os = "l4re"))]
 pub mod net;
 #[cfg(target_os = "l4re")]
@@ -36,7 +35,6 @@ pub mod path;
 pub mod pipe;
 pub mod process;
 pub mod rand;
-pub mod rwlock;
 pub mod stack_overflow;
 pub mod stdio;
 pub mod thread;
diff --git a/library/std/src/sys/unsupported/condvar.rs b/library/std/src/sys/unsupported/locks/condvar.rs
index 35d12a69c8a..8dbe03bad9b 100644
--- a/library/std/src/sys/unsupported/condvar.rs
+++ b/library/std/src/sys/unsupported/locks/condvar.rs
@@ -1,4 +1,4 @@
-use crate::sys::mutex::Mutex;
+use crate::sys::locks::Mutex;
 use crate::time::Duration;
 
 pub struct Condvar {}
diff --git a/library/std/src/sys/unsupported/locks/mod.rs b/library/std/src/sys/unsupported/locks/mod.rs
new file mode 100644
index 00000000000..5634f106339
--- /dev/null
+++ b/library/std/src/sys/unsupported/locks/mod.rs
@@ -0,0 +1,6 @@
+mod condvar;
+mod mutex;
+mod rwlock;
+pub use condvar::{Condvar, MovableCondvar};
+pub use mutex::{MovableMutex, Mutex, ReentrantMutex};
+pub use rwlock::{MovableRWLock, RWLock};
diff --git a/library/std/src/sys/unsupported/mutex.rs b/library/std/src/sys/unsupported/locks/mutex.rs
index b3203c16c50..b3203c16c50 100644
--- a/library/std/src/sys/unsupported/mutex.rs
+++ b/library/std/src/sys/unsupported/locks/mutex.rs
diff --git a/library/std/src/sys/unsupported/rwlock.rs b/library/std/src/sys/unsupported/locks/rwlock.rs
index 8438adeb5b5..8438adeb5b5 100644
--- a/library/std/src/sys/unsupported/rwlock.rs
+++ b/library/std/src/sys/unsupported/locks/rwlock.rs
diff --git a/library/std/src/sys/unsupported/mod.rs b/library/std/src/sys/unsupported/mod.rs
index a1276193bda..7bf6d40b76d 100644
--- a/library/std/src/sys/unsupported/mod.rs
+++ b/library/std/src/sys/unsupported/mod.rs
@@ -4,11 +4,10 @@ pub mod alloc;
 pub mod args;
 #[path = "../unix/cmath.rs"]
 pub mod cmath;
-pub mod condvar;
 pub mod env;
 pub mod fs;
 pub mod io;
-pub mod mutex;
+pub mod locks;
 pub mod net;
 pub mod os;
 #[path = "../unix/os_str.rs"]
@@ -17,7 +16,6 @@ pub mod os_str;
 pub mod path;
 pub mod pipe;
 pub mod process;
-pub mod rwlock;
 pub mod stdio;
 pub mod thread;
 #[cfg(target_thread_local)]
diff --git a/library/std/src/sys/wasi/mod.rs b/library/std/src/sys/wasi/mod.rs
index f878941939c..683a07a34dc 100644
--- a/library/std/src/sys/wasi/mod.rs
+++ b/library/std/src/sys/wasi/mod.rs
@@ -22,14 +22,12 @@ pub mod alloc;
 pub mod args;
 #[path = "../unix/cmath.rs"]
 pub mod cmath;
-#[path = "../unsupported/condvar.rs"]
-pub mod condvar;
 pub mod env;
 pub mod fd;
 pub mod fs;
 pub mod io;
-#[path = "../unsupported/mutex.rs"]
-pub mod mutex;
+#[path = "../unsupported/locks/mod.rs"]
+pub mod locks;
 pub mod net;
 pub mod os;
 #[path = "../unix/os_str.rs"]
@@ -40,8 +38,6 @@ pub mod path;
 pub mod pipe;
 #[path = "../unsupported/process.rs"]
 pub mod process;
-#[path = "../unsupported/rwlock.rs"]
-pub mod rwlock;
 pub mod stdio;
 pub mod thread;
 #[path = "../unsupported/thread_local_dtor.rs"]
diff --git a/library/std/src/sys/wasm/atomics/condvar.rs b/library/std/src/sys/wasm/atomics/condvar.rs
index 0c1c076cc91..f06c07c5409 100644
--- a/library/std/src/sys/wasm/atomics/condvar.rs
+++ b/library/std/src/sys/wasm/atomics/condvar.rs
@@ -2,7 +2,7 @@ use crate::arch::wasm32;
 use crate::cmp;
 use crate::mem;
 use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
-use crate::sys::mutex::Mutex;
+use crate::sys::locks::Mutex;
 use crate::time::Duration;
 
 pub struct Condvar {
diff --git a/library/std/src/sys/wasm/atomics/rwlock.rs b/library/std/src/sys/wasm/atomics/rwlock.rs
index 64eaa2fc482..1cca809764c 100644
--- a/library/std/src/sys/wasm/atomics/rwlock.rs
+++ b/library/std/src/sys/wasm/atomics/rwlock.rs
@@ -1,6 +1,5 @@
 use crate::cell::UnsafeCell;
-use crate::sys::condvar::Condvar;
-use crate::sys::mutex::Mutex;
+use crate::sys::locks::{Condvar, Mutex};
 
 pub struct RWLock {
     lock: Mutex,
diff --git a/library/std/src/sys/wasm/mod.rs b/library/std/src/sys/wasm/mod.rs
index c81d653a5e3..9f6700caf14 100644
--- a/library/std/src/sys/wasm/mod.rs
+++ b/library/std/src/sys/wasm/mod.rs
@@ -50,22 +50,23 @@ pub mod time;
 cfg_if::cfg_if! {
     if #[cfg(target_feature = "atomics")] {
         #[path = "atomics/condvar.rs"]
-        pub mod condvar;
+        mod condvar;
         #[path = "atomics/mutex.rs"]
-        pub mod mutex;
+        mod mutex;
         #[path = "atomics/rwlock.rs"]
-        pub mod rwlock;
+        mod rwlock;
+        pub mod locks {
+            pub use super::condvar::*;
+            pub use super::mutex::*;
+            pub use super::rwlock::*;
+        }
         #[path = "atomics/futex.rs"]
         pub mod futex;
         #[path = "atomics/thread.rs"]
         pub mod thread;
     } else {
-        #[path = "../unsupported/condvar.rs"]
-        pub mod condvar;
-        #[path = "../unsupported/mutex.rs"]
-        pub mod mutex;
-        #[path = "../unsupported/rwlock.rs"]
-        pub mod rwlock;
+        #[path = "../unsupported/locks/mod.rs"]
+        pub mod locks;
         #[path = "../unsupported/thread.rs"]
         pub mod thread;
     }
diff --git a/library/std/src/sys/windows/condvar.rs b/library/std/src/sys/windows/locks/condvar.rs
index 44547a5c51a..dfd8cfdceee 100644
--- a/library/std/src/sys/windows/condvar.rs
+++ b/library/std/src/sys/windows/locks/condvar.rs
@@ -1,6 +1,6 @@
 use crate::cell::UnsafeCell;
 use crate::sys::c;
-use crate::sys::mutex::{self, Mutex};
+use crate::sys::locks::{mutex, Mutex};
 use crate::sys::os;
 use crate::time::Duration;
 
@@ -31,7 +31,7 @@ impl Condvar {
         let r = c::SleepConditionVariableSRW(
             self.inner.get(),
             mutex::raw(mutex),
-            super::dur2timeout(dur),
+            crate::sys::windows::dur2timeout(dur),
             0,
         );
         if r == 0 {
diff --git a/library/std/src/sys/windows/locks/mod.rs b/library/std/src/sys/windows/locks/mod.rs
new file mode 100644
index 00000000000..5634f106339
--- /dev/null
+++ b/library/std/src/sys/windows/locks/mod.rs
@@ -0,0 +1,6 @@
+mod condvar;
+mod mutex;
+mod rwlock;
+pub use condvar::{Condvar, MovableCondvar};
+pub use mutex::{MovableMutex, Mutex, ReentrantMutex};
+pub use rwlock::{MovableRWLock, RWLock};
diff --git a/library/std/src/sys/windows/mutex.rs b/library/std/src/sys/windows/locks/mutex.rs
index 56f91ebe582..56f91ebe582 100644
--- a/library/std/src/sys/windows/mutex.rs
+++ b/library/std/src/sys/windows/locks/mutex.rs
diff --git a/library/std/src/sys/windows/rwlock.rs b/library/std/src/sys/windows/locks/rwlock.rs
index b7a5b1e7acc..b7a5b1e7acc 100644
--- a/library/std/src/sys/windows/rwlock.rs
+++ b/library/std/src/sys/windows/locks/rwlock.rs
diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs
index 6097e628768..62814eaaa56 100644
--- a/library/std/src/sys/windows/mod.rs
+++ b/library/std/src/sys/windows/mod.rs
@@ -16,13 +16,12 @@ pub mod alloc;
 pub mod args;
 pub mod c;
 pub mod cmath;
-pub mod condvar;
 pub mod env;
 pub mod fs;
 pub mod handle;
 pub mod io;
+pub mod locks;
 pub mod memchr;
-pub mod mutex;
 pub mod net;
 pub mod os;
 pub mod os_str;
@@ -30,7 +29,6 @@ pub mod path;
 pub mod pipe;
 pub mod process;
 pub mod rand;
-pub mod rwlock;
 pub mod thread;
 pub mod thread_local_dtor;
 pub mod thread_local_key;
diff --git a/library/std/src/sys_common/condvar.rs b/library/std/src/sys_common/condvar.rs
index 2c02e1cd33c..67d4b126209 100644
--- a/library/std/src/sys_common/condvar.rs
+++ b/library/std/src/sys_common/condvar.rs
@@ -1,11 +1,10 @@
-use crate::sys::condvar as imp;
-use crate::sys::mutex as mutex_imp;
+use crate::sys::locks as imp;
 use crate::sys_common::mutex::MovableMutex;
 use crate::time::Duration;
 
 mod check;
 
-type CondvarCheck = <mutex_imp::MovableMutex as check::CondvarCheck>::Check;
+type CondvarCheck = <imp::MovableMutex as check::CondvarCheck>::Check;
 
 /// An OS-based condition variable.
 pub struct Condvar {
diff --git a/library/std/src/sys_common/condvar/check.rs b/library/std/src/sys_common/condvar/check.rs
index 1578a2de60c..47aff060d6f 100644
--- a/library/std/src/sys_common/condvar/check.rs
+++ b/library/std/src/sys_common/condvar/check.rs
@@ -1,5 +1,5 @@
 use crate::sync::atomic::{AtomicUsize, Ordering};
-use crate::sys::mutex as mutex_imp;
+use crate::sys::locks as imp;
 use crate::sys_common::mutex::MovableMutex;
 
 pub trait CondvarCheck {
@@ -8,7 +8,7 @@ pub trait CondvarCheck {
 
 /// For boxed mutexes, a `Condvar` will check it's only ever used with the same
 /// mutex, based on its (stable) address.
-impl CondvarCheck for Box<mutex_imp::Mutex> {
+impl CondvarCheck for Box<imp::Mutex> {
     type Check = SameMutexCheck;
 }
 
@@ -22,7 +22,7 @@ impl SameMutexCheck {
         Self { addr: AtomicUsize::new(0) }
     }
     pub fn verify(&self, mutex: &MovableMutex) {
-        let addr = mutex.raw() as *const mutex_imp::Mutex as usize;
+        let addr = mutex.raw() as *const imp::Mutex as usize;
         match self.addr.compare_exchange(0, addr, Ordering::SeqCst, Ordering::SeqCst) {
             Ok(_) => {}               // Stored the address
             Err(n) if n == addr => {} // Lost a race to store the same address
@@ -33,7 +33,7 @@ impl SameMutexCheck {
 
 /// Unboxed mutexes may move, so `Condvar` can not require its address to stay
 /// constant.
-impl CondvarCheck for mutex_imp::Mutex {
+impl CondvarCheck for imp::Mutex {
     type Check = NoCheck;
 }
 
diff --git a/library/std/src/sys_common/mutex.rs b/library/std/src/sys_common/mutex.rs
index f3e7efb955a..12a09c98605 100644
--- a/library/std/src/sys_common/mutex.rs
+++ b/library/std/src/sys_common/mutex.rs
@@ -1,4 +1,4 @@
-use crate::sys::mutex as imp;
+use crate::sys::locks as imp;
 
 /// An OS-based mutual exclusion lock, meant for use in static variables.
 ///
diff --git a/library/std/src/sys_common/remutex.rs b/library/std/src/sys_common/remutex.rs
index 475bfca9b6d..801c9c28dd3 100644
--- a/library/std/src/sys_common/remutex.rs
+++ b/library/std/src/sys_common/remutex.rs
@@ -5,7 +5,7 @@ use crate::marker::PhantomPinned;
 use crate::ops::Deref;
 use crate::panic::{RefUnwindSafe, UnwindSafe};
 use crate::pin::Pin;
-use crate::sys::mutex as sys;
+use crate::sys::locks as sys;
 
 /// A re-entrant mutual exclusion
 ///
diff --git a/library/std/src/sys_common/rwlock.rs b/library/std/src/sys_common/rwlock.rs
index 07ec20f4dc6..eaee6312701 100644
--- a/library/std/src/sys_common/rwlock.rs
+++ b/library/std/src/sys_common/rwlock.rs
@@ -1,4 +1,4 @@
-use crate::sys::rwlock as imp;
+use crate::sys::locks as imp;
 
 /// An OS-based reader-writer lock, meant for use in static variables.
 ///