[Gc] sync_val_compare_and_swap equivalent in libatomic_ops

Ivan Maidanski ivmai at mail.ru
Wed Nov 16 09:07:04 PST 2011

Hi all,

I've added CAS primitive which returns old value instead of comparison result (the similar primitives in GCC are __sync_val_compare_and_swap and __sync_bool_compare_and_swap, respectively). I've named the primitive as AO_fetch_compare_and_swap.

I've added implementations for emulations, x86, x64, arm v6, Hexagon (not tested), ia64 (trivial but not tested), ppc (not tested) targets.
Meanwhile, alpha, avr, m68k, mips, s390, sparc lack such CAS primitive for now (unless via emulation) - I'm unable to do this without help from the community.

For some targets (e.g., ia64), old bool CAS primitives containing "return oldval_fetched == oldval_expected" statement are completely removed from "sysdeps" part as they are implemented in generalize.h (and generalize-small.h).

The functionality is available in ao_val_cas branch for testing period.
For implementation details, see the differences from master branch - https://github.com/ivmai/libatomic_ops/compare/master...ao_val_cas

Tests for new CAS has been added, so please everyone is welcomed to participate in testing:

git clone git://github.com/ivmai/libatomic_ops.git -b ao_val_cas
cd libatomic_ops
autoreconf -vif
make check


More information about the Gc mailing list