mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-21 00:00:10 +02:00
chore: use relaxed load for unsync_load on miri (#6179)
This commit is contained in:
@@ -23,7 +23,11 @@ impl AtomicU16 {
|
||||
/// All mutations must have happened before the unsynchronized load.
|
||||
/// Additionally, there must be no concurrent mutations.
|
||||
pub(crate) unsafe fn unsync_load(&self) -> u16 {
|
||||
core::ptr::read(self.inner.get() as *const u16)
|
||||
// See <https://github.com/tokio-rs/tokio/issues/6155>
|
||||
#[cfg(miri)]
|
||||
return self.load(std::sync::atomic::Ordering::Relaxed);
|
||||
#[cfg(not(miri))]
|
||||
return core::ptr::read(self.inner.get() as *const u16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,11 @@ impl AtomicU32 {
|
||||
/// All mutations must have happened before the unsynchronized load.
|
||||
/// Additionally, there must be no concurrent mutations.
|
||||
pub(crate) unsafe fn unsync_load(&self) -> u32 {
|
||||
core::ptr::read(self.inner.get() as *const u32)
|
||||
// See <https://github.com/tokio-rs/tokio/issues/6155>
|
||||
#[cfg(miri)]
|
||||
return self.load(std::sync::atomic::Ordering::Relaxed);
|
||||
#[cfg(not(miri))]
|
||||
return core::ptr::read(self.inner.get() as *const u32);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,11 @@ impl AtomicUsize {
|
||||
/// All mutations must have happened before the unsynchronized load.
|
||||
/// Additionally, there must be no concurrent mutations.
|
||||
pub(crate) unsafe fn unsync_load(&self) -> usize {
|
||||
core::ptr::read(self.inner.get() as *const usize)
|
||||
// See <https://github.com/tokio-rs/tokio/issues/6155>
|
||||
#[cfg(miri)]
|
||||
return self.load(std::sync::atomic::Ordering::Relaxed);
|
||||
#[cfg(not(miri))]
|
||||
return core::ptr::read(self.inner.get() as *const usize);
|
||||
}
|
||||
|
||||
pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {
|
||||
|
||||
Reference in New Issue
Block a user