Skip to content

Commit

Permalink
runtime: fix unsync_load on atomic types (#5175)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Nov 6, 2022
1 parent a1002a2 commit 9884fe3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tokio/src/loom/std/atomic_u16.rs
Expand Up @@ -23,7 +23,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 {
*(*self.inner.get()).get_mut()
core::ptr::read(self.inner.get() as *const u16)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/loom/std/atomic_u32.rs
Expand Up @@ -23,7 +23,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 {
*(*self.inner.get()).get_mut()
core::ptr::read(self.inner.get() as *const u32)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tokio/src/loom/std/atomic_usize.rs
Expand Up @@ -23,7 +23,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 {
*(*self.inner.get()).get_mut()
core::ptr::read(self.inner.get() as *const usize)
}

pub(crate) fn with_mut<R>(&mut self, f: impl FnOnce(&mut usize) -> R) -> R {
Expand Down
2 changes: 1 addition & 1 deletion tokio/src/runtime/tests/queue.rs
Expand Up @@ -111,7 +111,7 @@ const fn normal_or_miri(normal: usize, miri: usize) -> usize {

#[test]
fn stress1() {
const NUM_ITER: usize = 1;
const NUM_ITER: usize = 5;
const NUM_STEAL: usize = normal_or_miri(1_000, 10);
const NUM_LOCAL: usize = normal_or_miri(1_000, 10);
const NUM_PUSH: usize = normal_or_miri(500, 10);
Expand Down

0 comments on commit 9884fe3

Please sign in to comment.