3
When programming in C/C++ on the x86 and x86-64 (AMD64) architecture and using the Microsoft compiler that comes with Visual Studio, there are two intrinsic functions to perform atomic operations, _InterlockedCompareExchange32
and _InterlockedIncrement32
, which are implemented through the Assembly instructions lock cmpxchg
and lock xadd
, respectively.
Looking at the documentation in the MSDN section ARM Intrinsics, I read that the Microsoft compiler also has these two intrinsic functions for the ARM architecture.
Obviously these functions in the ARM architecture will not be replaced by the Assembly instructions lock cmpxchg
and lock xadd
, since she has no such instructions.
How to implement the functions _InterlockedCompareExchange32
and _InterlockedIncrement32
(can be in C or Assembly), so that it is compileable by ARM compiler that comes with Android NDK?