mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
inc and dec are atomic in JS backend (#16129)
This commit is contained in:
@@ -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,
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user