Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 83c5b7a

Browse files
CAD97GrigorenkoPV
andcommittedFeb 1, 2025·
use generic Atomic type where possible
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <[email protected]>
1 parent e117c9d commit 83c5b7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+262
-255
lines changed
 

‎library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
#![feature(fmt_internals)]
121121
#![feature(fn_traits)]
122122
#![feature(formatting_options)]
123+
#![feature(generic_atomic)]
123124
#![feature(hasher_prefixfree_extras)]
124125
#![feature(inplace_iteration)]
125126
#![feature(iter_advance_by)]

‎library/alloc/src/sync.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use core::pin::{Pin, PinCoerceUnsized};
2525
use core::ptr::{self, NonNull};
2626
#[cfg(not(no_global_oom_handling))]
2727
use core::slice::from_raw_parts_mut;
28-
use core::sync::atomic;
2928
use core::sync::atomic::Ordering::{Acquire, Relaxed, Release};
29+
use core::sync::atomic::{self, Atomic};
3030
use core::{borrow, fmt, hint};
3131

3232
#[cfg(not(no_global_oom_handling))]
@@ -348,12 +348,12 @@ impl<T: ?Sized, A: Allocator> fmt::Debug for Weak<T, A> {
348348
// inner types.
349349
#[repr(C)]
350350
struct ArcInner<T: ?Sized> {
351-
strong: atomic::AtomicUsize,
351+
strong: Atomic<usize>,
352352

353353
// the value usize::MAX acts as a sentinel for temporarily "locking" the
354354
// ability to upgrade weak pointers or downgrade strong ones; this is used
355355
// to avoid races in `make_mut` and `get_mut`.
356-
weak: atomic::AtomicUsize,
356+
weak: Atomic<usize>,
357357

358358
data: T,
359359
}
@@ -2724,8 +2724,8 @@ impl<T, A: Allocator> Weak<T, A> {
27242724
/// Helper type to allow accessing the reference counts without
27252725
/// making any assertions about the data field.
27262726
struct WeakInner<'a> {
2727-
weak: &'a atomic::AtomicUsize,
2728-
strong: &'a atomic::AtomicUsize,
2727+
weak: &'a Atomic<usize>,
2728+
strong: &'a Atomic<usize>,
27292729
}
27302730

27312731
impl<T: ?Sized> Weak<T> {

0 commit comments

Comments
 (0)
Please sign in to comment.