Skip to content

Commit

Permalink
inc and dec are atomic in JS backend (#16129)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Nov 25, 2020
1 parent e220f75 commit 7848da7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit 7848da7

Please sign in to comment.