@@ -124,6 +124,7 @@ pub fn spin_loop_hint() {
124
124
/// [`bool`]: ../../../std/primitive.bool.html
125
125
#[ cfg( target_has_atomic = "8" ) ]
126
126
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
127
+ #[ repr( C , align( 1 ) ) ]
127
128
pub struct AtomicBool {
128
129
v : UnsafeCell < u8 > ,
129
130
}
@@ -147,6 +148,9 @@ unsafe impl Sync for AtomicBool {}
147
148
/// This type has the same in-memory representation as a `*mut T`.
148
149
#[ cfg( target_has_atomic = "ptr" ) ]
149
150
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
151
+ #[ cfg_attr( target_pointer_width = "16" , repr( C , align( 2 ) ) ) ]
152
+ #[ cfg_attr( target_pointer_width = "32" , repr( C , align( 4 ) ) ) ]
153
+ #[ cfg_attr( target_pointer_width = "64" , repr( C , align( 8 ) ) ) ]
150
154
pub struct AtomicPtr < T > {
151
155
p : UnsafeCell < * mut T > ,
152
156
}
@@ -1088,6 +1092,7 @@ macro_rules! atomic_int {
1088
1092
$s_int_type: expr, $int_ref: expr,
1089
1093
$extra_feature: expr,
1090
1094
$min_fn: ident, $max_fn: ident,
1095
+ $align: expr,
1091
1096
$int_type: ident $atomic_type: ident $atomic_init: ident) => {
1092
1097
/// An integer type which can be safely shared between threads.
1093
1098
///
@@ -1101,6 +1106,7 @@ macro_rules! atomic_int {
1101
1106
///
1102
1107
/// [module-level documentation]: index.html
1103
1108
#[ $stable]
1109
+ #[ repr( C , align( $align) ) ]
1104
1110
pub struct $atomic_type {
1105
1111
v: UnsafeCell <$int_type>,
1106
1112
}
@@ -1831,6 +1837,7 @@ atomic_int! {
1831
1837
"i8" , "../../../std/primitive.i8.html" ,
1832
1838
"#![feature(integer_atomics)]\n \n " ,
1833
1839
atomic_min, atomic_max,
1840
+ 1 ,
1834
1841
i8 AtomicI8 ATOMIC_I8_INIT
1835
1842
}
1836
1843
#[ cfg( target_has_atomic = "8" ) ]
@@ -1844,6 +1851,7 @@ atomic_int! {
1844
1851
"u8" , "../../../std/primitive.u8.html" ,
1845
1852
"#![feature(integer_atomics)]\n \n " ,
1846
1853
atomic_umin, atomic_umax,
1854
+ 1 ,
1847
1855
u8 AtomicU8 ATOMIC_U8_INIT
1848
1856
}
1849
1857
#[ cfg( target_has_atomic = "16" ) ]
@@ -1857,6 +1865,7 @@ atomic_int! {
1857
1865
"i16" , "../../../std/primitive.i16.html" ,
1858
1866
"#![feature(integer_atomics)]\n \n " ,
1859
1867
atomic_min, atomic_max,
1868
+ 2 ,
1860
1869
i16 AtomicI16 ATOMIC_I16_INIT
1861
1870
}
1862
1871
#[ cfg( target_has_atomic = "16" ) ]
@@ -1870,6 +1879,7 @@ atomic_int! {
1870
1879
"u16" , "../../../std/primitive.u16.html" ,
1871
1880
"#![feature(integer_atomics)]\n \n " ,
1872
1881
atomic_umin, atomic_umax,
1882
+ 2 ,
1873
1883
u16 AtomicU16 ATOMIC_U16_INIT
1874
1884
}
1875
1885
#[ cfg( target_has_atomic = "32" ) ]
@@ -1883,6 +1893,7 @@ atomic_int! {
1883
1893
"i32" , "../../../std/primitive.i32.html" ,
1884
1894
"#![feature(integer_atomics)]\n \n " ,
1885
1895
atomic_min, atomic_max,
1896
+ 4 ,
1886
1897
i32 AtomicI32 ATOMIC_I32_INIT
1887
1898
}
1888
1899
#[ cfg( target_has_atomic = "32" ) ]
@@ -1896,6 +1907,7 @@ atomic_int! {
1896
1907
"u32" , "../../../std/primitive.u32.html" ,
1897
1908
"#![feature(integer_atomics)]\n \n " ,
1898
1909
atomic_umin, atomic_umax,
1910
+ 4 ,
1899
1911
u32 AtomicU32 ATOMIC_U32_INIT
1900
1912
}
1901
1913
#[ cfg( target_has_atomic = "64" ) ]
@@ -1909,6 +1921,7 @@ atomic_int! {
1909
1921
"i64" , "../../../std/primitive.i64.html" ,
1910
1922
"#![feature(integer_atomics)]\n \n " ,
1911
1923
atomic_min, atomic_max,
1924
+ 8 ,
1912
1925
i64 AtomicI64 ATOMIC_I64_INIT
1913
1926
}
1914
1927
#[ cfg( target_has_atomic = "64" ) ]
@@ -1922,8 +1935,49 @@ atomic_int! {
1922
1935
"u64" , "../../../std/primitive.u64.html" ,
1923
1936
"#![feature(integer_atomics)]\n \n " ,
1924
1937
atomic_umin, atomic_umax,
1938
+ 8 ,
1925
1939
u64 AtomicU64 ATOMIC_U64_INIT
1926
1940
}
1941
+ #[ cfg( all( not( stage0) , target_has_atomic = "128" ) ) ]
1942
+ atomic_int ! {
1943
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1944
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1945
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1946
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1947
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1948
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1949
+ "i128" , "../../../std/primitive.i128.html" ,
1950
+ "#![feature(integer_atomics)]\n \n " ,
1951
+ atomic_min, atomic_max,
1952
+ 16 ,
1953
+ i128 AtomicI128 ATOMIC_I128_INIT
1954
+ }
1955
+ #[ cfg( all( not( stage0) , target_has_atomic = "128" ) ) ]
1956
+ atomic_int ! {
1957
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1958
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1959
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1960
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1961
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1962
+ unstable( feature = "integer_atomics" , issue = "32976" ) ,
1963
+ "u128" , "../../../std/primitive.u128.html" ,
1964
+ "#![feature(integer_atomics)]\n \n " ,
1965
+ atomic_umin, atomic_umax,
1966
+ 16 ,
1967
+ u128 AtomicU128 ATOMIC_U128_INIT
1968
+ }
1969
+ #[ cfg( target_pointer_width = "16" ) ]
1970
+ macro_rules! ptr_width {
1971
+ ( ) => { 2 }
1972
+ }
1973
+ #[ cfg( target_pointer_width = "32" ) ]
1974
+ macro_rules! ptr_width {
1975
+ ( ) => { 4 }
1976
+ }
1977
+ #[ cfg( target_pointer_width = "64" ) ]
1978
+ macro_rules! ptr_width {
1979
+ ( ) => { 8 }
1980
+ }
1927
1981
#[ cfg( target_has_atomic = "ptr" ) ]
1928
1982
atomic_int ! {
1929
1983
stable( feature = "rust1" , since = "1.0.0" ) ,
@@ -1935,6 +1989,7 @@ atomic_int!{
1935
1989
"isize" , "../../../std/primitive.isize.html" ,
1936
1990
"" ,
1937
1991
atomic_min, atomic_max,
1992
+ ptr_width!( ) ,
1938
1993
isize AtomicIsize ATOMIC_ISIZE_INIT
1939
1994
}
1940
1995
#[ cfg( target_has_atomic = "ptr" ) ]
@@ -1948,6 +2003,7 @@ atomic_int!{
1948
2003
"usize" , "../../../std/primitive.usize.html" ,
1949
2004
"" ,
1950
2005
atomic_umin, atomic_umax,
2006
+ ptr_width!( ) ,
1951
2007
usize AtomicUsize ATOMIC_USIZE_INIT
1952
2008
}
1953
2009
0 commit comments