mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 03:44:14 +00:00
@@ -288,10 +288,10 @@ else:
|
||||
type
|
||||
# Atomic* {.importcpp: "_Atomic('0)".} [T] = object
|
||||
|
||||
AtomicInt8 {.importc: "_Atomic NI8", size: 1.} = object
|
||||
AtomicInt16 {.importc: "_Atomic NI16", size: 2.} = object
|
||||
AtomicInt32 {.importc: "_Atomic NI32", size: 4.} = object
|
||||
AtomicInt64 {.importc: "_Atomic NI64", size: 8.} = object
|
||||
AtomicInt8 {.importc: "_Atomic NI8".} = int8
|
||||
AtomicInt16 {.importc: "_Atomic NI16".} = int16
|
||||
AtomicInt32 {.importc: "_Atomic NI32".} = int32
|
||||
AtomicInt64 {.importc: "_Atomic NI64".} = int64
|
||||
|
||||
template atomicType*(T: typedesc[Trivial]): untyped =
|
||||
# Maps the size of a trivial type to it's internal atomic type
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# test atomic operations
|
||||
|
||||
import atomics, bitops
|
||||
import std/[atomics, bitops]
|
||||
|
||||
type
|
||||
Object = object
|
||||
@@ -607,3 +607,23 @@ block clear:
|
||||
doAssert not location.testAndSet
|
||||
location.clear(moRelease)
|
||||
doAssert not location.testAndSet
|
||||
|
||||
block: # bug #18844
|
||||
when not defined(cpp): # cpp pending pr #18836
|
||||
type
|
||||
Deprivation = object of RootObj
|
||||
memes: Atomic[int]
|
||||
Zoomer = object
|
||||
dopamine: Deprivation
|
||||
|
||||
block:
|
||||
var x = Deprivation()
|
||||
var y = Zoomer()
|
||||
doAssert x.memes.load == 0
|
||||
doAssert y.dopamine.memes.load == 0
|
||||
|
||||
block:
|
||||
var x: Deprivation
|
||||
var y: Zoomer
|
||||
doAssert x.memes.load == 0
|
||||
doAssert y.dopamine.memes.load == 0
|
||||
|
||||
Reference in New Issue
Block a user