From 59a3a5dba314d4b693d141a56fde2e6a879d0af0 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 3 Mar 2024 07:55:23 -0800 Subject: [PATCH 1/6] Clarify atomic bit validity The previous definition used the phrase "representation", which is ambiguous given the current state of memory model nomenclature in Rust. The new wording clarifies that size and bit validity are guaranteed to match the corresponding native integer type. --- library/core/src/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 45193c11e1d6b..303f1bf8f65e4 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -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 in-memory size and bit validity as the underlying /// integer type, [` #[doc = $s_int_type] /// `]. From db34b082c0895e80bc9eda17a4c859c51e6509bd Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 3 Mar 2024 07:57:35 -0800 Subject: [PATCH 2/6] Clarify bit validity for AtomicBool --- library/core/src/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 303f1bf8f65e4..5947f6569a7fa 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -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 memory layout and bit validity as a [`bool`]. /// /// **Note**: This type is only available on platforms that support atomic /// loads and stores of `u8`. From 00d21c91f0cafc97dabe261f934af7ea0df089b4 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 3 Mar 2024 08:04:41 -0800 Subject: [PATCH 3/6] Document AtomicPtr bit validity --- library/core/src/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 5947f6569a7fa..4eaacdfe7945b 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -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 memory layout 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. From fba87f6892a052fdaed45993a1ec03d6c51ab87d Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 3 Mar 2024 08:06:41 -0800 Subject: [PATCH 4/6] Use "size and alignment" rather than layout --- library/core/src/sync/atomic.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 4eaacdfe7945b..0a0daa49926a2 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -243,7 +243,7 @@ const EMULATE_ATOMIC_BOOL: bool = /// A boolean type which can be safely shared between threads. /// -/// This type has the same memory layout and bit validity 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 memory layout and bit validity as a `*mut T`. +/// This type has the same size, alignment, 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. From c50804cfdd5deac77a8eff6e1b2303b6453e786f Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 3 Mar 2024 08:08:52 -0800 Subject: [PATCH 5/6] Update library/core/src/sync/atomic.rs Co-authored-by: Taiki Endo --- library/core/src/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index 0a0daa49926a2..aac0acbadbfc9 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -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 size and bit validity as the underlying + /// This type has the same size and bit validity as the underlying /// integer type, [` #[doc = $s_int_type] /// `]. From a6e3e02d70708c6777e2b4090e12d7ee528fd1ac Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Sun, 3 Mar 2024 08:12:56 -0800 Subject: [PATCH 6/6] Update library/core/src/sync/atomic.rs Co-authored-by: Taiki Endo --- library/core/src/sync/atomic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs index aac0acbadbfc9..632f5f4be685d 100644 --- a/library/core/src/sync/atomic.rs +++ b/library/core/src/sync/atomic.rs @@ -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 size, alignment, and bit validity 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.