fix: use SEQ_CST in atomic inc/dec
This commit is contained in:
parent
5354680c15
commit
ec17f60de5
1 changed files with 2 additions and 2 deletions
|
|
@ -48,7 +48,7 @@ static inline size_t atomic_load(const volatile size_t *p) {
|
|||
|
||||
static inline uint32_t atomic_inc(volatile uint32_t *p) {
|
||||
#ifdef __ATOMIC_RELAXED
|
||||
return __atomic_add_fetch(p, 1U, __ATOMIC_RELAXED);
|
||||
return __atomic_add_fetch(p, 1U, __ATOMIC_SEQ_CST);
|
||||
#else
|
||||
return __sync_add_and_fetch(p, 1U);
|
||||
#endif
|
||||
|
|
@ -56,7 +56,7 @@ static inline uint32_t atomic_inc(volatile uint32_t *p) {
|
|||
|
||||
static inline uint32_t atomic_dec(volatile uint32_t *p) {
|
||||
#ifdef __ATOMIC_RELAXED
|
||||
return __atomic_sub_fetch(p, 1U, __ATOMIC_RELAXED);
|
||||
return __atomic_sub_fetch(p, 1U, __ATOMIC_SEQ_CST);
|
||||
#else
|
||||
return __sync_sub_and_fetch(p, 1U);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue