Rollup merge of #122386 - joboet:move_pal_once, r=jhpratt
Move `Once` implementations to `sys` Part of https://github.com/rust-lang/rust/issues/117276.
This commit is contained in:
commit
dff680d359
@ -52,7 +52,7 @@ Copyright: 2019 The Crossbeam Project Developers
|
|||||||
The Rust Project Developers (see https://thanks.rust-lang.org)
|
The Rust Project Developers (see https://thanks.rust-lang.org)
|
||||||
License: MIT OR Apache-2.0
|
License: MIT OR Apache-2.0
|
||||||
|
|
||||||
Files: library/std/src/sys/locks/mutex/fuchsia.rs
|
Files: library/std/src/sys/sync/mutex/fuchsia.rs
|
||||||
Copyright: 2016 The Fuchsia Authors
|
Copyright: 2016 The Fuchsia Authors
|
||||||
The Rust Project Developers (see https://thanks.rust-lang.org)
|
The Rust Project Developers (see https://thanks.rust-lang.org)
|
||||||
License: BSD-2-Clause AND (MIT OR Apache-2.0)
|
License: BSD-2-Clause AND (MIT OR Apache-2.0)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
|
use crate::sync::{mutex, poison, LockResult, MutexGuard, PoisonError};
|
||||||
use crate::sys::locks as sys;
|
use crate::sys::sync as sys;
|
||||||
use crate::time::{Duration, Instant};
|
use crate::time::{Duration, Instant};
|
||||||
|
|
||||||
/// A type indicating whether a timed wait on a condition variable returned
|
/// A type indicating whether a timed wait on a condition variable returned
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
use crate::ops::{Deref, DerefMut};
|
use crate::ops::{Deref, DerefMut};
|
||||||
use crate::ptr::NonNull;
|
use crate::ptr::NonNull;
|
||||||
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
|
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
|
||||||
use crate::sys::locks as sys;
|
use crate::sys::sync as sys;
|
||||||
|
|
||||||
/// A mutual exclusion primitive useful for protecting shared data
|
/// A mutual exclusion primitive useful for protecting shared data
|
||||||
///
|
///
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
use crate::fmt;
|
use crate::fmt;
|
||||||
use crate::panic::{RefUnwindSafe, UnwindSafe};
|
use crate::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
use crate::sys_common::once as sys;
|
use crate::sys::sync as sys;
|
||||||
|
|
||||||
/// A synchronization primitive which can be used to run a one-time global
|
/// A synchronization primitive which can be used to run a one-time global
|
||||||
/// initialization. Useful for one-time initialization for FFI or related
|
/// initialization. Useful for one-time initialization for FFI or related
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
use crate::ops::Deref;
|
use crate::ops::Deref;
|
||||||
use crate::panic::{RefUnwindSafe, UnwindSafe};
|
use crate::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
||||||
use crate::sys::locks as sys;
|
use crate::sys::sync as sys;
|
||||||
|
|
||||||
/// A re-entrant mutual exclusion lock
|
/// A re-entrant mutual exclusion lock
|
||||||
///
|
///
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
use crate::ops::{Deref, DerefMut};
|
use crate::ops::{Deref, DerefMut};
|
||||||
use crate::ptr::NonNull;
|
use crate::ptr::NonNull;
|
||||||
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
|
use crate::sync::{poison, LockResult, TryLockError, TryLockResult};
|
||||||
use crate::sys::locks as sys;
|
use crate::sys::sync as sys;
|
||||||
|
|
||||||
/// A reader-writer lock
|
/// A reader-writer lock
|
||||||
///
|
///
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
mod personality;
|
mod personality;
|
||||||
|
|
||||||
pub mod cmath;
|
pub mod cmath;
|
||||||
pub mod locks;
|
|
||||||
pub mod os_str;
|
pub mod os_str;
|
||||||
pub mod path;
|
pub mod path;
|
||||||
|
pub mod sync;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
pub mod thread_local;
|
pub mod thread_local;
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#[path = "../unsupported/io.rs"]
|
#[path = "../unsupported/io.rs"]
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod net;
|
pub mod net;
|
||||||
#[path = "../unsupported/once.rs"]
|
|
||||||
pub mod once;
|
|
||||||
pub mod os;
|
pub mod os;
|
||||||
#[path = "../unsupported/pipe.rs"]
|
#[path = "../unsupported/pipe.rs"]
|
||||||
pub mod pipe;
|
pub mod pipe;
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
pub mod io;
|
pub mod io;
|
||||||
#[path = "../unsupported/net.rs"]
|
#[path = "../unsupported/net.rs"]
|
||||||
pub mod net;
|
pub mod net;
|
||||||
#[path = "../unsupported/once.rs"]
|
|
||||||
pub mod once;
|
|
||||||
pub mod os;
|
pub mod os;
|
||||||
#[path = "../unsupported/pipe.rs"]
|
#[path = "../unsupported/pipe.rs"]
|
||||||
pub mod pipe;
|
pub mod pipe;
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
pub mod fs;
|
pub mod fs;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod net;
|
pub mod net;
|
||||||
pub mod once;
|
|
||||||
pub mod os;
|
pub mod os;
|
||||||
pub mod pipe;
|
pub mod pipe;
|
||||||
pub mod process;
|
pub mod process;
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(not(target_feature = "atomics"))] {
|
if #[cfg(not(target_feature = "atomics"))] {
|
||||||
#[path = "../unsupported/once.rs"]
|
|
||||||
pub mod once;
|
|
||||||
#[path = "../unsupported/thread_parking.rs"]
|
#[path = "../unsupported/thread_parking.rs"]
|
||||||
pub mod thread_parking;
|
pub mod thread_parking;
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,6 @@
|
|||||||
if #[cfg(target_feature = "atomics")] {
|
if #[cfg(target_feature = "atomics")] {
|
||||||
compile_error!("The wasm32-wasip2 target does not support atomics");
|
compile_error!("The wasm32-wasip2 target does not support atomics");
|
||||||
} else {
|
} else {
|
||||||
#[path = "../unsupported/locks/mod.rs"]
|
|
||||||
pub mod locks;
|
|
||||||
#[path = "../unsupported/once.rs"]
|
|
||||||
pub mod once;
|
|
||||||
#[path = "../unsupported/thread_parking.rs"]
|
#[path = "../unsupported/thread_parking.rs"]
|
||||||
pub mod thread_parking;
|
pub mod thread_parking;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,6 @@
|
|||||||
#[path = "atomics/thread.rs"]
|
#[path = "atomics/thread.rs"]
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
} else {
|
} else {
|
||||||
#[path = "../unsupported/once.rs"]
|
|
||||||
pub mod once;
|
|
||||||
#[path = "../unsupported/thread.rs"]
|
#[path = "../unsupported/thread.rs"]
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
#[path = "../unsupported/thread_parking.rs"]
|
#[path = "../unsupported/thread_parking.rs"]
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
pub mod io;
|
pub mod io;
|
||||||
#[path = "../unsupported/net.rs"]
|
#[path = "../unsupported/net.rs"]
|
||||||
pub mod net;
|
pub mod net;
|
||||||
#[path = "../unsupported/once.rs"]
|
|
||||||
pub mod once;
|
|
||||||
pub mod os;
|
pub mod os;
|
||||||
#[path = "../unsupported/pipe.rs"]
|
#[path = "../unsupported/pipe.rs"]
|
||||||
pub mod pipe;
|
pub mod pipe;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::sync::atomic::{AtomicU32, Ordering::Relaxed};
|
use crate::sync::atomic::{AtomicU32, Ordering::Relaxed};
|
||||||
use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
|
use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all};
|
||||||
use crate::sys::locks::Mutex;
|
use crate::sys::sync::Mutex;
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
||||||
pub struct Condvar {
|
pub struct Condvar {
|
@ -2,7 +2,7 @@
|
|||||||
use crate::sys::pal::itron::{
|
use crate::sys::pal::itron::{
|
||||||
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
|
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
|
||||||
};
|
};
|
||||||
use crate::{mem::replace, ptr::NonNull, sys::locks::Mutex, time::Duration};
|
use crate::{mem::replace, ptr::NonNull, sys::sync::Mutex, time::Duration};
|
||||||
|
|
||||||
// The implementation is inspired by the queue-based implementation shown in
|
// The implementation is inspired by the queue-based implementation shown in
|
||||||
// Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores"
|
// Andrew D. Birrell's paper "Implementing Condition Variables with Semaphores"
|
@ -1,4 +1,4 @@
|
|||||||
use crate::sys::locks::Mutex;
|
use crate::sys::sync::Mutex;
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
||||||
pub struct Condvar {}
|
pub struct Condvar {}
|
@ -1,7 +1,7 @@
|
|||||||
use crate::cell::UnsafeCell;
|
use crate::cell::UnsafeCell;
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
|
use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
|
||||||
use crate::sys::locks::{mutex, Mutex};
|
use crate::sys::sync::{mutex, Mutex};
|
||||||
#[cfg(not(target_os = "nto"))]
|
#[cfg(not(target_os = "nto"))]
|
||||||
use crate::sys::time::TIMESPEC_MAX;
|
use crate::sys::time::TIMESPEC_MAX;
|
||||||
#[cfg(target_os = "nto")]
|
#[cfg(target_os = "nto")]
|
@ -1,5 +1,5 @@
|
|||||||
use crate::sys::locks::Mutex;
|
|
||||||
use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
|
use crate::sys::pal::waitqueue::{SpinMutex, WaitQueue, WaitVariable};
|
||||||
|
use crate::sys::sync::Mutex;
|
||||||
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
|
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
use crate::cell::UnsafeCell;
|
use crate::cell::UnsafeCell;
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
|
use crate::sync::atomic::{AtomicPtr, Ordering::Relaxed};
|
||||||
use crate::sys::locks::mutex::{self, Mutex};
|
use crate::sys::sync::mutex::{self, Mutex};
|
||||||
use crate::sys::time::TIMESPEC_MAX;
|
use crate::sys::time::TIMESPEC_MAX;
|
||||||
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
|
use crate::sys_common::lazy_box::{LazyBox, LazyInit};
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
@ -1,7 +1,7 @@
|
|||||||
use crate::cell::UnsafeCell;
|
use crate::cell::UnsafeCell;
|
||||||
use crate::sys::c;
|
use crate::sys::c;
|
||||||
use crate::sys::locks::{mutex, Mutex};
|
|
||||||
use crate::sys::os;
|
use crate::sys::os;
|
||||||
|
use crate::sys::sync::{mutex, Mutex};
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
||||||
pub struct Condvar {
|
pub struct Condvar {
|
@ -1,6 +1,6 @@
|
|||||||
use crate::os::xous::ffi::{blocking_scalar, scalar};
|
use crate::os::xous::ffi::{blocking_scalar, scalar};
|
||||||
use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
|
use crate::os::xous::services::{ticktimer_server, TicktimerScalar};
|
||||||
use crate::sys::locks::Mutex;
|
use crate::sys::sync::Mutex;
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
@ -1,7 +1,9 @@
|
|||||||
mod condvar;
|
mod condvar;
|
||||||
mod mutex;
|
mod mutex;
|
||||||
|
mod once;
|
||||||
mod rwlock;
|
mod rwlock;
|
||||||
|
|
||||||
pub use condvar::Condvar;
|
pub use condvar::Condvar;
|
||||||
pub use mutex::Mutex;
|
pub use mutex::Mutex;
|
||||||
|
pub use once::{Once, OnceState};
|
||||||
pub use rwlock::RwLock;
|
pub use rwlock::RwLock;
|
@ -30,6 +30,7 @@
|
|||||||
mod queue;
|
mod queue;
|
||||||
pub use queue::{Once, OnceState};
|
pub use queue::{Once, OnceState};
|
||||||
} else {
|
} else {
|
||||||
pub use crate::sys::once::{Once, OnceState};
|
mod no_threads;
|
||||||
|
pub use no_threads::{Once, OnceState};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
use crate::sys::locks::mutex::Mutex;
|
use crate::sys::sync::mutex::Mutex;
|
||||||
|
|
||||||
/// we do not supported rwlock, so use mutex to simulate rwlock.
|
/// we do not supported rwlock, so use mutex to simulate rwlock.
|
||||||
/// it's useful because so many code in std will use rwlock.
|
/// it's useful because so many code in std will use rwlock.
|
@ -24,7 +24,6 @@
|
|||||||
pub mod fs;
|
pub mod fs;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod lazy_box;
|
pub mod lazy_box;
|
||||||
pub mod once;
|
|
||||||
pub mod process;
|
pub mod process;
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
pub mod thread_info;
|
pub mod thread_info;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
//
|
//
|
||||||
// cdb-command:dx m,d
|
// cdb-command:dx m,d
|
||||||
// cdb-check:m,d [Type: std::sync::mutex::Mutex<i32>]
|
// cdb-check:m,d [Type: std::sync::mutex::Mutex<i32>]
|
||||||
// cdb-check: [...] inner [Type: std::sys::locks::mutex::futex::Mutex]
|
// cdb-check: [...] inner [Type: std::sys::sync::mutex::futex::Mutex]
|
||||||
// cdb-check: [...] poison [Type: std::sync::poison::Flag]
|
// cdb-check: [...] poison [Type: std::sync::poison::Flag]
|
||||||
// cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell<i32>]
|
// cdb-check: [...] data : 0 [Type: core::cell::UnsafeCell<i32>]
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
// cdb-command:dx r
|
// cdb-command:dx r
|
||||||
// cdb-check:r [Type: std::sync::rwlock::RwLockReadGuard<i32>]
|
// cdb-check:r [Type: std::sync::rwlock::RwLockReadGuard<i32>]
|
||||||
// cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull<i32>]
|
// cdb-check: [...] data : NonNull([...]: 0) [Type: core::ptr::non_null::NonNull<i32>]
|
||||||
// cdb-check: [...] inner_lock : [...] [Type: std::sys::locks::rwlock::futex::RwLock *]
|
// cdb-check: [...] inner_lock : [...] [Type: std::sys::sync::rwlock::futex::RwLock *]
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user