https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109166
--- Comment #5 from Jan Dubiec <jdx at o2 dot pl> --- I read that thread a few days ago and I understand concerns regarding SWP, in particular on ARMv6 which has made SWP obsolete (AFAIR it is optional on ARMv6-A/R, ARMv6-M has neither SWP nor LDREX/STREX). However I have never heard of an ARMv4T based MCU which does not have SWP. So I do not understand why gcc targeting various "bare metal" ARMs for ARMv4T a) emits non-atomic __atomic_test_and_set, b) does not use SWP in that code. Especially that the code attached to the linked message for ARMv4T uses SWP.