diff --git a/src/heap.cpp b/src/heap.cpp index 740b9985af..5dcd75f7c2 100644 --- a/src/heap.cpp +++ b/src/heap.cpp @@ -76,7 +76,10 @@ markBitAtomic(uintptr_t* map, unsigned i) { uintptr_t* p = map + wordOf(i); uintptr_t v = static_cast(1) << bitOf(i); - while (not atomicCompareAndSwap(p, *p, *p | v)) { } + for (uintptr_t old = *p; + not atomicCompareAndSwap(p, old, old | v); + old = *p) + { } } #endif // USE_ATOMIC_OPERATIONS diff --git a/src/machine.cpp b/src/machine.cpp index 62c4649659..b9ae880225 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -24,9 +24,12 @@ const unsigned NoByte = 0xFFFF; #ifdef USE_ATOMIC_OPERATIONS void -atomicIncrement(unsigned* p, int v) +atomicIncrement(uint32_t* p, int v) { - while (not atomicCompareAndSwap32(p, *p, *p + v)) { } + for (uint32_t old = *p; + not atomicCompareAndSwap32(p, old, old + v); + old = *p) + { } } #endif