Coverity fixes.

Change-Id: Ieb580a23436b227fb889197cb3f4857f03ccf7ae
Atomics compatibility wrapper, should work for most recent compilers.

Fallback for x86/amd64 architectures using full barrier.

Change-Id: I80e3beaa721653f760f2d0a6d26a80dd422ab618