@@ -293,19 +293,16 @@ else:
293293 AtomicInt32 {.importc : " _Atomic NI32" .} = int32
294294 AtomicInt64 {.importc : " _Atomic NI64" .} = int64
295295
296- template atomicType * (T: typedesc [Trivial ]): untyped =
297- # Maps the size of a trivial type to it's internal atomic type
298- when sizeof (T) == 1 : AtomicInt8
299- elif sizeof (T) == 2 : AtomicInt16
300- elif sizeof (T) == 4 : AtomicInt32
301- elif sizeof (T) == 8 : AtomicInt64
302-
303296 type
304297 AtomicFlag * {.importc : " atomic_flag" , size : 1 .} = object
305298
306299 Atomic * [T] = object
307300 when T is Trivial :
308- value: T.atomicType
301+ # Maps the size of a trivial type to it's internal atomic type
302+ when sizeof (T) == 1 : value: AtomicInt8
303+ elif sizeof (T) == 2 : value: AtomicInt16
304+ elif sizeof (T) == 4 : value: AtomicInt32
305+ elif sizeof (T) == 8 : value: AtomicInt64
309306 else :
310307 nonAtomicValue: T
311308 guard: AtomicFlag
@@ -364,11 +361,11 @@ else:
364361 cast [T](atomic_fetch_xor_explicit (addr (location.value), cast [nonAtomicType (T)](value), order))
365362
366363 template withLock [T: not Trivial ](location: var Atomic [T]; order: MemoryOrder ; body: untyped ): untyped =
367- while location.guard. testAndSet ( moAcquire): discard
364+ while testAndSet ( location.guard, moAcquire): discard
368365 try :
369366 body
370367 finally :
371- location.guard. clear ( moRelease)
368+ clear ( location.guard, moRelease)
372369
373370 proc load * [T: not Trivial ](location: var Atomic [T]; order: MemoryOrder = moSequentiallyConsistent): T {.inline .} =
374371 withLock (location, order):
0 commit comments