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 fbf092e

Browse files
committedSep 19, 2024·
use generic Atomic type where possible
in core/alloc/std only for now, and ignoring test files
1 parent e65783d commit fbf092e

Some content is hidden

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

75 files changed

+246
-240
lines changed
 

‎library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
#![feature(extend_one_unchecked)]
126126
#![feature(fmt_internals)]
127127
#![feature(fn_traits)]
128+
#![feature(generic_atomic)]
128129
#![feature(hasher_prefixfree_extras)]
129130
#![feature(inplace_iteration)]
130131
#![feature(iter_advance_by)]

‎library/alloc/src/sync.rs

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

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

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

356356
data: T,
357357
}
@@ -2706,8 +2706,8 @@ impl<T, A: Allocator> Weak<T, A> {
27062706
/// Helper type to allow accessing the reference counts without
27072707
/// making any assertions about the data field.
27082708
struct WeakInner<'a> {
2709-
weak: &'a atomic::AtomicUsize,
2710-
strong: &'a atomic::AtomicUsize,
2709+
weak: &'a Atomic<usize>,
2710+
strong: &'a Atomic<usize>,
27112711
}
27122712

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

0 commit comments

Comments
 (0)
Please sign in to comment.