https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63368
--- Comment #7 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> --- For anyone reading this. the comment "-latomic is there already." means: replace __sync_val_compare_and_swap(ptr, oldval, newval) in your code with __atomic_compare_exchange(ptr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) then link with -latomic