Skip to content

Commit c663da8

Browse files
committed
Cast pointers to usize before passing them to atomic operations as some platforms do not support atomic operations on pointers.
1 parent 80c0511 commit c663da8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/sync/atomic.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,10 @@ impl<T> AtomicPtr<T> {
12011201
}
12021202
}
12031203
#[cfg(not(bootstrap))]
1204-
// SAFETY: data races are prevented by atomic intrinsics.
1204+
// SAFETY: This intrinsic is unsafe because it operates on a raw pointer
1205+
// but we know for sure that the pointer is valid (we just got it from
1206+
// an `UnsafeCell` that we have by reference) and the atomic operation
1207+
// itself allows us to safely mutate the `UnsafeCell` contents.
12051208
unsafe {
12061209
atomic_compare_exchange_weak(self.p.get(), current, new, success, failure)
12071210
}

0 commit comments

Comments
 (0)