mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
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++; ```
This commit is contained in:
parent
46fa01a4b8
commit
108d9d6b61
1 changed files with 1 additions and 1 deletions
|
@ -104,7 +104,7 @@ static inline uint8_t __basepriSetRetVal(uint8_t prio)
|
|||
__asm__ volatile ("\t# barier(" #data ") end\n" : : "m" (**__d)); \
|
||||
} \
|
||||
typeof(data) __attribute__((__cleanup__(__UNIQL(__barrierEnd)))) *__UNIQL(__barrier) = &data; \
|
||||
__asm__ volatile ("\t# barier (" #data ") start\n" : "=m" (*__UNIQL(__barrier)))
|
||||
__asm__ volatile ("\t# barier (" #data ") start\n" : "+m" (*__UNIQL(__barrier)))
|
||||
|
||||
|
||||
// define these wrappers for atomic operations, use gcc buildins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue