Skip to content

Commit 22a5267

Browse files
committed
std: move Once implementations to sys
1 parent 3b85d2c commit 22a5267

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

+22
-35
lines changed

.reuse/dep5

+1-1
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/locks/mutex/fuchsia.rs
55+
Files: library/std/src/sys/sync/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/sync/condvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod tests;
33

44
use crate::fmt;
55
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
6-
use crate::sys::locks as sys;
6+
use crate::sys::sync as sys;
77
use crate::time::{Duration, Instant};
88

99
/// A type indicating whether a timed wait on a condition variable returned

library/std/src/sync/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::mem::ManuallyDrop;
88
use crate::ops::{Deref, DerefMut};
99
use crate::ptr::NonNull;
1010
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
11-
use crate::sys::locks as sys;
11+
use crate::sys::sync as sys;
1212

1313
/// A mutual exclusion primitive useful for protecting shared data
1414
///

library/std/src/sync/once.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod tests;
88

99
use crate::fmt;
1010
use crate::panic::{RefUnwindSafe, UnwindSafe};
11-
use crate::sys_common::once as sys;
11+
use crate::sys::sync as sys;
1212

1313
/// A synchronization primitive which can be used to run a one-time global
1414
/// initialization. Useful for one-time initialization for FFI or related

library/std/src/sync/reentrant_lock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::fmt;
66
use crate::ops::Deref;
77
use crate::panic::{RefUnwindSafe, UnwindSafe};
88
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
9-
use crate::sys::locks as sys;
9+
use crate::sys::sync as sys;
1010

1111
/// A re-entrant mutual exclusion lock
1212
///

library/std/src/sync/rwlock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::mem::ManuallyDrop;
88
use crate::ops::{Deref, DerefMut};
99
use crate::ptr::NonNull;
1010
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
11-
use crate::sys::locks as sys;
11+
use crate::sys::sync as sys;
1212

1313
/// A reader-writer lock
1414
///

library/std/src/sys/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ mod pal;
66
mod personality;
77

88
pub mod cmath;
9-
pub mod locks;
109
pub mod os_str;
1110
pub mod path;
11+
pub mod sync;
1212
#[allow(dead_code)]
1313
#[allow(unused_imports)]
1414
pub mod thread_local;

library/std/src/sys/pal/teeos/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ pub mod fs;
1919
#[path = "../unsupported/io.rs"]
2020
pub mod io;
2121
pub mod net;
22-
#[path = "../unsupported/once.rs"]
23-
pub mod once;
2422
pub mod os;
2523
#[path = "../unsupported/pipe.rs"]
2624
pub mod pipe;

library/std/src/sys/pal/uefi/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ pub mod fs;
2121
pub mod io;
2222
#[path = "../unsupported/net.rs"]
2323
pub mod net;
24-
#[path = "../unsupported/once.rs"]
25-
pub mod once;
2624
pub mod os;
2725
#[path = "../unsupported/pipe.rs"]
2826
pub mod pipe;

library/std/src/sys/pal/unsupported/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub mod env;
66
pub mod fs;
77
pub mod io;
88
pub mod net;
9-
pub mod once;
109
pub mod os;
1110
pub mod pipe;
1211
pub mod process;

library/std/src/sys/pal/wasi/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ pub mod time;
4141

4242
cfg_if::cfg_if! {
4343
if #[cfg(not(target_feature = "atomics"))] {
44-
#[path = "../unsupported/once.rs"]
45-
pub mod once;
4644
#[path = "../unsupported/thread_parking.rs"]
4745
pub mod thread_parking;
4846
}

library/std/src/sys/pal/wasip2/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ cfg_if::cfg_if! {
5151
if #[cfg(target_feature = "atomics")] {
5252
compile_error!("The wasm32-wasip2 target does not support atomics");
5353
} else {
54-
#[path = "../unsupported/locks/mod.rs"]
55-
pub mod locks;
56-
#[path = "../unsupported/once.rs"]
57-
pub mod once;
5854
#[path = "../unsupported/thread_parking.rs"]
5955
pub mod thread_parking;
6056
}

