Skip to content

Commit ccb1415

Browse files
committed
Auto merge of #121177 - joboet:move_pal_locks, r=ChrisDenton
Move locks to `sys` Part of #117276. r? `@ChrisDenton`
2 parents 0243834 + 1b1b6dd commit ccb1415

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+144
-167
lines changed

.reuse/dep5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Copyright: 2019 The Crossbeam Project Developers
5252
The Rust Project Developers (see https://thanks.rust-lang.org)
5353
License: MIT OR Apache-2.0
5454

55-
Files: library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs
55+
Files: library/std/src/sys/locks/mutex/fuchsia.rs
5656
Copyright: 2016 The Fuchsia Authors
5757
The Rust Project Developers (see https://thanks.rust-lang.org)
5858
License: BSD-2-Clause AND (MIT OR Apache-2.0)

library/std/src/sys/pal/unix/locks/futex_condvar.rs renamed to library/std/src/sys/locks/condvar/futex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use super::Mutex;
21
use crate::sync::atomic::{AtomicU32, Ordering::Relaxed};
32
use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
3+
use crate::sys::locks::Mutex;
44
use crate::time::Duration;
55

66
pub struct Condvar {

library/std/src/sys/pal/itron/condvar.rs renamed to library/std/src/sys/locks/condvar/itron.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! POSIX conditional variable implementation based on user-space wait queues.
2-
use super::{abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong};
2+
use crate::sys::pal::itron::{
3+
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
4+
};
35
use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration};
46

57
// The implementation is inspired by the queue-based implementation shown in
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cfg_if::cfg_if! {
2+
if #[cfg(any(
3+
target_os = "linux",
4+
target_os = "android",
5+
target_os = "freebsd",
6+
target_os = "openbsd",
7+
target_os = "dragonfly",
8+
target_os = "fuchsia",
9+
all(target_family = "wasm", target_feature = "atomics"),
10+
target_os = "hermit",
11+
))] {
12+
mod futex;
13+
pub use futex::Condvar;
14+
} else if #[cfg(target_family = "unix")] {
15+
mod pthread;
16+
pub use pthread::Condvar;
17+
} else if #[cfg(target_os = "windows")] {
18+
mod windows;
19+
pub use windows::Condvar;
20+
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
21+
mod sgx;
22+
pub use sgx::Condvar;
23+
} else if #[cfg(target_os = "solid_asp3")] {
24+
mod itron;
25+
pub use itron::Condvar;
26+
} else if #[cfg(target_os = "teeos")] {
27+
mod teeos;
28+
pub use teeos::Condvar;
29+
} else if #[cfg(target_os = "xous")] {
30+
mod xous;
31+
pub use xous::Condvar;
32+
} else {
33+
mod no_threads;
34+
pub use no_threads::Condvar;
35+
}
36+
}

library/std/src/sys/pal/unix/locks/pthread_condvar.rs renamed to library/std/src/sys/locks/condvar/pthread.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::cell::UnsafeCell;
22
use crate::ptr;
33
use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
4-
use crate::sys::locks::{pthread_mutex, Mutex};
4+
use crate::sys::locks::{mutex, Mutex};
55
#[cfg(not(target_os = "nto"))]
66
use crate::sys::time::TIMESPEC_MAX;
77
#[cfg(target_os = "nto")]
@@ -112,7 +112,7 @@ impl Condvar {
112112

113113
#[inline]
114114
pub unsafe fn wait(&self, mutex: &Mutex) {
115-
let mutex = pthread_mutex::raw(mutex);
115+
let mutex = mutex::raw(mutex);
116116
self.verify(mutex);
117117
let r = libc::pthread_cond_wait(raw(self), mutex);
118118
debug_assert_eq!(r, 0);
@@ -134,7 +134,7 @@ impl Condvar {
134134
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
135135
use crate::sys::time::Timespec;
136136

137-
let mutex = pthread_mutex::raw(mutex);
137+
let mutex = mutex::raw(mutex);
138138
self.verify(mutex);
139139

140140
#[cfg(not(target_os = "nto"))]
@@ -170,7 +170,7 @@ impl Condvar {
170170
use crate::sys::time::SystemTime;
171171
use crate::time::Instant;
172172

173-
let mutex = pthread_mutex::raw(mutex);
173+
let mutex = mutex::raw(mutex);
174174
self.verify(mutex);
175175

176176
// OSX implementation of `pthread_cond_timedwait` is buggy

library/std/src/sys/pal/sgx/condvar.rs renamed to library/std/src/sys/locks/condvar/sgx.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use crate::sys::locks::Mutex;
2+
use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
23
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
34
use crate::time::Duration;
45

5-
use super::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
6-
76
/// FIXME: `UnsafeList` is not movable.
87
struct AllocatedCondvar(SpinMutex<WaitVariable<()>>);
98

library/std/src/sys/pal/windows/locks/condvar.rs renamed to library/std/src/sys/locks/condvar/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Condvar {
2727
let r = c::SleepConditionVariableSRW(
2828
self.inner.get(),
2929
mutex::raw(mutex),
30-
crate::sys::pal::windows::dur2timeout(dur),
30+
crate::sys::pal::dur2timeout(dur),
3131
0,
3232
);
3333
if r == 0 {

library/std/src/sys/pal/xous/locks/condvar.rs renamed to library/std/src/sys/locks/condvar/xous.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use super::mutex::Mutex;
21
use crate::os::xous::ffi::{blocking_scalar, scalar};
32
use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
3+
use crate::sys::locks::Mutex;
44
use crate::time::Duration;
55
use core::sync::atomic::{AtomicUsize, Ordering};
66

0 commit comments

Comments
 (0)