Skip to content

Commit

Permalink
Move std::sys::{mutex, condvar, rwlock} to std::sys::locks.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Mar 22, 2022
1 parent ac69963 commit 8ddb34d
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 32 deletions.
13 changes: 10 additions & 3 deletions library/std/src/sys/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -40,14 +38,23 @@ 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;
#[path = "../unsupported/thread_local_key.rs"]
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)]
Expand Down
13 changes: 10 additions & 3 deletions library/std/src/sys/sgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ 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"]
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"]
Expand All @@ -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) {
Expand Down
11 changes: 9 additions & 2 deletions library/std/src/sys/solid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::sys::mutex::Mutex;
use crate::sys::locks::Mutex;
use crate::time::Duration;

pub struct Condvar {}
Expand Down
6 changes: 6 additions & 0 deletions library/std/src/sys/unsupported/locks/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions library/std/src/sys/unsupported/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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)]
Expand Down
8 changes: 2 additions & 6 deletions library/std/src/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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"]
Expand Down
19 changes: 10 additions & 9 deletions library/std/src/sys/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions library/std/src/sys/windows/locks/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions library/std/src/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ 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;
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;
Expand Down

0 comments on commit 8ddb34d

Please sign in to comment.