Fix atomic.h
commit107fc11939c9c873ae890d583ad2153cd4b0eead
authorPetr Ledvina <ledvinap@gmail.com>
Thu, 29 Dec 2016 18:31:02 +0000 (29 19:31 +0100)
committerMichael Keller <github@ike.ch>
Wed, 25 Jan 2017 20:40:17 +0000 (26 09:40 +1300)
tree0195d8dae4d35498de32a6cdeae557dbdcd35024
parent42256ca8b57feeb0feea4aa9b68f40802106b993
Fix atomic.h

`=m` output operand means that value is write only, gcc may discard previous value because it assumes that it will be overwritten. This bug was not triggered in gcc v4 because `asm volatile` triggered full memory barrier.

With old version, this code will increase `markme` only by 2, not 3:
```
static int markme = 0;
markme++;
ATOMIC_BLOCK_NB(0xff) {
  ATOMIC_BARRIER(markme);  // markme is marked as overwritten, previous increment can be discarded
  markme++;
}
markme++;
```
src/main/build/atomic.h