inc and dec are atomic in JS backend (#16129)

This commit is contained in:
flywind
2020-11-25 21:09:03 +08:00
committed by GitHub
parent e220f756e7
commit 7848da7abe
2 changed files with 10 additions and 1 deletions

View File

@@ -1774,7 +1774,7 @@ when not defined(nimscript):
when not declared(sysFatal):
include "system/fatal"
when notJSnotNims:
when not defined(nimscript):
{.push stackTrace: off, profiler: off.}
proc atomicInc*(memLoc: var int, x: int = 1): int {.inline,

View File

@@ -0,0 +1,9 @@
discard """
target: "c cpp js"
"""
var x = 10
atomicInc(x)
doAssert x == 11
atomicDec(x)
doAssert x == 10