@@ -110,6 +110,8 @@ use self::Ordering::*;
110
110
use crate :: cell:: UnsafeCell ;
111
111
use crate :: fmt;
112
112
use crate :: intrinsics;
113
+
114
+ #[ allow( unused_imports) ]
113
115
use crate :: mem:: align_of;
114
116
115
117
use crate :: hint:: spin_loop;
@@ -342,6 +344,7 @@ impl AtomicBool {
342
344
/// assert_eq!(some_bool, false);
343
345
/// ```
344
346
#[ inline]
347
+ #[ cfg( target_has_atomic_equal_alignment = "8" ) ]
345
348
#[ unstable( feature = "atomic_from_mut" , issue = "76314" ) ]
346
349
pub fn from_mut ( v : & mut bool ) -> & Self {
347
350
// SAFETY: the mutable reference guarantees unique ownership, and
@@ -855,6 +858,7 @@ impl<T> AtomicPtr<T> {
855
858
/// assert_eq!(unsafe { *some_ptr }, 456);
856
859
/// ```
857
860
#[ inline]
861
+ #[ cfg( target_has_atomic_equal_alignment = "ptr" ) ]
858
862
#[ unstable( feature = "atomic_from_mut" , issue = "76314" ) ]
859
863
pub fn from_mut ( v : & mut * mut T ) -> & Self {
860
864
let [ ] = [ ( ) ; align_of :: < AtomicPtr < ( ) > > ( ) - align_of :: < * mut ( ) > ( ) ] ;
@@ -1159,6 +1163,7 @@ macro_rules! if_not_8_bit {
1159
1163
#[ cfg( target_has_atomic_load_store = "8" ) ]
1160
1164
macro_rules! atomic_int {
1161
1165
( $cfg_cas: meta,
1166
+ $cfg_align: meta,
1162
1167
$stable: meta,
1163
1168
$stable_cxchg: meta,
1164
1169
$stable_debug: meta,
@@ -1167,7 +1172,6 @@ macro_rules! atomic_int {
1167
1172
$stable_nand: meta,
1168
1173
$const_stable: meta,
1169
1174
$stable_init_const: meta,
1170
- $( from_mut: cfg( $from_mut_cfg: meta) , ) ?
1171
1175
$s_int_type: literal, $int_ref: expr,
1172
1176
$extra_feature: expr,
1173
1177
$min_fn: ident, $max_fn: ident,
@@ -1304,15 +1308,14 @@ assert_eq!(some_int, 100);
1304
1308
```
1305
1309
" ) ,
1306
1310
#[ inline]
1307
- $ ( # [ cfg ( $from_mut_cfg ) ] ) ?
1311
+ # [ $cfg_align ]
1308
1312
#[ unstable( feature = "atomic_from_mut" , issue = "76314" ) ]
1309
1313
pub fn from_mut( v: & mut $int_type) -> & Self {
1310
1314
let [ ] = [ ( ) ; align_of:: <Self >( ) - align_of:: <$int_type>( ) ] ;
1311
1315
// SAFETY:
1312
1316
// - the mutable reference guarantees unique ownership.
1313
1317
// - the alignment of `$int_type` and `Self` is the
1314
- // same on all platforms enabled by `$from_mut_cfg`
1315
- // as verified above.
1318
+ // same, as promised by $cfg_align and verified above.
1316
1319
unsafe { & * ( v as * mut $int_type as * mut Self ) }
1317
1320
}
1318
1321
}
@@ -1959,6 +1962,7 @@ let mut atomic = ", stringify!($atomic_type), "::new(1);
1959
1962
#[ cfg( target_has_atomic_load_store = "8" ) ]
1960
1963
atomic_int ! {
1961
1964
cfg( target_has_atomic = "8" ) ,
1965
+ cfg( target_has_atomic_equal_alignment = "8" ) ,
1962
1966
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
1963
1967
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
1964
1968
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -1977,6 +1981,7 @@ atomic_int! {
1977
1981
#[ cfg( target_has_atomic_load_store = "8" ) ]
1978
1982
atomic_int ! {
1979
1983
cfg( target_has_atomic = "8" ) ,
1984
+ cfg( target_has_atomic_equal_alignment = "8" ) ,
1980
1985
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
1981
1986
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
1982
1987
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -1995,6 +2000,7 @@ atomic_int! {
1995
2000
#[ cfg( target_has_atomic_load_store = "16" ) ]
1996
2001
atomic_int ! {
1997
2002
cfg( target_has_atomic = "16" ) ,
2003
+ cfg( target_has_atomic_equal_alignment = "16" ) ,
1998
2004
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
1999
2005
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2000
2006
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -2013,6 +2019,7 @@ atomic_int! {
2013
2019
#[ cfg( target_has_atomic_load_store = "16" ) ]
2014
2020
atomic_int ! {
2015
2021
cfg( target_has_atomic = "16" ) ,
2022
+ cfg( target_has_atomic_equal_alignment = "16" ) ,
2016
2023
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2017
2024
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2018
2025
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -2031,6 +2038,7 @@ atomic_int! {
2031
2038
#[ cfg( target_has_atomic_load_store = "32" ) ]
2032
2039
atomic_int ! {
2033
2040
cfg( target_has_atomic = "32" ) ,
2041
+ cfg( target_has_atomic_equal_alignment = "32" ) ,
2034
2042
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2035
2043
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2036
2044
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -2049,6 +2057,7 @@ atomic_int! {
2049
2057
#[ cfg( target_has_atomic_load_store = "32" ) ]
2050
2058
atomic_int ! {
2051
2059
cfg( target_has_atomic = "32" ) ,
2060
+ cfg( target_has_atomic_equal_alignment = "32" ) ,
2052
2061
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2053
2062
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2054
2063
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -2067,6 +2076,7 @@ atomic_int! {
2067
2076
#[ cfg( target_has_atomic_load_store = "64" ) ]
2068
2077
atomic_int ! {
2069
2078
cfg( target_has_atomic = "64" ) ,
2079
+ cfg( target_has_atomic_equal_alignment = "64" ) ,
2070
2080
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2071
2081
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2072
2082
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -2075,7 +2085,6 @@ atomic_int! {
2075
2085
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2076
2086
rustc_const_stable( feature = "const_integer_atomics" , since = "1.34.0" ) ,
2077
2087
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2078
- from_mut: cfg( not( target_arch = "x86" ) ) ,
2079
2088
"i64" , "../../../std/primitive.i64.html" ,
2080
2089
"" ,
2081
2090
atomic_min, atomic_max,
@@ -2086,6 +2095,7 @@ atomic_int! {
2086
2095
#[ cfg( target_has_atomic_load_store = "64" ) ]
2087
2096
atomic_int ! {
2088
2097
cfg( target_has_atomic = "64" ) ,
2098
+ cfg( target_has_atomic_equal_alignment = "64" ) ,
2089
2099
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2090
2100
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2091
2101
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
@@ -2094,7 +2104,6 @@ atomic_int! {
2094
2104
stable( feature = "integer_atomics_stable" , since = "1.34.0" ) ,
2095
2105
rustc_const_stable( feature = "const_integer_atomics" , since = "1.34.0" ) ,
2096
2106
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2097
- from_mut: cfg( not( target_arch = "x86" ) ) ,
2098
2107
"u64" , "../../../std/primitive.u64.html" ,
2099
2108
"" ,
2100
2109
atomic_umin, atomic_umax,
@@ -2105,6 +2114,7 @@ atomic_int! {
2105
2114
#[ cfg( target_has_atomic_load_store = "128" ) ]
2106
2115
atomic_int ! {
2107
2116
cfg( target_has_atomic = "128" ) ,
2117
+ cfg( target_has_atomic_equal_alignment = "128" ) ,
2108
2118
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2109
2119
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2110
2120
unstable( feature = "integer_atomics" , issue = "32976" ) ,
@@ -2113,7 +2123,6 @@ atomic_int! {
2113
2123
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2114
2124
rustc_const_stable( feature = "const_integer_atomics" , since = "1.34.0" ) ,
2115
2125
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2116
- from_mut: cfg( not( target_arch = "x86_64" ) ) ,
2117
2126
"i128" , "../../../std/primitive.i128.html" ,
2118
2127
"#![feature(integer_atomics)]\n \n " ,
2119
2128
atomic_min, atomic_max,
@@ -2124,6 +2133,7 @@ atomic_int! {
2124
2133
#[ cfg( target_has_atomic_load_store = "128" ) ]
2125
2134
atomic_int ! {
2126
2135
cfg( target_has_atomic = "128" ) ,
2136
+ cfg( target_has_atomic_equal_alignment = "128" ) ,
2127
2137
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2128
2138
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2129
2139
unstable( feature = "integer_atomics" , issue = "32976" ) ,
@@ -2132,7 +2142,6 @@ atomic_int! {
2132
2142
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2133
2143
rustc_const_stable( feature = "const_integer_atomics" , since = "1.34.0" ) ,
2134
2144
unstable( feature = "integer_atomics" , issue = "32976" ) ,
2135
- from_mut: cfg( not( target_arch = "x86_64" ) ) ,
2136
2145
"u128" , "../../../std/primitive.u128.html" ,
2137
2146
"#![feature(integer_atomics)]\n \n " ,
2138
2147
atomic_umin, atomic_umax,
@@ -2164,6 +2173,7 @@ macro_rules! ptr_width {
2164
2173
#[ cfg( target_has_atomic_load_store = "ptr" ) ]
2165
2174
atomic_int ! {
2166
2175
cfg( target_has_atomic = "ptr" ) ,
2176
+ cfg( target_has_atomic_equal_alignment = "ptr" ) ,
2167
2177
stable( feature = "rust1" , since = "1.0.0" ) ,
2168
2178
stable( feature = "extended_compare_and_swap" , since = "1.10.0" ) ,
2169
2179
stable( feature = "atomic_debug" , since = "1.3.0" ) ,
@@ -2182,6 +2192,7 @@ atomic_int! {
2182
2192
#[ cfg( target_has_atomic_load_store = "ptr" ) ]
2183
2193
atomic_int ! {
2184
2194
cfg( target_has_atomic = "ptr" ) ,
2195
+ cfg( target_has_atomic_equal_alignment = "ptr" ) ,
2185
2196
stable( feature = "rust1" , since = "1.0.0" ) ,
2186
2197
stable( feature = "extended_compare_and_swap" , since = "1.10.0" ) ,
2187
2198
stable( feature = "atomic_debug" , since = "1.3.0" ) ,
0 commit comments