Fix atomic.h
commit108d9d6b61b05d96163dfd4cdea2d4d86f413b8e
authorPetr Ledvina <ledvinap@gmail.com>
Thu, 29 Dec 2016 18:31:02 +0000 (29 19:31 +0100)
committerborisbstyle <dreambb1982@gmail.com>
Mon, 30 Jan 2017 23:50:26 +0000 (31 00:50 +0100)
tree2af901151c4fc5f93a929ec2f5e6e848d480bc6a
parent46fa01a4b82c1fa3adaab35ebf0716a234132c75
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