Skip to content

Commit 622ea62

Browse files
authored
chore: use stabilized AtomicXXX::from_ptr() (#1738)
# What does this PR do? This PR replaces a raw cast to `AtomicUsize` to a call to `Atomic::from_ptr`, which is the official solution for this use-case (have an atomic view of a raw pointer) # Motivation Came to this line looking at something else. The comment mentions `from_ptr()` is unstable, which isn't anymore (since Rust 1.75). So let's pay the technical debt (one nickel at a time!). # Additional Notes N/A # How to test the change? N/A Co-authored-by: yann.hamdaoui <yann.hamdaoui@datadoghq.com>
1 parent 6a02f01 commit 622ea62

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

datadog-ipc/src/platform/unix/mem_handle_macos.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ impl<T: FileBackedHandle + From<MappedMem<T>>> MappedMem<T> {
163163
(MAPPING_MAX_SIZE - usize::from(page_size)) as off_t,
164164
)
165165
.unwrap();
166-
// AtomicUsize::from_ptr() is still unstable
167-
let size = ptr.cast::<AtomicUsize>().as_ref();
166+
let size = AtomicUsize::from_ptr(ptr.cast::<usize>().as_ptr());
168167
size.fetch_max(handle.get_size(), Ordering::SeqCst);
169168
_ = munmap(ptr, usize::from(page_size));
170169
}

0 commit comments

Comments
 (0)