@@ -171,6 +171,8 @@ mod test_detect_auxv;
171171use core:: arch:: asm;
172172use core:: sync:: atomic:: Ordering ;
173173
174+ #[ cfg( portable_atomic_no_strict_provenance) ]
175+ use crate :: utils:: ptr:: PtrExt as _;
174176use crate :: utils:: { Pair , U128 } ;
175177
176178#[ cfg( any(
@@ -645,7 +647,7 @@ cfg_sel!({
645647) ) ]
646648#[ inline]
647649unsafe fn _atomic_load_ldp ( src : * mut u128 , order : Ordering ) -> u128 {
648- debug_assert ! ( src as usize % 16 == 0 ) ;
650+ debug_assert ! ( src. addr ( ) % 16 == 0 ) ;
649651 debug_assert_lse2 ! ( ) ;
650652
651653 // SAFETY: the caller must guarantee that `dst` is valid for reads,
@@ -712,7 +714,7 @@ unsafe fn _atomic_load_ldp(src: *mut u128, order: Ordering) -> u128 {
712714) ) ]
713715#[ inline]
714716unsafe fn _atomic_load_ldiapp ( src : * mut u128 , order : Ordering ) -> u128 {
715- debug_assert ! ( src as usize % 16 == 0 ) ;
717+ debug_assert ! ( src. addr ( ) % 16 == 0 ) ;
716718 debug_assert_lse2 ! ( ) ;
717719 debug_assert_rcpc3 ! ( ) ;
718720
@@ -785,7 +787,7 @@ unsafe fn _atomic_load_ldiapp(src: *mut u128, order: Ordering) -> u128 {
785787#[ cfg( any( target_feature = "lse" , portable_atomic_target_feature = "lse" ) ) ]
786788#[ inline]
787789unsafe fn _atomic_load_casp ( src : * mut u128 , order : Ordering ) -> u128 {
788- debug_assert ! ( src as usize % 16 == 0 ) ;
790+ debug_assert ! ( src. addr ( ) % 16 == 0 ) ;
789791 debug_assert_lse ! ( ) ;
790792
791793 // SAFETY: the caller must uphold the safety contract.
@@ -824,7 +826,7 @@ unsafe fn _atomic_load_casp(src: *mut u128, order: Ordering) -> u128 {
824826) ) ]
825827#[ inline]
826828unsafe fn _atomic_load_ldxp_stxp ( src : * mut u128 , order : Ordering ) -> u128 {
827- debug_assert ! ( src as usize % 16 == 0 ) ;
829+ debug_assert ! ( src. addr ( ) % 16 == 0 ) ;
828830
829831 // SAFETY: the caller must uphold the safety contract.
830832 unsafe {
@@ -1061,7 +1063,7 @@ cfg_sel!({
10611063) ) ]
10621064#[ inline]
10631065unsafe fn _atomic_store_stp ( dst : * mut u128 , val : u128 , order : Ordering ) {
1064- debug_assert ! ( dst as usize % 16 == 0 ) ;
1066+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
10651067 debug_assert_lse2 ! ( ) ;
10661068
10671069 // SAFETY: the caller must guarantee that `dst` is valid for writes,
@@ -1136,7 +1138,7 @@ unsafe fn _atomic_store_stp(dst: *mut u128, val: u128, order: Ordering) {
11361138) ) ]
11371139#[ inline]
11381140unsafe fn _atomic_store_stilp ( dst : * mut u128 , val : u128 , order : Ordering ) {
1139- debug_assert ! ( dst as usize % 16 == 0 ) ;
1141+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
11401142 debug_assert_lse2 ! ( ) ;
11411143 debug_assert_rcpc3 ! ( ) ;
11421144
@@ -1195,7 +1197,7 @@ unsafe fn _atomic_store_stilp(dst: *mut u128, val: u128, order: Ordering) {
11951197) ) ]
11961198#[ inline]
11971199unsafe fn _atomic_store_ldxp_stxp ( dst : * mut u128 , val : u128 , order : Ordering ) {
1198- debug_assert ! ( dst as usize % 16 == 0 ) ;
1200+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
11991201
12001202 // SAFETY: the caller must uphold the safety contract.
12011203 unsafe {
@@ -1430,7 +1432,7 @@ unsafe fn _atomic_compare_exchange_casp(
14301432 success : Ordering ,
14311433 failure : Ordering ,
14321434) -> u128 {
1433- debug_assert ! ( dst as usize % 16 == 0 ) ;
1435+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
14341436 debug_assert_lse ! ( ) ;
14351437 let order = crate :: utils:: upgrade_success_ordering ( success, failure) ;
14361438
@@ -1472,7 +1474,7 @@ unsafe fn _atomic_compare_exchange_ldxp_stxp(
14721474 success : Ordering ,
14731475 failure : Ordering ,
14741476) -> u128 {
1475- debug_assert ! ( dst as usize % 16 == 0 ) ;
1477+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
14761478 let order = crate :: utils:: upgrade_success_ordering ( success, failure) ;
14771479
14781480 // SAFETY: the caller must guarantee that `dst` is valid for both writes and
@@ -1581,7 +1583,7 @@ cfg_sel!({
15811583) ) ]
15821584#[ inline]
15831585unsafe fn _atomic_swap_swpp ( dst : * mut u128 , val : u128 , order : Ordering ) -> u128 {
1584- debug_assert ! ( dst as usize % 16 == 0 ) ;
1586+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
15851587 debug_assert_lse128 ! ( ) ;
15861588
15871589 // SAFETY: the caller must guarantee that `dst` is valid for both writes and
@@ -1632,7 +1634,7 @@ unsafe fn _atomic_swap_swpp(dst: *mut u128, val: u128, order: Ordering) -> u128
16321634#[ cfg( any( target_feature = "lse" , portable_atomic_target_feature = "lse" ) ) ]
16331635#[ inline]
16341636unsafe fn _atomic_swap_casp ( dst : * mut u128 , val : u128 , order : Ordering ) -> u128 {
1635- debug_assert ! ( dst as usize % 16 == 0 ) ;
1637+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
16361638 debug_assert_lse ! ( ) ;
16371639
16381640 // SAFETY: the caller must uphold the safety contract.
@@ -1685,7 +1687,7 @@ unsafe fn _atomic_swap_casp(dst: *mut u128, val: u128, order: Ordering) -> u128
16851687) ) ]
16861688#[ inline]
16871689unsafe fn _atomic_swap_ldxp_stxp ( dst : * mut u128 , val : u128 , order : Ordering ) -> u128 {
1688- debug_assert ! ( dst as usize % 16 == 0 ) ;
1690+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
16891691
16901692 // SAFETY: the caller must uphold the safety contract.
16911693 unsafe {
@@ -1739,7 +1741,7 @@ macro_rules! atomic_rmw_ll_sc_3 {
17391741 ) ) ]
17401742 #[ inline]
17411743 unsafe fn $name( dst: * mut u128 , val: u128 , order: Ordering ) -> u128 {
1742- debug_assert!( dst as usize % 16 == 0 ) ;
1744+ debug_assert!( dst. addr ( ) % 16 == 0 ) ;
17431745 // SAFETY: the caller must uphold the safety contract.
17441746 unsafe {
17451747 let val = U128 { whole: val } ;
@@ -1791,7 +1793,7 @@ macro_rules! atomic_rmw_cas_3 {
17911793 #[ cfg( any( target_feature = "lse" , portable_atomic_target_feature = "lse" ) ) ]
17921794 #[ inline]
17931795 unsafe fn $name( dst: * mut u128 , val: u128 , order: Ordering ) -> u128 {
1794- debug_assert!( dst as usize % 16 == 0 ) ;
1796+ debug_assert!( dst. addr ( ) % 16 == 0 ) ;
17951797 debug_assert_lse!( ) ;
17961798 // SAFETY: the caller must uphold the safety contract.
17971799 // cfg guarantee that the CPU supports FEAT_LSE.
@@ -1863,7 +1865,7 @@ macro_rules! atomic_rmw_ll_sc_2 {
18631865 ) ) ]
18641866 #[ inline]
18651867 unsafe fn $name( dst: * mut u128 , order: Ordering ) -> u128 {
1866- debug_assert!( dst as usize % 16 == 0 ) ;
1868+ debug_assert!( dst. addr ( ) % 16 == 0 ) ;
18671869 // SAFETY: the caller must uphold the safety contract.
18681870 unsafe {
18691871 let ( mut prev_lo, mut prev_hi) ;
@@ -1911,7 +1913,7 @@ macro_rules! atomic_rmw_cas_2 {
19111913 #[ cfg( any( target_feature = "lse" , portable_atomic_target_feature = "lse" ) ) ]
19121914 #[ inline]
19131915 unsafe fn $name( dst: * mut u128 , order: Ordering ) -> u128 {
1914- debug_assert!( dst as usize % 16 == 0 ) ;
1916+ debug_assert!( dst. addr ( ) % 16 == 0 ) ;
19151917 debug_assert_lse!( ) ;
19161918 // SAFETY: the caller must uphold the safety contract.
19171919 // cfg guarantee that the CPU supports FEAT_LSE.
@@ -1995,7 +1997,7 @@ atomic_rmw_cas_3! {
19951997#[ cfg( any( target_feature = "lse128" , portable_atomic_target_feature = "lse128" ) ) ]
19961998#[ inline]
19971999unsafe fn atomic_and ( dst : * mut u128 , val : u128 , order : Ordering ) -> u128 {
1998- debug_assert ! ( dst as usize % 16 == 0 ) ;
2000+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
19992001
20002002 // SAFETY: the caller must guarantee that `dst` is valid for both writes and
20012003 // reads, 16-byte aligned, that there are no concurrent non-atomic operations,
@@ -2071,7 +2073,7 @@ atomic_rmw_cas_3! {
20712073#[ cfg( any( target_feature = "lse128" , portable_atomic_target_feature = "lse128" ) ) ]
20722074#[ inline]
20732075unsafe fn atomic_or ( dst : * mut u128 , val : u128 , order : Ordering ) -> u128 {
2074- debug_assert ! ( dst as usize % 16 == 0 ) ;
2076+ debug_assert ! ( dst. addr ( ) % 16 == 0 ) ;
20752077
20762078 // SAFETY: the caller must guarantee that `dst` is valid for both writes and
20772079 // reads, 16-byte aligned, that there are no concurrent non-atomic operations,
0 commit comments