Skip to content

Commit

Permalink
Clarify overlapping accesses in Atomic*::from_ptr docs
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Oct 16, 2023
1 parent e0467f8 commit 9ab403c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,11 @@ impl AtomicBool {
/// duration of lifetime `'a`. Most use cases should be able to follow this guideline.
/// * This requirement is also trivially satisfied if all accesses (atomic or not) are done
/// from the same thread.
/// * This method must not be used to perform overlapping or mixed-size atomic
/// accesses, as these are not supported by the memory model.
/// * Atomic accesses that overlap must either all use the same address and size,
/// or they must have a happens-before relationship.
/// * In other words, within one of the atomic time periods mentioned in the previous
/// bullet, there cannot be accesses to the same value that overlap only partially.
/// They must either not overlap at all or overlap perfectly.
///
/// [valid]: crate::ptr#safety
#[stable(feature = "atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")]
Expand Down Expand Up @@ -1161,8 +1164,11 @@ impl<T> AtomicPtr<T> {
/// duration of lifetime `'a`. Most use cases should be able to follow this guideline.
/// * This requirement is also trivially satisfied if all accesses (atomic or not) are done
/// from the same thread.
/// * This method must not be used to perform overlapping or mixed-size atomic accesses, as
/// these are not supported by the memory model.
/// * Atomic accesses that overlap must either all use the same address and size,
/// or they must have a happens-before relationship.
/// * In other words, within one of the atomic time periods mentioned in the previous
/// bullet, there cannot be accesses to the same value that overlap only partially.
/// They must either not overlap at all or overlap perfectly.
///
/// [valid]: crate::ptr#safety
#[stable(feature = "atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")]
Expand Down Expand Up @@ -2144,8 +2150,11 @@ macro_rules! atomic_int {
/// this guideline.
/// * This requirement is also trivially satisfied if all accesses (atomic or not) are
/// done from the same thread.
/// * This method must not be used to perform overlapping or mixed-size atomic
/// accesses, as these are not supported by the memory model.
/// * Atomic accesses that overlap must either all use the same address and size,
/// or they must have a happens-before relationship.
/// * In other words, within one of the atomic time periods mentioned in the previous
/// bullet, there cannot be accesses to the same value that overlap only partially.
/// They must either not overlap at all or overlap perfectly.
///
/// [valid]: crate::ptr#safety
#[stable(feature = "atomic_from_ptr", since = "CURRENT_RUSTC_VERSION")]
Expand Down

0 comments on commit 9ab403c

Please sign in to comment.