diff options
author | cooldome <cdome@bk.ru> | 2019-12-13 12:12:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-13 12:12:04 +0000 |
commit | 777c9ad0ef47de8ff0f1c4387541c1d7b0a1fa6a (patch) | |
tree | 4d66cc368c3b9f196abcb7b9e132ba2bb82b3631 | |
parent | 1e1fd73530a77332f11a4133b78f2f713a6cdbd3 (diff) | |
download | Nim-777c9ad0ef47de8ff0f1c4387541c1d7b0a1fa6a.tar.gz |
Better clang_cl support (#12896)
-rw-r--r-- | lib/system/atomics.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/system/atomics.nim b/lib/system/atomics.nim index c0612c9a5..146bb859f 100644 --- a/lib/system/atomics.nim +++ b/lib/system/atomics.nim @@ -11,6 +11,7 @@ {.push stackTrace:off, profiler:off.} const someGcc = defined(gcc) or defined(llvm_gcc) or defined(clang) +const someVcc = defined(vcc) or defined(clang_cl) type AtomType* = SomeNumber|pointer|ptr|char|bool @@ -163,7 +164,7 @@ when someGcc and hasThreadSupport: ## ignore this parameter. template fence*() = atomicThreadFence(ATOMIC_SEQ_CST) -elif defined(vcc) and hasThreadSupport: +elif someVcc and hasThreadSupport: type AtomMemModel* = distinct cint const @@ -217,7 +218,7 @@ else: proc atomicInc*(memLoc: var int, x: int = 1): int = when someGcc and hasThreadSupport: result = atomicAddFetch(memLoc.addr, x, ATOMIC_RELAXED) - elif defined(vcc) and hasThreadSupport: + elif someVcc and hasThreadSupport: result = addAndFetch(memLoc.addr, x) inc(result, x) else: @@ -230,14 +231,14 @@ proc atomicDec*(memLoc: var int, x: int = 1): int = result = atomicSubFetch(memLoc.addr, x, ATOMIC_RELAXED) else: result = atomicAddFetch(memLoc.addr, -x, ATOMIC_RELAXED) - elif defined(vcc) and hasThreadSupport: + elif someVcc and hasThreadSupport: result = addAndFetch(memLoc.addr, -x) dec(result, x) else: dec(memLoc, x) result = memLoc -when defined(vcc): +when someVcc: when defined(cpp): proc interlockedCompareExchange64(p: pointer; exchange, comparand: int64): int64 {.importcpp: "_InterlockedCompareExchange64(static_cast<NI64 volatile *>(#), #, #)", header: "<intrin.h>".} @@ -321,7 +322,7 @@ else: # XXX is this valid for 'int'? -when (defined(x86) or defined(amd64)) and defined(vcc): +when (defined(x86) or defined(amd64)) and someVcc: proc cpuRelax* {.importc: "YieldProcessor", header: "<windows.h>".} elif (defined(x86) or defined(amd64)) and (someGcc or defined(bcc)): proc cpuRelax* {.inline.} = |