atomic: fix compilation and make use of gcc's cas-based implementation