From 224f046492cd58e63ff053e26095cb70e37c1156 Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Mon, 6 Jan 2025 12:36:25 +0100 Subject: [PATCH] chore: use unsync loads for `unsync_load` This reverts #6203 and #6179. --- tokio/src/loom/std/atomic_u16.rs | 3 +-- tokio/src/loom/std/atomic_u32.rs | 3 +-- tokio/src/loom/std/atomic_usize.rs | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tokio/src/loom/std/atomic_u16.rs b/tokio/src/loom/std/atomic_u16.rs index 32ae349c33f..a9bdcb573c6 100644 --- a/tokio/src/loom/std/atomic_u16.rs +++ b/tokio/src/loom/std/atomic_u16.rs @@ -26,8 +26,7 @@ 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 { - // See - self.load(std::sync::atomic::Ordering::Relaxed) + core::ptr::read(self.inner.get() as *const u16) } } diff --git a/tokio/src/loom/std/atomic_u32.rs b/tokio/src/loom/std/atomic_u32.rs index c34ca940f8a..004bd9d75f7 100644 --- a/tokio/src/loom/std/atomic_u32.rs +++ b/tokio/src/loom/std/atomic_u32.rs @@ -26,8 +26,7 @@ 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 { - // See - self.load(std::sync::atomic::Ordering::Relaxed) + core::ptr::read(self.inner.get() as *const u32) } } diff --git a/tokio/src/loom/std/atomic_usize.rs b/tokio/src/loom/std/atomic_usize.rs index f88cc4bf727..0dee481b68e 100644 --- a/tokio/src/loom/std/atomic_usize.rs +++ b/tokio/src/loom/std/atomic_usize.rs @@ -26,8 +26,7 @@ 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 { - // See - self.load(std::sync::atomic::Ordering::Relaxed) + core::ptr::read(self.inner.get() as *const usize) } pub(crate) fn with_mut(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {