@@ -124,6 +124,7 @@ pub fn spin_loop_hint() {
124124/// [`bool`]: ../../../std/primitive.bool.html
125125#[ cfg( target_has_atomic = "8" ) ]
126126#[ stable( feature = "rust1" , since = "1.0.0" ) ]
127+ #[ repr( C , align( 1 ) ) ]
127128pub struct AtomicBool {
128129 v : UnsafeCell < u8 > ,
129130}
@@ -147,6 +148,9 @@ unsafe impl Sync for AtomicBool {}
147148/// This type has the same in-memory representation as a `*mut T`.
148149#[ cfg( target_has_atomic = "ptr" ) ]
149150#[ 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 ) ) ) ]
150154pub struct AtomicPtr < T > {
151155 p : UnsafeCell < * mut T > ,
152156}
@@ -1088,6 +1092,7 @@ macro_rules! atomic_int {
10881092 $s_int_type: expr, $int_ref: expr,
10891093 $extra_feature: expr,
10901094 $min_fn: ident, $max_fn: ident,
1095+ $align: expr,
10911096 $int_type: ident $atomic_type: ident $atomic_init: ident) => {
10921097 /// An integer type which can be safely shared between threads.
10931098 ///
@@ -1101,6 +1106,7 @@ macro_rules! atomic_int {
11011106 ///
11021107 /// [module-level documentation]: index.html
11031108 #[ $stable]
1109+ #[ repr( C , align( $align) ) ]
11041110 pub struct $atomic_type {
11051111 v: UnsafeCell <$int_type>,
11061112 }
@@ -1831,6 +1837,7 @@ atomic_int! {
18311837 "i8" , "../../../std/primitive.i8.html" ,
18321838 "#![feature(integer_atomics)]\n \n " ,
18331839 atomic_min, atomic_max,
1840+ 1 ,
18341841 i8 AtomicI8 ATOMIC_I8_INIT
18351842}
18361843#[ cfg( target_has_atomic = "8" ) ]
@@ -1844,6 +1851,7 @@ atomic_int! {
18441851 "u8" , "../../../std/primitive.u8.html" ,
18451852 "#![feature(integer_atomics)]\n \n " ,
18461853 atomic_umin, atomic_umax,
1854+ 1 ,
18471855 u8 AtomicU8 ATOMIC_U8_INIT
18481856}
18491857#[ cfg( target_has_atomic = "16" ) ]
@@ -1857,6 +1865,7 @@ atomic_int! {
18571865 "i16" , "../../../std/primitive.i16.html" ,
18581866 "#![feature(integer_atomics)]\n \n " ,
18591867 atomic_min, atomic_max,
1868+ 2 ,
18601869 i16 AtomicI16 ATOMIC_I16_INIT
18611870}
18621871#[ cfg( target_has_atomic = "16" ) ]
@@ -1870,6 +1879,7 @@ atomic_int! {
18701879 "u16" , "../../../std/primitive.u16.html" ,
18711880 "#![feature(integer_atomics)]\n \n " ,
18721881 atomic_umin, atomic_umax,
1882+ 2 ,
18731883 u16 AtomicU16 ATOMIC_U16_INIT
18741884}
18751885#[ cfg( target_has_atomic = "32" ) ]
@@ -1883,6 +1893,7 @@ atomic_int! {
18831893 "i32" , "../../../std/primitive.i32.html" ,
18841894 "#![feature(integer_atomics)]\n \n " ,
18851895 atomic_min, atomic_max,
1896+ 4 ,
18861897 i32 AtomicI32 ATOMIC_I32_INIT
18871898}
18881899#[ cfg( target_has_atomic = "32" ) ]
@@ -1896,6 +1907,7 @@ atomic_int! {
18961907 "u32" , "../../../std/primitive.u32.html" ,
18971908 "#![feature(integer_atomics)]\n \n " ,
18981909 atomic_umin, atomic_umax,
1910+ 4 ,
18991911 u32 AtomicU32 ATOMIC_U32_INIT
19001912}
19011913#[ cfg( target_has_atomic = "64" ) ]
@@ -1909,6 +1921,7 @@ atomic_int! {
19091921 "i64" , "../../../std/primitive.i64.html" ,
19101922 "#![feature(integer_atomics)]\n \n " ,
19111923 atomic_min, atomic_max,
1924+ 8 ,
19121925 i64 AtomicI64 ATOMIC_I64_INIT
19131926}
19141927#[ cfg( target_has_atomic = "64" ) ]
@@ -1922,8 +1935,49 @@ atomic_int! {
19221935 "u64" , "../../../std/primitive.u64.html" ,
19231936 "#![feature(integer_atomics)]\n \n " ,
19241937 atomic_umin, atomic_umax,
1938+ 8 ,
19251939 u64 AtomicU64 ATOMIC_U64_INIT
19261940}
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+ }
19271981#[ cfg( target_has_atomic = "ptr" ) ]
19281982atomic_int ! {
19291983 stable( feature = "rust1" , since = "1.0.0" ) ,
@@ -1935,6 +1989,7 @@ atomic_int!{
19351989 "isize" , "../../../std/primitive.isize.html" ,
19361990 "" ,
19371991 atomic_min, atomic_max,
1992+ ptr_width!( ) ,
19381993 isize AtomicIsize ATOMIC_ISIZE_INIT
19391994}
19401995#[ cfg( target_has_atomic = "ptr" ) ]
@@ -1948,6 +2003,7 @@ atomic_int!{
19482003 "usize" , "../../../std/primitive.usize.html" ,
19492004 "" ,
19502005 atomic_umin, atomic_umax,
2006+ ptr_width!( ) ,
19512007 usize AtomicUsize ATOMIC_USIZE_INIT
19522008}
19532009
0 commit comments