diff options
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/hermit/rwlock.rs | 14 | ||||
| -rw-r--r-- | library/std/src/sys/sgx/rwlock.rs | 22 | ||||
| -rw-r--r-- | library/std/src/sys/sgx/rwlock/tests.rs | 8 | ||||
| -rw-r--r-- | library/std/src/sys/solid/os.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/solid/rwlock.rs | 14 | ||||
| -rw-r--r-- | library/std/src/sys/unix/locks/mod.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/unix/locks/pthread_rwlock.rs | 14 | ||||
| -rw-r--r-- | library/std/src/sys/unix/os.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/unsupported/locks/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unsupported/locks/rwlock.rs | 14 | ||||
| -rw-r--r-- | library/std/src/sys/wasm/atomics/rwlock.rs | 14 | ||||
| -rw-r--r-- | library/std/src/sys/windows/locks/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/windows/locks/rwlock.rs | 14 |
13 files changed, 66 insertions, 66 deletions
diff --git a/library/std/src/sys/hermit/rwlock.rs b/library/std/src/sys/hermit/rwlock.rs index 1cca809764c..690bb155e1a 100644 --- a/library/std/src/sys/hermit/rwlock.rs +++ b/library/std/src/sys/hermit/rwlock.rs @@ -1,13 +1,13 @@ use crate::cell::UnsafeCell; use crate::sys::locks::{Condvar, Mutex}; -pub struct RWLock { +pub struct RwLock { lock: Mutex, cond: Condvar, state: UnsafeCell<State>, } -pub type MovableRWLock = RWLock; +pub type MovableRwLock = RwLock; enum State { Unlocked, @@ -15,8 +15,8 @@ enum State { Writing, } -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} // This rwlock implementation is a relatively simple implementation which has a // condition variable for readers/writers as well as a mutex protecting the @@ -26,9 +26,9 @@ unsafe impl Sync for RWLock {} // hopefully correct this implementation is very likely to want to be changed in // the future. -impl RWLock { - pub const fn new() -> RWLock { - RWLock { lock: Mutex::new(), cond: Condvar::new(), state: UnsafeCell::new(State::Unlocked) } +impl RwLock { + pub const fn new() -> RwLock { + RwLock { lock: Mutex::new(), cond: Condvar::new(), state: UnsafeCell::new(State::Unlocked) } } #[inline] diff --git a/library/std/src/sys/sgx/rwlock.rs b/library/std/src/sys/sgx/rwlock.rs index 2d038b51896..47be4c006ec 100644 --- a/library/std/src/sys/sgx/rwlock.rs +++ b/library/std/src/sys/sgx/rwlock.rs @@ -8,25 +8,25 @@ use super::waitqueue::{ }; use crate::mem; -pub struct RWLock { +pub struct RwLock { readers: SpinMutex<WaitVariable<Option<NonZeroUsize>>>, writer: SpinMutex<WaitVariable<bool>>, } -pub type MovableRWLock = Box<RWLock>; +pub type MovableRwLock = Box<RwLock>; -// Check at compile time that RWLock size matches C definition (see test_c_rwlock_initializer below) +// Check at compile time that RwLock size matches C definition (see test_c_rwlock_initializer below) // // # Safety // Never called, as it is a compile time check. #[allow(dead_code)] -unsafe fn rw_lock_size_assert(r: RWLock) { - unsafe { mem::transmute::<RWLock, [u8; 144]>(r) }; +unsafe fn rw_lock_size_assert(r: RwLock) { + unsafe { mem::transmute::<RwLock, [u8; 144]>(r) }; } -impl RWLock { - pub const fn new() -> RWLock { - RWLock { +impl RwLock { + pub const fn new() -> RwLock { + RwLock { readers: SpinMutex::new(WaitVariable::new(None)), writer: SpinMutex::new(WaitVariable::new(false)), } @@ -180,7 +180,7 @@ const EINVAL: i32 = 22; #[cfg(not(test))] #[no_mangle] -pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RWLock) -> i32 { +pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; } @@ -190,7 +190,7 @@ pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RWLock) -> i32 { #[cfg(not(test))] #[no_mangle] -pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RWLock) -> i32 { +pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; } @@ -199,7 +199,7 @@ pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RWLock) -> i32 { } #[cfg(not(test))] #[no_mangle] -pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RWLock) -> i32 { +pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; } diff --git a/library/std/src/sys/sgx/rwlock/tests.rs b/library/std/src/sys/sgx/rwlock/tests.rs index 17c9e72ee39..4799961154a 100644 --- a/library/std/src/sys/sgx/rwlock/tests.rs +++ b/library/std/src/sys/sgx/rwlock/tests.rs @@ -1,7 +1,7 @@ use super::*; -// Verify that the byte pattern libunwind uses to initialize an RWLock is -// equivalent to the value of RWLock::new(). If the value changes, +// Verify that the byte pattern libunwind uses to initialize an RwLock is +// equivalent to the value of RwLock::new(). If the value changes, // `src/UnwindRustSgx.h` in libunwind needs to be changed too. #[test] fn test_c_rwlock_initializer() { @@ -18,9 +18,9 @@ fn test_c_rwlock_initializer() { /* 0x80 */ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ]; - // For the test to work, we need the padding/unused bytes in RWLock to be + // For the test to work, we need the padding/unused bytes in RwLock to be // initialized as 0. In practice, this is the case with statics. - static RUST_RWLOCK_INIT: RWLock = RWLock::new(); + static RUST_RWLOCK_INIT: RwLock = RwLock::new(); unsafe { // If the assertion fails, that not necessarily an issue with the value diff --git a/library/std/src/sys/solid/os.rs b/library/std/src/sys/solid/os.rs index 127cca3acca..719d95bbe50 100644 --- a/library/std/src/sys/solid/os.rs +++ b/library/std/src/sys/solid/os.rs @@ -8,7 +8,7 @@ use crate::os::{ solid::ffi::{OsStrExt, OsStringExt}, }; use crate::path::{self, PathBuf}; -use crate::sys_common::rwlock::StaticRWLock; +use crate::sys_common::rwlock::StaticRwLock; use crate::vec; use super::{abi, error, itron, memchr}; @@ -78,7 +78,7 @@ pub fn current_exe() -> io::Result<PathBuf> { unsupported() } -static ENV_LOCK: StaticRWLock = StaticRWLock::new(); +static ENV_LOCK: StaticRwLock = StaticRwLock::new(); pub struct Env { iter: vec::IntoIter<(OsString, OsString)>, diff --git a/library/std/src/sys/solid/rwlock.rs b/library/std/src/sys/solid/rwlock.rs index 4e39ac2a930..df16cc680ad 100644 --- a/library/std/src/sys/solid/rwlock.rs +++ b/library/std/src/sys/solid/rwlock.rs @@ -7,24 +7,24 @@ use super::{ }, }; -pub struct RWLock { +pub struct RwLock { /// The ID of the underlying mutex object rwl: SpinIdOnceCell<()>, } -pub type MovableRWLock = RWLock; +pub type MovableRwLock = RwLock; // Safety: `num_readers` is protected by `mtx_num_readers` -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} fn new_rwl() -> Result<abi::ID, ItronError> { ItronError::err_if_negative(unsafe { abi::rwl_acre_rwl() }) } -impl RWLock { - pub const fn new() -> RWLock { - RWLock { rwl: SpinIdOnceCell::new() } +impl RwLock { + pub const fn new() -> RwLock { + RwLock { rwl: SpinIdOnceCell::new() } } /// Get the inner mutex's ID, which is lazily created. diff --git a/library/std/src/sys/unix/locks/mod.rs b/library/std/src/sys/unix/locks/mod.rs index 30e9f407eec..2b8dd168068 100644 --- a/library/std/src/sys/unix/locks/mod.rs +++ b/library/std/src/sys/unix/locks/mod.rs @@ -10,7 +10,7 @@ cfg_if::cfg_if! { mod pthread_rwlock; // FIXME: Implement this using a futex pub use futex::{Mutex, MovableMutex, Condvar, MovableCondvar}; pub use pthread_remutex::ReentrantMutex; - pub use pthread_rwlock::{RWLock, MovableRWLock}; + pub use pthread_rwlock::{RwLock, MovableRwLock}; } else { mod pthread_mutex; mod pthread_remutex; @@ -18,7 +18,7 @@ cfg_if::cfg_if! { mod pthread_condvar; pub use pthread_mutex::{Mutex, MovableMutex}; pub use pthread_remutex::ReentrantMutex; - pub use pthread_rwlock::{RWLock, MovableRWLock}; + pub use pthread_rwlock::{RwLock, MovableRwLock}; pub use pthread_condvar::{Condvar, MovableCondvar}; } } diff --git a/library/std/src/sys/unix/locks/pthread_rwlock.rs b/library/std/src/sys/unix/locks/pthread_rwlock.rs index 1318c5b8e3a..11a0c0457cd 100644 --- a/library/std/src/sys/unix/locks/pthread_rwlock.rs +++ b/library/std/src/sys/unix/locks/pthread_rwlock.rs @@ -1,20 +1,20 @@ use crate::cell::UnsafeCell; use crate::sync::atomic::{AtomicUsize, Ordering}; -pub struct RWLock { +pub struct RwLock { inner: UnsafeCell<libc::pthread_rwlock_t>, write_locked: UnsafeCell<bool>, // guarded by the `inner` RwLock num_readers: AtomicUsize, } -pub type MovableRWLock = Box<RWLock>; +pub type MovableRwLock = Box<RwLock>; -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} -impl RWLock { - pub const fn new() -> RWLock { - RWLock { +impl RwLock { + pub const fn new() -> RwLock { + RwLock { inner: UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER), write_locked: UnsafeCell::new(false), num_readers: AtomicUsize::new(0), diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs index 0b6cdb923bd..1be733ba106 100644 --- a/library/std/src/sys/unix/os.rs +++ b/library/std/src/sys/unix/os.rs @@ -20,7 +20,7 @@ use crate::str; use crate::sys::cvt; use crate::sys::fd; use crate::sys::memchr; -use crate::sys_common::rwlock::{StaticRWLock, StaticRWLockReadGuard}; +use crate::sys_common::rwlock::{StaticRwLock, StaticRwLockReadGuard}; use crate::vec; #[cfg(all(target_env = "gnu", not(target_os = "vxworks")))] @@ -481,9 +481,9 @@ pub unsafe fn environ() -> *mut *const *const c_char { ptr::addr_of_mut!(environ) } -static ENV_LOCK: StaticRWLock = StaticRWLock::new(); +static ENV_LOCK: StaticRwLock = StaticRwLock::new(); -pub fn env_read_lock() -> StaticRWLockReadGuard { +pub fn env_read_lock() -> StaticRwLockReadGuard { ENV_LOCK.read() } diff --git a/library/std/src/sys/unsupported/locks/mod.rs b/library/std/src/sys/unsupported/locks/mod.rs index 5634f106339..35bd5913034 100644 --- a/library/std/src/sys/unsupported/locks/mod.rs +++ b/library/std/src/sys/unsupported/locks/mod.rs @@ -3,4 +3,4 @@ mod mutex; mod rwlock; pub use condvar::{Condvar, MovableCondvar}; pub use mutex::{MovableMutex, Mutex, ReentrantMutex}; -pub use rwlock::{MovableRWLock, RWLock}; +pub use rwlock::{MovableRwLock, RwLock}; diff --git a/library/std/src/sys/unsupported/locks/rwlock.rs b/library/std/src/sys/unsupported/locks/rwlock.rs index 8438adeb5b5..14fd351314c 100644 --- a/library/std/src/sys/unsupported/locks/rwlock.rs +++ b/library/std/src/sys/unsupported/locks/rwlock.rs @@ -1,18 +1,18 @@ use crate::cell::Cell; -pub struct RWLock { +pub struct RwLock { // This platform has no threads, so we can use a Cell here. mode: Cell<isize>, } -pub type MovableRWLock = RWLock; +pub type MovableRwLock = RwLock; -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} // no threads on this platform +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} // no threads on this platform -impl RWLock { - pub const fn new() -> RWLock { - RWLock { mode: Cell::new(0) } +impl RwLock { + pub const fn new() -> RwLock { + RwLock { mode: Cell::new(0) } } #[inline] diff --git a/library/std/src/sys/wasm/atomics/rwlock.rs b/library/std/src/sys/wasm/atomics/rwlock.rs index 1cca809764c..690bb155e1a 100644 --- a/library/std/src/sys/wasm/atomics/rwlock.rs +++ b/library/std/src/sys/wasm/atomics/rwlock.rs @@ -1,13 +1,13 @@ use crate::cell::UnsafeCell; use crate::sys::locks::{Condvar, Mutex}; -pub struct RWLock { +pub struct RwLock { lock: Mutex, cond: Condvar, state: UnsafeCell<State>, } -pub type MovableRWLock = RWLock; +pub type MovableRwLock = RwLock; enum State { Unlocked, @@ -15,8 +15,8 @@ enum State { Writing, } -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} // This rwlock implementation is a relatively simple implementation which has a // condition variable for readers/writers as well as a mutex protecting the @@ -26,9 +26,9 @@ unsafe impl Sync for RWLock {} // hopefully correct this implementation is very likely to want to be changed in // the future. -impl RWLock { - pub const fn new() -> RWLock { - RWLock { lock: Mutex::new(), cond: Condvar::new(), state: UnsafeCell::new(State::Unlocked) } +impl RwLock { + pub const fn new() -> RwLock { + RwLock { lock: Mutex::new(), cond: Condvar::new(), state: UnsafeCell::new(State::Unlocked) } } #[inline] diff --git a/library/std/src/sys/windows/locks/mod.rs b/library/std/src/sys/windows/locks/mod.rs index 5634f106339..35bd5913034 100644 --- a/library/std/src/sys/windows/locks/mod.rs +++ b/library/std/src/sys/windows/locks/mod.rs @@ -3,4 +3,4 @@ mod mutex; mod rwlock; pub use condvar::{Condvar, MovableCondvar}; pub use mutex::{MovableMutex, Mutex, ReentrantMutex}; -pub use rwlock::{MovableRWLock, RWLock}; +pub use rwlock::{MovableRwLock, RwLock}; diff --git a/library/std/src/sys/windows/locks/rwlock.rs b/library/std/src/sys/windows/locks/rwlock.rs index b7a5b1e7acc..12906652e0b 100644 --- a/library/std/src/sys/windows/locks/rwlock.rs +++ b/library/std/src/sys/windows/locks/rwlock.rs @@ -1,18 +1,18 @@ use crate::cell::UnsafeCell; use crate::sys::c; -pub struct RWLock { +pub struct RwLock { inner: UnsafeCell<c::SRWLOCK>, } -pub type MovableRWLock = RWLock; +pub type MovableRwLock = RwLock; -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} +unsafe impl Send for RwLock {} +unsafe impl Sync for RwLock {} -impl RWLock { - pub const fn new() -> RWLock { - RWLock { inner: UnsafeCell::new(c::SRWLOCK_INIT) } +impl RwLock { + pub const fn new() -> RwLock { + RwLock { inner: UnsafeCell::new(c::SRWLOCK_INIT) } } #[inline] pub unsafe fn read(&self) { |
