mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 07:13:27 +00:00
Atomic inc/dec should use ATOMIC_SEQ_CST (#19212)
(cherry picked from commit 0992854941)
This commit is contained in:
@@ -217,7 +217,7 @@ else:
|
||||
|
||||
proc atomicInc*(memLoc: var int, x: int = 1): int =
|
||||
when someGcc and hasThreadSupport:
|
||||
result = atomicAddFetch(memLoc.addr, x, ATOMIC_RELAXED)
|
||||
result = atomicAddFetch(memLoc.addr, x, ATOMIC_SEQ_CST)
|
||||
elif someVcc and hasThreadSupport:
|
||||
result = addAndFetch(memLoc.addr, x)
|
||||
inc(result, x)
|
||||
@@ -228,9 +228,9 @@ proc atomicInc*(memLoc: var int, x: int = 1): int =
|
||||
proc atomicDec*(memLoc: var int, x: int = 1): int =
|
||||
when someGcc and hasThreadSupport:
|
||||
when declared(atomicSubFetch):
|
||||
result = atomicSubFetch(memLoc.addr, x, ATOMIC_RELAXED)
|
||||
result = atomicSubFetch(memLoc.addr, x, ATOMIC_SEQ_CST)
|
||||
else:
|
||||
result = atomicAddFetch(memLoc.addr, -x, ATOMIC_RELAXED)
|
||||
result = atomicAddFetch(memLoc.addr, -x, ATOMIC_SEQ_CST)
|
||||
elif someVcc and hasThreadSupport:
|
||||
result = addAndFetch(memLoc.addr, -x)
|
||||
dec(result, x)
|
||||
|
||||
Reference in New Issue
Block a user