Rollup merge of #121943 - joshlf:patch-11, r=scottmcm
Clarify atomic bit validity The previous definition used the phrase "representation", which is ambiguous given the current state of memory model nomenclature in Rust. For integer types and for `AtomicPtr<T>`, the new wording clarifies that size and bit validity are guaranteed to match the corresponding native integer type/`*mut T`. For `AtomicBool`, the new wording clarifies that size, alignment, and bit validity are guaranteed to match `bool`. Note that we use the phrase "size and alignment" rather than "layout" since the latter term also implies that the field types are the same. This isn't true - `AtomicXxx` doesn't store an `xxx`, but rather an `UnsafeCell<xxx>`. This distinction is important for some `unsafe` code, which needs to reason about the presence or absence of interior mutability in order to ensure that their code is sound (see e.g. https://github.com/google/zerocopy/issues/251).
This commit is contained in:
commit
a9ed9fb943
1 changed files with 3 additions and 3 deletions
|
@ -243,7 +243,7 @@ const EMULATE_ATOMIC_BOOL: bool =
|
|||
|
||||
/// A boolean type which can be safely shared between threads.
|
||||
///
|
||||
/// This type has the same in-memory representation as a [`bool`].
|
||||
/// This type has the same size, alignment, and bit validity as a [`bool`].
|
||||
///
|
||||
/// **Note**: This type is only available on platforms that support atomic
|
||||
/// loads and stores of `u8`.
|
||||
|
@ -272,7 +272,7 @@ unsafe impl Sync for AtomicBool {}
|
|||
|
||||
/// A raw pointer type which can be safely shared between threads.
|
||||
///
|
||||
/// This type has the same in-memory representation as a `*mut T`.
|
||||
/// This type has the same size and bit validity as a `*mut T`.
|
||||
///
|
||||
/// **Note**: This type is only available on platforms that support atomic
|
||||
/// loads and stores of pointers. Its size depends on the target pointer's size.
|
||||
|
@ -2121,7 +2121,7 @@ macro_rules! atomic_int {
|
|||
$int_type:ident $atomic_type:ident) => {
|
||||
/// An integer type which can be safely shared between threads.
|
||||
///
|
||||
/// This type has the same in-memory representation as the underlying
|
||||
/// This type has the same size and bit validity as the underlying
|
||||
/// integer type, [`
|
||||
#[doc = $s_int_type]
|
||||
/// `].
|
||||
|
|
Loading…
Add table
Reference in a new issue