Skip to content

Commit

Permalink
Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=Amanieu
Browse files Browse the repository at this point in the history
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance

As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066).

The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".)

The new name nicely matches `ptr::without_provenance`.
  • Loading branch information
jhpratt authored Apr 3, 2024
2 parents 61daba9 + c7a9561 commit 93d3300
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions crates/core_simd/src/simd/ptr/const_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ pub trait SimdConstPtr: Copy + Sealed {
fn with_addr(self, addr: Self::Usize) -> Self;

/// Gets the "address" portion of the pointer, and "exposes" the provenance part for future use
/// in [`Self::from_exposed_addr`].
/// in [`Self::with_exposed_provenance`].
fn expose_addr(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::from_exposed_addr`] on each element.
fn from_exposed_addr(addr: Self::Usize) -> Self;
/// Equivalent to calling [`core::ptr::with_exposed_provenance`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;

/// Calculates the offset from a pointer using wrapping arithmetic.
///
Expand Down Expand Up @@ -137,9 +137,9 @@ where
}

#[inline]
fn from_exposed_addr(addr: Self::Usize) -> Self {
fn with_exposed_provenance(addr: Self::Usize) -> Self {
// Safety: `self` is a pointer vector
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
unsafe { core::intrinsics::simd::simd_with_exposed_provenance(addr) }
}

#[inline]
Expand Down
10 changes: 5 additions & 5 deletions crates/core_simd/src/simd/ptr/mut_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ pub trait SimdMutPtr: Copy + Sealed {
fn with_addr(self, addr: Self::Usize) -> Self;

/// Gets the "address" portion of the pointer, and "exposes" the provenance part for future use
/// in [`Self::from_exposed_addr`].
/// in [`Self::with_exposed_provenance`].
fn expose_addr(self) -> Self::Usize;

/// Convert an address back to a pointer, picking up a previously "exposed" provenance.
///
/// Equivalent to calling [`core::ptr::from_exposed_addr_mut`] on each element.
fn from_exposed_addr(addr: Self::Usize) -> Self;
/// Equivalent to calling [`core::ptr::with_exposed_provenance_mut`] on each element.
fn with_exposed_provenance(addr: Self::Usize) -> Self;

/// Calculates the offset from a pointer using wrapping arithmetic.
///
Expand Down Expand Up @@ -134,9 +134,9 @@ where
}

#[inline]
fn from_exposed_addr(addr: Self::Usize) -> Self {
fn with_exposed_provenance(addr: Self::Usize) -> Self {
// Safety: `self` is a pointer vector
unsafe { core::intrinsics::simd::simd_from_exposed_addr(addr) }
unsafe { core::intrinsics::simd::simd_with_exposed_provenance(addr) }
}

#[inline]
Expand Down
12 changes: 6 additions & 6 deletions crates/core_simd/tests/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ mod const_ptr {
);
}

fn from_exposed_addr<const LANES: usize>() {
fn with_exposed_provenance<const LANES: usize>() {
test_helpers::test_unary_elementwise(
&Simd::<*const u32, LANES>::from_exposed_addr,
&core::ptr::from_exposed_addr::<u32>,
&Simd::<*const u32, LANES>::with_exposed_provenance,
&core::ptr::with_exposed_provenance::<u32>,
&|_| true,
);
}
Expand All @@ -103,10 +103,10 @@ mod mut_ptr {
);
}

fn from_exposed_addr<const LANES: usize>() {
fn with_exposed_provenance<const LANES: usize>() {
test_helpers::test_unary_elementwise(
&Simd::<*mut u32, LANES>::from_exposed_addr,
&core::ptr::from_exposed_addr_mut::<u32>,
&Simd::<*mut u32, LANES>::with_exposed_provenance,
&core::ptr::with_exposed_provenance_mut::<u32>,
&|_| true,
);
}
Expand Down

0 comments on commit 93d3300

Please sign in to comment.