library/std/src/sys/pal/wasm/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ cfg_if::cfg_if! {
4848
#[path = "atomics/thread.rs"]
4949
pub mod thread;
5050
} else {
51-
#[path = "../unsupported/once.rs"]
52-
pub mod once;
5351
#[path = "../unsupported/thread.rs"]
5452
pub mod thread;
5553
#[path = "../unsupported/thread_parking.rs"]

library/std/src/sys/pal/zkvm/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ pub mod fs;
2121
pub mod io;
2222
#[path = "../unsupported/net.rs"]
2323
pub mod net;
24-
#[path = "../unsupported/once.rs"]
25-
pub mod once;
2624
pub mod os;
2725
#[path = "../unsupported/pipe.rs"]
2826
pub mod pipe;

library/std/src/sys/locks/condvar/futex.rs library/std/src/sys/sync/condvar/futex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::sync::atomic::{AtomicU32, Ordering::Relaxed};
22
use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
3-
use crate::sys::locks::Mutex;
3+
use crate::sys::sync::Mutex;
44
use crate::time::Duration;
55

66
pub struct Condvar {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::sys::pal::itron::{
33
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
44
};
5-
use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration};
5+
use crate::{mem::replace, ptr::NonNull, sys::sync::Mutex, time::Duration};
66

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

library/std/src/sys/locks/condvar/no_threads.rs library/std/src/sys/sync/condvar/no_threads.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::sys::locks::Mutex;
1+
use crate::sys::sync::Mutex;
22
use crate::time::Duration;
33

44
pub struct Condvar {}

library/std/src/sys/locks/condvar/pthread.rs library/std/src/sys/sync/condvar/pthread.rs

+1-1
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::{mutex, Mutex};
4+
use crate::sys::sync::{mutex, Mutex};
55
#[cfg(not(target_os = "nto"))]
66
use crate::sys::time::TIMESPEC_MAX;
77
#[cfg(target_os = "nto")]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::sys::locks::Mutex;
21
use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
2+
use crate::sys::sync::Mutex;
33
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
44
use crate::time::Duration;
55

library/std/src/sys/locks/condvar/teeos.rs library/std/src/sys/sync/condvar/teeos.rs

+1-1
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::mutex::{self, Mutex};
4+
use crate::sys::sync::mutex::{self, Mutex};
55
use crate::sys::time::TIMESPEC_MAX;
66
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
77
use crate::time::Duration;

library/std/src/sys/locks/condvar/windows7.rs library/std/src/sys/sync/condvar/windows7.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::cell::UnsafeCell;
22
use crate::sys::c;
3-
use crate::sys::locks::{mutex, Mutex};
43
use crate::sys::os;
4+
use crate::sys::sync::{mutex, Mutex};
55
use crate::time::Duration;
66

77
pub struct Condvar {

library/std/src/sys/locks/condvar/xous.rs library/std/src/sys/sync/condvar/xous.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::os::xous::ffi::{blocking_scalar, scalar};
22
use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
3-
use crate::sys::locks::Mutex;
3+
use crate::sys::sync::Mutex;
44
use crate::time::Duration;
55
use core::sync::atomic::{AtomicUsize, Ordering};
66

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
mod condvar;
22
mod mutex;
3+
mod once;
34
mod rwlock;
45

56
pub use condvar::Condvar;
67
pub use mutex::Mutex;
8+
pub use once::{Once, OnceState};
79
pub use rwlock::RwLock;
File renamed without changes.
File renamed without changes.
File renamed without changes.

library/std/src/sys_common/once/mod.rs library/std/src/sys/sync/once/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cfg_if::cfg_if! {
3030
mod queue;
3131
pub use queue::{Once, OnceState};
3232
} else {
33-
pub use crate::sys::once::{Once, OnceState};
33+
mod no_threads;
34+
pub use no_threads::{Once, OnceState};
3435
}
3536
}
File renamed without changes.
File renamed without changes.

library/std/src/sys/locks/rwlock/teeos.rs library/std/src/sys/sync/rwlock/teeos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::sys::locks::mutex::Mutex;
1+
use crate::sys::sync::mutex::Mutex;
22

33
/// we do not supported rwlock, so use mutex to simulate rwlock.
44
/// it's useful because so many code in std will use rwlock.

library/std/src/sys_common/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub mod backtrace;
2424
pub mod fs;
2525
pub mod io;
2626
pub mod lazy_box;
27-
pub mod once;
2827
pub mod process;
2928
pub mod thread;
3029
pub mod thread_info;

tests/debuginfo/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
// cdb-command:dx m,d
1212
// cdb-check:m,d [Type: std::sync::mutex::Mutex<i32>]
13-
// cdb-check: [...] inner [Type: std::sys::locks::mutex::futex::Mutex]
13+
// cdb-check: [...] inner [Type: std::sys::sync::mutex::futex::Mutex]
1414
// cdb-check: [...] poison [Type: std::sync::poison::Flag]
1515
// cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell<i32>]
1616

tests/debuginfo/rwlock-read.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// cdb-command:dx r
1717
// cdb-check:r [Type: std::sync::rwlock::RwLockReadGuard<i32>]
1818
// cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull<i32>]
19-
// cdb-check: [...] inner_lock : [...] [Type: std::sys::locks::rwlock::futex::RwLock *]
19+
// cdb-check: [...] inner_lock : [...] [Type: std::sys::sync::rwlock::futex::RwLock *]
2020

2121
#[allow(unused_variables)]
2222

0 commit comments

Comments
 (0)