inc and dec are atomic in JS backend (#16129)
This commit is contained in:
parent
e220f756e7
commit
7848da7abe
2 changed files with 10 additions and 1 deletions
|
|
@ -1774,7 +1774,7 @@ when not defined(nimscript):
|
||||||
when not declared(sysFatal):
|
when not declared(sysFatal):
|
||||||
include "system/fatal"
|
include "system/fatal"
|
||||||
|
|
||||||
when notJSnotNims:
|
when not defined(nimscript):
|
||||||
{.push stackTrace: off, profiler: off.}
|
{.push stackTrace: off, profiler: off.}
|
||||||
|
|
||||||
proc atomicInc*(memLoc: var int, x: int = 1): int {.inline,
|
proc atomicInc*(memLoc: var int, x: int = 1): int {.inline,
|
||||||
|
|
|
||||||
9
tests/system/tatomics1.nim
Normal file
9
tests/system/tatomics1.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
discard """
|
||||||
|
target: "c cpp js"
|
||||||
|
"""
|
||||||
|
|
||||||
|
var x = 10
|
||||||
|
atomicInc(x)
|
||||||
|
doAssert x == 11
|
||||||
|
atomicDec(x)
|
||||||
|
doAssert x == 10
|
||||||
Loading…
Add table
Add a link
Reference in a new issue