@@ -2,7 +2,7 @@ use super::*;
2
2
use crate :: cmp:: Ordering :: { Equal , Greater , Less } ;
3
3
use crate :: intrinsics:: const_eval_select;
4
4
use crate :: marker:: PointeeSized ;
5
- use crate :: mem:: { self , SizedTypeProperties } ;
5
+ use crate :: mem:: SizedTypeProperties ;
6
6
use crate :: slice:: { self , SliceIndex } ;
7
7
8
8
impl < T : PointeeSized > * mut T {
@@ -160,12 +160,20 @@ impl<T: PointeeSized> *mut T {
160
160
#[ inline( always) ]
161
161
#[ stable( feature = "strict_provenance" , since = "1.84.0" ) ]
162
162
pub fn addr ( self ) -> usize {
163
- // A pointer-to-integer transmute currently has exactly the right semantics: it returns the
164
- // address without exposing the provenance. Note that this is *not* a stable guarantee about
165
- // transmute semantics, it relies on sysroot crates having special status.
166
- // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
167
- // provenance).
168
- unsafe { mem:: transmute ( self . cast :: < ( ) > ( ) ) }
163
+ #[ cfg( target_family = "cheri" ) ]
164
+ {
165
+ crate :: intrinsics:: cheri:: cheri_address_get ( self . cast :: < ( ) > ( ) )
166
+ }
167
+
168
+ #[ cfg( not( target_family = "cheri" ) ) ]
169
+ {
170
+ // A pointer-to-integer transmute currently has exactly the right semantics: it returns the
171
+ // address without exposing the provenance. Note that this is *not* a stable guarantee about
172
+ // transmute semantics, it relies on sysroot crates having special status.
173
+ // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the
174
+ // provenance).
175
+ unsafe { crate :: mem:: transmute ( self . cast :: < ( ) > ( ) ) }
176
+ }
169
177
}
170
178
171
179
/// Exposes the ["provenance"][crate::ptr#provenance] part of the pointer for future use in
0 commit comments