Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inc and dec are atomic in JS backend #16129

Merged
merged 14 commits into from
Nov 25, 2020
2 changes: 1 addition & 1 deletion lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions tests/system/tatomics1.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
discard """
target: "c cpp js"
"""

var x = 10
atomicInc(x)
doAssert x == 11
atomicDec(x)
doAssert x == 10