Implements a few improvements for the atomic integers.

The main concern on the mailing list was that some of the
implementation was not using memory barriers/fences, which
may be dangerous in some cases. I made the first attempt to
make much of the atomic functionality use a sequentially-
consistent ordering by using memory barriers. The performance
impact seems to be relatively small but we will have to keep
an eye on it.

I also made some changes to the implementation that will
hopefully avoid falling back to critical sections on Windows
XP.

Change-Id: Ib05f411f905cfe9a89bb8bc82ca103d3c1eb8002
Merge topic 'atomics-improvements' into master

8d3f2756 Implements a few improvements for the atomic integers.