Fix atomic.h
commit5b11326eb1694af7ac8010080ebb680b8a7a5a17
authorPetr Ledvina <ledvinap@gmail.com>
Thu, 29 Dec 2016 18:31:02 +0000 (29 19:31 +0100)
committerborisbstyle <dreambb1982@gmail.com>
Tue, 31 Jan 2017 13:20:29 +0000 (31 14:20 +0100)
treed762e07f23e183bf265faf7862e8b7008ec74b19
parent3dc03d7735e3fa13d8a181959b772394eec1bd52
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