fixed bugs in atomic_flag

Bugs are described [here](https://github.com/hrydgard/ppsspp/pull/4021)