Native Android, Interlocked/Atomic operations

Issue

Interlocked/Atomic operations are CPU specific.

Is there any common baseline requirement by all Android supporting hardware as far as for interlocked operations?

Are there any interlocked operations supported by all Android devices?

Is there any Android equivalent to Windows’ InterlockedExchange?

Any help will be appreciated.

Solution

You can use __atomic_swap for InterlockedExchange functionality.

Read docs/ANDROID-ATOMICS.html file from NDK distribution for more info.

Answered By – Mārtiņš Možeiko

Leave a Comment