Various fixes to make atomic ints compile on older platforms.

Some of the functions I used do not exist on older platforms
(Windows XP and Mac PPC). Added checks and switched to using
critical sections when the atomic functions do not exist.
The performance on these older systems is not going to be good
when using atomic functions.

Change-Id: Idee6d35199f036061036e66926f20fb2e5d2088c
Merge topic 'atomics-fixes' into master

9549a06d Various fixes to make atomic ints compile on older platforms.