Ported Compare and Swap for 32bit values

Compare and Swap is now implemented without locks. Compatible with ARM
Cortex, ARM v7 etc.