Atomic operations
The standard C and C++ atomic operations are available in the files stdatomic.h and atomic. If atomic operations are not available, the predefined preprocessor symbol __STDC_NO_ATOMICS__ is defined to 1. This is true both in C and C++.
Atomic operations are either supported by hardware—if the RISC-V extension A is available—or by software.
For devices with hardware support for atomic operations, the primitive type atomic_flag and 32-bit types are lock-free. Other types are implemented using locks. For devices without hardware support for atomic operations, all atomic operations are guarded by locks. The locks are implemented using two functions (that you can override):
unsigned int __iar_atomic_acquire_lock(void volatile*addr); __iar_atomic_release_lock(unsigned intacq_token);
For devices that support the A extension, the default lock implementation is based on spin locks. For devices without support for the A extension, the locks enable and disable interrupts.