mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-13 14:53:46 +00:00
Fix cas when using vcc/cpp and use the correct interlocked exchange for bool (#6735)
This commit is contained in:
committed by
Andreas Rumpf
parent
e4fd52b223
commit
eab7c88ce9
@@ -213,12 +213,20 @@ proc atomicDec*(memLoc: var int, x: int = 1): int =
|
||||
result = memLoc
|
||||
|
||||
when defined(vcc):
|
||||
proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
|
||||
{.importc: "_InterlockedCompareExchange64", header: "<intrin.h>".}
|
||||
proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
|
||||
{.importc: "_InterlockedCompareExchange", header: "<intrin.h>".}
|
||||
proc interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte
|
||||
{.importc: "_InterlockedCompareExchange64", header: "<intrin.h>".}
|
||||
when defined(cpp):
|
||||
proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
|
||||
{.importcpp: "_InterlockedCompareExchange64(static_cast<NI64 volatile *>(#), #, #)", header: "<intrin.h>".}
|
||||
proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
|
||||
{.importcpp: "_InterlockedCompareExchange(static_cast<NI volatile *>(#), #, #)", header: "<intrin.h>".}
|
||||
proc interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte
|
||||
{.importcpp: "_InterlockedCompareExchange8(static_cast<char volatile *>(#), #, #)", header: "<intrin.h>".}
|
||||
else:
|
||||
proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
|
||||
{.importc: "_InterlockedCompareExchange64", header: "<intrin.h>".}
|
||||
proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
|
||||
{.importc: "_InterlockedCompareExchange", header: "<intrin.h>".}
|
||||
proc interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte
|
||||
{.importc: "_InterlockedCompareExchange8", header: "<intrin.h>".}
|
||||
|
||||
proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
|
||||
when sizeof(T) == 8:
|
||||
|
||||
Reference in New Issue
Block a user