22// Lock-free implementations
33
44// cfg(target_has_atomic_load_store = "ptr")
5- #[ cfg( not( portable_atomic_no_atomic_load_store) ) ]
5+ #[ cfg( not( any(
6+ portable_atomic_no_atomic_load_store,
7+ portable_atomic_unsafe_assume_single_core,
8+ target_arch = "avr" ,
9+ target_arch = "msp430" ,
10+ ) ) ) ]
611#[ cfg_attr(
712 not( portable_atomic_no_cfg_target_has_atomic) ,
813 cfg( not( all(
914 any( target_arch = "riscv32" , target_arch = "riscv64" ) ,
1015 not( target_has_atomic = "ptr" )
1116 ) ) )
1217) ]
13- #[ cfg( any( test, not( portable_atomic_unsafe_assume_single_core) ) ) ]
1418mod core_atomic;
1519
1620// Miri and Sanitizer do not support inline assembly.
@@ -137,38 +141,27 @@ pub(crate) mod float;
137141// -----------------------------------------------------------------------------
138142
139143// Atomic{Isize,Usize,Bool,Ptr}, Atomic{I,U}{8,16}
140- #[ cfg_attr(
141- portable_atomic_no_cfg_target_has_atomic,
142- cfg( any(
143- not( portable_atomic_no_atomic_cas) ,
144- all(
145- not( portable_atomic_no_atomic_load_store) ,
146- not( portable_atomic_unsafe_assume_single_core)
147- )
148- ) )
149- ) ]
144+ #[ cfg( not( any(
145+ portable_atomic_no_atomic_load_store,
146+ portable_atomic_unsafe_assume_single_core,
147+ target_arch = "avr" ,
148+ target_arch = "msp430" ,
149+ ) ) ) ]
150150#[ cfg_attr(
151151 not( portable_atomic_no_cfg_target_has_atomic) ,
152- cfg( any(
153- target_has_atomic = "ptr" ,
154- all(
155- not( portable_atomic_no_atomic_load_store) ,
156- not( portable_atomic_unsafe_assume_single_core) ,
157- not( all(
158- any( target_arch = "riscv32" , target_arch = "riscv64" ) ,
159- not( target_has_atomic = "ptr" )
160- ) )
161- )
162- ) )
152+ cfg( not( all(
153+ any( target_arch = "riscv32" , target_arch = "riscv64" ) ,
154+ not( target_has_atomic = "ptr" )
155+ ) ) )
163156) ]
164157pub ( crate ) use self :: core_atomic:: {
165158 AtomicBool , AtomicI16 , AtomicI8 , AtomicIsize , AtomicPtr , AtomicU16 , AtomicU8 , AtomicUsize ,
166159} ;
167160// RISC-V without A-extension
168161#[ cfg( not( portable_atomic_unsafe_assume_single_core) ) ]
169- #[ cfg( any( target_arch = "riscv32" , target_arch = "riscv64" ) ) ]
170162#[ cfg_attr( portable_atomic_no_cfg_target_has_atomic, cfg( portable_atomic_no_atomic_cas) ) ]
171163#[ cfg_attr( not( portable_atomic_no_cfg_target_has_atomic) , cfg( not( target_has_atomic = "ptr" ) ) ) ]
164+ #[ cfg( any( target_arch = "riscv32" , target_arch = "riscv64" ) ) ]
172165pub ( crate ) use self :: riscv:: {
173166 AtomicBool , AtomicI16 , AtomicI8 , AtomicIsize , AtomicPtr , AtomicU16 , AtomicU8 , AtomicUsize ,
174167} ;
@@ -185,37 +178,25 @@ pub(crate) use self::interrupt::{
185178} ;
186179
187180// Atomic{I,U}32
188- #[ cfg( not( target_pointer_width = "16" ) ) ]
189- #[ cfg_attr(
190- portable_atomic_no_cfg_target_has_atomic,
191- cfg( any(
192- not( portable_atomic_no_atomic_cas) ,
193- all(
194- not( portable_atomic_no_atomic_load_store) ,
195- not( portable_atomic_unsafe_assume_single_core)
196- )
197- ) )
198- ) ]
181+ #[ cfg( not( any(
182+ portable_atomic_no_atomic_load_store,
183+ portable_atomic_unsafe_assume_single_core,
184+ target_arch = "avr" ,
185+ target_arch = "msp430" ,
186+ ) ) ) ]
199187#[ cfg_attr(
200188 not( portable_atomic_no_cfg_target_has_atomic) ,
201- cfg( any(
202- target_has_atomic = "ptr" ,
203- all(
204- not( portable_atomic_no_atomic_load_store) ,
205- not( portable_atomic_unsafe_assume_single_core) ,
206- not( all(
207- any( target_arch = "riscv32" , target_arch = "riscv64" ) ,
208- not( target_has_atomic = "ptr" )
209- ) )
210- )
211- ) )
189+ cfg( not( all(
190+ any( target_arch = "riscv32" , target_arch = "riscv64" ) ,
191+ not( target_has_atomic = "ptr" )
192+ ) ) )
212193) ]
213194pub ( crate ) use self :: core_atomic:: { AtomicI32 , AtomicU32 } ;
214195// RISC-V without A-extension
215196#[ cfg( not( portable_atomic_unsafe_assume_single_core) ) ]
216- #[ cfg( any( target_arch = "riscv32" , target_arch = "riscv64" ) ) ]
217197#[ cfg_attr( portable_atomic_no_cfg_target_has_atomic, cfg( portable_atomic_no_atomic_cas) ) ]
218198#[ cfg_attr( not( portable_atomic_no_cfg_target_has_atomic) , cfg( not( target_has_atomic = "ptr" ) ) ) ]
199+ #[ cfg( any( target_arch = "riscv32" , target_arch = "riscv64" ) ) ]
219200pub ( crate ) use self :: riscv:: { AtomicI32 , AtomicU32 } ;
220201// no core Atomic{I,U}32 & no CAS & assume single core => critical section based fallback
221202#[ cfg( any( not( target_pointer_width = "16" ) , feature = "fallback" ) ) ]
@@ -229,15 +210,17 @@ pub(crate) use self::riscv::{AtomicI32, AtomicU32};
229210pub ( crate ) use self :: interrupt:: { AtomicI32 , AtomicU32 } ;
230211
231212// Atomic{I,U}64
213+ #[ cfg( not( any(
214+ portable_atomic_no_atomic_load_store,
215+ portable_atomic_unsafe_assume_single_core,
216+ ) ) ) ]
232217#[ cfg_attr( portable_atomic_no_cfg_target_has_atomic, cfg( not( portable_atomic_no_atomic_64) ) ) ]
233218#[ cfg_attr(
234219 not( portable_atomic_no_cfg_target_has_atomic) ,
235220 cfg( any(
236221 target_has_atomic = "64" ,
237222 all(
238223 not( any( target_pointer_width = "16" , target_pointer_width = "32" ) ) ,
239- not( portable_atomic_no_atomic_load_store) ,
240- not( portable_atomic_unsafe_assume_single_core) ,
241224 not( all(
242225 any( target_arch = "riscv32" , target_arch = "riscv64" ) ,
243226 not( target_has_atomic = "ptr" )
@@ -248,16 +231,20 @@ pub(crate) use self::interrupt::{AtomicI32, AtomicU32};
248231pub ( crate ) use self :: core_atomic:: { AtomicI64 , AtomicU64 } ;
249232// RISC-V without A-extension
250233#[ cfg( not( portable_atomic_unsafe_assume_single_core) ) ]
251- #[ cfg( target_arch = "riscv64" ) ]
252234#[ cfg_attr( portable_atomic_no_cfg_target_has_atomic, cfg( portable_atomic_no_atomic_cas) ) ]
253235#[ cfg_attr( not( portable_atomic_no_cfg_target_has_atomic) , cfg( not( target_has_atomic = "ptr" ) ) ) ]
236+ #[ cfg( target_arch = "riscv64" ) ]
254237pub ( crate ) use self :: riscv:: { AtomicI64 , AtomicU64 } ;
255238// no core Atomic{I,U}64 & has CAS => use lock-base fallback
256239#[ cfg( feature = "fallback" ) ]
257- #[ cfg_attr( portable_atomic_no_cfg_target_has_atomic, cfg( portable_atomic_no_atomic_64) ) ]
258- #[ cfg_attr( not( portable_atomic_no_cfg_target_has_atomic) , cfg( not( target_has_atomic = "64" ) ) ) ]
259- #[ cfg_attr( portable_atomic_no_cfg_target_has_atomic, cfg( not( portable_atomic_no_atomic_cas) ) ) ]
260- #[ cfg_attr( not( portable_atomic_no_cfg_target_has_atomic) , cfg( target_has_atomic = "ptr" ) ) ]
240+ #[ cfg_attr(
241+ portable_atomic_no_cfg_target_has_atomic,
242+ cfg( all( portable_atomic_no_atomic_64, not( portable_atomic_no_atomic_cas) ) )
243+ ) ]
244+ #[ cfg_attr(
245+ not( portable_atomic_no_cfg_target_has_atomic) ,
246+ cfg( all( not( target_has_atomic = "64" ) , target_has_atomic = "ptr" ) )
247+ ) ]
261248pub ( crate ) use self :: fallback:: { AtomicI64 , AtomicU64 } ;
262249// no core Atomic{I,U}64 & no CAS & assume single core => critical section based fallback
263250#[ cfg( any(
0 commit comments