Atomic inc/dec should use ATOMIC_SEQ_CST (#19212)
This commit is contained in:
parent
7806ec525e
commit
0992854941
1 changed files with 3 additions and 3 deletions
|
|
@ -217,7 +217,7 @@ else:
|
||||||
|
|
||||||
proc atomicInc*(memLoc: var int, x: int = 1): int =
|
proc atomicInc*(memLoc: var int, x: int = 1): int =
|
||||||
when someGcc and hasThreadSupport:
|
when someGcc and hasThreadSupport:
|
||||||
result = atomicAddFetch(memLoc.addr, x, ATOMIC_RELAXED)
|
result = atomicAddFetch(memLoc.addr, x, ATOMIC_SEQ_CST)
|
||||||
elif someVcc and hasThreadSupport:
|
elif someVcc and hasThreadSupport:
|
||||||
result = addAndFetch(memLoc.addr, x)
|
result = addAndFetch(memLoc.addr, x)
|
||||||
inc(result, 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 =
|
proc atomicDec*(memLoc: var int, x: int = 1): int =
|
||||||
when someGcc and hasThreadSupport:
|
when someGcc and hasThreadSupport:
|
||||||
when declared(atomicSubFetch):
|
when declared(atomicSubFetch):
|
||||||
result = atomicSubFetch(memLoc.addr, x, ATOMIC_RELAXED)
|
result = atomicSubFetch(memLoc.addr, x, ATOMIC_SEQ_CST)
|
||||||
else:
|
else:
|
||||||
result = atomicAddFetch(memLoc.addr, -x, ATOMIC_RELAXED)
|
result = atomicAddFetch(memLoc.addr, -x, ATOMIC_SEQ_CST)
|
||||||
elif someVcc and hasThreadSupport:
|
elif someVcc and hasThreadSupport:
|
||||||
result = addAndFetch(memLoc.addr, -x)
|
result = addAndFetch(memLoc.addr, -x)
|
||||||
dec(result, x)
|
dec(result, x)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue