Fix cas when using vcc/cpp and use the correct interlocked exchange for bool (#6735)
This commit is contained in:
parent
e4fd52b223
commit
eab7c88ce9
1 changed files with 14 additions and 6 deletions
|
|
@ -213,12 +213,20 @@ proc atomicDec*(memLoc: var int, x: int = 1): int =
|
||||||
result = memLoc
|
result = memLoc
|
||||||
|
|
||||||
when defined(vcc):
|
when defined(vcc):
|
||||||
proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
|
when defined(cpp):
|
||||||
{.importc: "_InterlockedCompareExchange64", header: "<intrin.h>".}
|
proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64
|
||||||
proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
|
{.importcpp: "_InterlockedCompareExchange64(static_cast<NI64 volatile *>(#), #, #)", header: "<intrin.h>".}
|
||||||
{.importc: "_InterlockedCompareExchange", header: "<intrin.h>".}
|
proc interlockedCompareExchange32(p: pointer; exchange, comparand: int32): int32
|
||||||
proc interlockedCompareExchange8(p: pointer; exchange, comparand: byte): byte
|
{.importcpp: "_InterlockedCompareExchange(static_cast<NI volatile *>(#), #, #)", header: "<intrin.h>".}
|
||||||
{.importc: "_InterlockedCompareExchange64", 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 =
|
proc cas*[T: bool|int|ptr](p: ptr T; oldValue, newValue: T): bool =
|
||||||
when sizeof(T) == 8:
|
when sizeof(T) == 8:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue