There's some material online about how to write 64 bit atomic code, for example:
How to guarantee 64-bit writes are atomic?
.. but before I go down that road, I'd prefer to use an Android NDK / ARM specific solution if there is one.
I'm porting a C++ engine which needs 32 and 64 bit atomic operations. I researched and implemented the GCC built-in __sync_* functions, but when it came time to link I got these kind of errors for the 64 bit operations:
error: undefined reference to '__sync_fetch_and_or_8'
error: undefined reference to '__sync_lock_test_and_set_8'
error: undefined reference to '__sync_fetch_and_and_8'
error: undefined reference to '__sync_fetch_and_add_8'
error: undefined reference to '__sync_val_compare_and_swap_8'
I'm targetting armeabi-v7a, which I've read has some assembly instructions for 64 bit atomic (ldrexd/strexd), so is there a way to access them via the GCC built-in atomics? If not, what are the other options?
Thanks!
Since my question, NDK r8d was released which supports built-in 64-bit atomics.
http://developer.android.com/tools/sdk/ndk/index.html
Backported 64-bit built-in atomic functions for ARM to GCC 4.6.