Skip to content

Commit 733153f

Browse files
committed
Move std::sys::{mutex, condvar, rwlock} to std::sys::locks.
1 parent ac69963 commit 733153f

File tree

21 files changed

+64
-40
lines changed

21 files changed

+64
-40
lines changed

library/std/src/sys/hermit/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::ffi::c_void;
22
use crate::ptr;
33
use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
44
use crate::sys::hermit::abi;
5-
use crate::sys::mutex::Mutex;
5+
use crate::sys::locks::Mutex;
66
use crate::time::Duration;
77

88
// The implementation is inspired by Andrew D. Birrell's paper

library/std/src/sys/hermit/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ pub mod alloc;
2222
pub mod args;
2323
#[path = "../unix/cmath.rs"]
2424
pub mod cmath;
25-
pub mod condvar;
2625
pub mod env;
2726
pub mod fd;
2827
pub mod fs;
2928
#[path = "../unsupported/io.rs"]
3029
pub mod io;
3130
pub mod memchr;
32-
pub mod mutex;
3331
pub mod net;
3432
pub mod os;
3533
#[path = "../unix/os_str.rs"]
@@ -40,14 +38,23 @@ pub mod path;
4038
pub mod pipe;
4139
#[path = "../unsupported/process.rs"]
4240
pub mod process;
43-
pub mod rwlock;
4441
pub mod stdio;
4542
pub mod thread;
4643
pub mod thread_local_dtor;
4744
#[path = "../unsupported/thread_local_key.rs"]
4845
pub mod thread_local_key;
4946
pub mod time;
5047

48+
mod condvar;
49+
mod mutex;
50+
mod rwlock;
51+
52+
pub mod locks {
53+
pub use super::condvar::*;
54+
pub use super::mutex::*;
55+
pub use super::rwlock::*;
56+
}
57+
5158
use crate::io::ErrorKind;
5259

5360
#[allow(unused_extern_crates)]

library/std/src/sys/hermit/rwlock.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::cell::UnsafeCell;
2-
use crate::sys::condvar::Condvar;
3-
use crate::sys::mutex::Mutex;
2+
use crate::sys::locks::{Condvar, Mutex};
43

54
pub struct RWLock {
65
lock: Mutex,

library/std/src/sys/itron/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! POSIX conditional variable implementation based on user-space wait queues.
22
use super::{abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong};
3-
use crate::{mem::replace, ptr::NonNull, sys::mutex::Mutex, time::Duration};
3+
use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration};
44

55
// The implementation is inspired by the queue-based implementation shown in
66
// Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores"

library/std/src/sys/sgx/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::sys::mutex::Mutex;
1+
use crate::sys::locks::Mutex;
22
use crate::time::Duration;
33

44
use super::waitqueue::{SpinMutex, WaitQueue, WaitVariable};

library/std/src/sys/sgx/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ pub mod alloc;
1515
pub mod args;
1616
#[path = "../unix/cmath.rs"]
1717
pub mod cmath;
18-
pub mod condvar;
1918
pub mod env;
2019
pub mod fd;
2120
#[path = "../unsupported/fs.rs"]
2221
pub mod fs;
2322
#[path = "../unsupported/io.rs"]
2423
pub mod io;
2524
pub mod memchr;
26-
pub mod mutex;
2725
pub mod net;
2826
pub mod os;
2927
#[path = "../unix/os_str.rs"]
@@ -33,12 +31,21 @@ pub mod path;
3331
pub mod pipe;
3432
#[path = "../unsupported/process.rs"]
3533
pub mod process;
36-
pub mod rwlock;
3734
pub mod stdio;
3835
pub mod thread;
3936
pub mod thread_local_key;
4037
pub mod time;
4138

39+
mod condvar;
40+
mod mutex;
41+
mod rwlock;
42+
43+
pub mod locks {
44+
pub use super::condvar::*;
45+
pub use super::mutex::*;
46+
pub use super::rwlock::*;
47+
}
48+
4249
// SAFETY: must be called only once during runtime initialization.
4350
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
4451
pub unsafe fn init(argc: isize, argv: *const *const u8) {

library/std/src/sys/solid/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ pub mod path;
3737
pub mod pipe;
3838
#[path = "../unsupported/process.rs"]
3939
pub mod process;
40-
pub mod rwlock;
4140
pub mod stdio;
42-
pub use self::itron::{condvar, mutex, thread};
41+
pub use self::itron::thread;
4342
pub mod memchr;
4443
pub mod thread_local_dtor;
4544
pub mod thread_local_key;
4645
pub mod time;
4746

47+
mod rwlock;
48+
49+
pub mod locks {
50+
pub use super::itron::condvar::*;
51+
pub use super::itron::mutex::*;
52+
pub use super::rwlock::*;
53+
}
54+
4855
// SAFETY: must be called only once during runtime initialization.
4956
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
5057
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}

library/std/src/sys/unsupported/condvar.rs renamed to library/std/src/sys/unsupported/locks/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::sys::mutex::Mutex;
1+
use crate::sys::locks::Mutex;
22
use crate::time::Duration;
33

44
pub struct Condvar {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
mod condvar;
2+
mod mutex;
3+
mod rwlock;
4+
pub use condvar::{Condvar, MovableCondvar};
5+
pub use mutex::{MovableMutex, Mutex, ReentrantMutex};
6+
pub use rwlock::{MovableRWLock, RWLock};

0 commit comments

Comments
 (0)