Skip to content

Commit 0982eab

Browse files
authored
Rollup merge of rust-lang#107736 - tgross35:atomic-as-ptr, r=m-ou-se
Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref rust-lang#66893) Originally discussed in rust-lang#66893 (comment) ~~This uses rust-lang#107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased `@rustbot` label +T-libs-api r? m-ou-se
2 parents b869e84 + 787b111 commit 0982eab

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

library/core/src/sync/atomic.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -922,13 +922,13 @@ impl AtomicBool {
922922
///
923923
/// let mut atomic = AtomicBool::new(true);
924924
/// unsafe {
925-
/// my_atomic_op(atomic.as_mut_ptr());
925+
/// my_atomic_op(atomic.as_ptr());
926926
/// }
927927
/// # }
928928
/// ```
929929
#[inline]
930930
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
931-
pub const fn as_mut_ptr(&self) -> *mut bool {
931+
pub const fn as_ptr(&self) -> *mut bool {
932932
self.v.get().cast()
933933
}
934934

@@ -1814,12 +1814,12 @@ impl<T> AtomicPtr<T> {
18141814
///
18151815
/// // SAFETY: Safe as long as `my_atomic_op` is atomic.
18161816
/// unsafe {
1817-
/// my_atomic_op(atomic.as_mut_ptr());
1817+
/// my_atomic_op(atomic.as_ptr());
18181818
/// }
18191819
/// ```
18201820
#[inline]
18211821
#[unstable(feature = "atomic_mut_ptr", reason = "recently added", issue = "66893")]
1822-
pub const fn as_mut_ptr(&self) -> *mut *mut T {
1822+
pub const fn as_ptr(&self) -> *mut *mut T {
18231823
self.p.get()
18241824
}
18251825
}
@@ -2719,15 +2719,15 @@ macro_rules! atomic_int {
27192719
///
27202720
/// // SAFETY: Safe as long as `my_atomic_op` is atomic.
27212721
/// unsafe {
2722-
/// my_atomic_op(atomic.as_mut_ptr());
2722+
/// my_atomic_op(atomic.as_ptr());
27232723
/// }
27242724
/// # }
27252725
/// ```
27262726
#[inline]
27272727
#[unstable(feature = "atomic_mut_ptr",
27282728
reason = "recently added",
27292729
issue = "66893")]
2730-
pub const fn as_mut_ptr(&self) -> *mut $int_type {
2730+
pub const fn as_ptr(&self) -> *mut $int_type {
27312731
self.v.get()
27322732
}
27332733
}

library/std/src/sys_common/thread_parking/id.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Parker {
6060
if state == PARKED {
6161
// Loop to guard against spurious wakeups.
6262
while state == PARKED {
63-
park(self.state.as_mut_ptr().addr());
63+
park(self.state.as_ptr().addr());
6464
state = self.state.load(Acquire);
6565
}
6666

@@ -76,7 +76,7 @@ impl Parker {
7676

7777
let state = self.state.fetch_sub(1, Acquire).wrapping_sub(1);
7878
if state == PARKED {
79-
park_timeout(dur, self.state.as_mut_ptr().addr());
79+
park_timeout(dur, self.state.as_ptr().addr());
8080
// Swap to ensure that we observe all state changes with acquire
8181
// ordering, even if the state has been changed after the timeout
8282
// occured.
@@ -99,7 +99,7 @@ impl Parker {
9999
// and terminated before this call is made. This call then returns an
100100
// error or wakes up an unrelated thread. The platform API and
101101
// environment does allow this, however.
102-
unpark(tid, self.state.as_mut_ptr().addr());
102+
unpark(tid, self.state.as_ptr().addr());
103103
}
104104
}
105105
}

0 commit comments

Comments
 (0)