Fix for compile error happening on Mingw.

_Interlocked* don't seem to exist on Mingw. Using critical
sections instead. This is probably slower so someone that cares
about multi-threaded performance on Mingw may want to do a
better fix.

Change-Id: I04128a0492d13c8bd7fe76e86c980d1562f1b26c
Merge topic 'mingw-atomic-fix' into master

4e968a6f Fix for compile error happening on Mingw.