1#ifdef PL_ATOMICUTLS_WIN_INL_H_INCLUDED
2# error "This file must not be included twice."
5#define PL_ATOMICUTLS_WIN_INL_H_INCLUDED
11 return _InterlockedOr((
long*)(&iSrc), 0);
16#if PL_ENABLED(PL_PLATFORM_32BIT)
21 }
while (_InterlockedCompareExchange64(
const_cast<plInt64*
>(&iSrc), old, old) != old);
24 return _InterlockedOr64(
const_cast<plInt64*
>(&iSrc), 0);
30 return _InterlockedIncrement(
reinterpret_cast<long*
>(&ref_iDest));
35#if PL_ENABLED(PL_PLATFORM_32BIT)
40 }
while (_InterlockedCompareExchange64(&ref_iDest, old + 1, old) != old);
43 return _InterlockedIncrement64(&ref_iDest);
49 return _InterlockedDecrement(
reinterpret_cast<long*
>(&ref_iDest));
54#if PL_ENABLED(PL_PLATFORM_32BIT)
59 }
while (_InterlockedCompareExchange64(&ref_iDest, old - 1, old) != old);
62 return _InterlockedDecrement64(&ref_iDest);
68 return _InterlockedExchangeAdd(
reinterpret_cast<long*
>(&ref_iDest), 1);
73#if PL_ENABLED(PL_PLATFORM_32BIT)
78 }
while (_InterlockedCompareExchange64(&ref_iDest, old + 1, old) != old);
81 return _InterlockedExchangeAdd64(&ref_iDest, 1);
87 return _InterlockedExchangeAdd(
reinterpret_cast<long*
>(&ref_iDest), -1);
92#if PL_ENABLED(PL_PLATFORM_32BIT)
97 }
while (_InterlockedCompareExchange64(&ref_iDest, old - 1, old) != old);
100 return _InterlockedExchangeAdd64(&ref_iDest, -1);
106 _InterlockedExchangeAdd(
reinterpret_cast<long*
>(&ref_iDest), value);
111#if PL_ENABLED(PL_PLATFORM_32BIT)
116 }
while (_InterlockedCompareExchange64(&ref_iDest, old + value, old) != old);
118 _InterlockedExchangeAdd64(&ref_iDest, value);
125 _InterlockedAnd(
reinterpret_cast<long*
>(&ref_iDest), value);
130#if PL_ENABLED(PL_PLATFORM_32BIT)
135 }
while (_InterlockedCompareExchange64(&ref_iDest, old & value, old) != old);
137 _InterlockedAnd64(&ref_iDest, value);
144 _InterlockedOr(
reinterpret_cast<long*
>(&ref_iDest), value);
149#if PL_ENABLED(PL_PLATFORM_32BIT)
154 }
while (_InterlockedCompareExchange64(&ref_iDest, old | value, old) != old);
156 _InterlockedOr64(&ref_iDest, value);
163 _InterlockedXor(
reinterpret_cast<long*
>(&ref_iDest), value);
168#if PL_ENABLED(PL_PLATFORM_32BIT)
173 }
while (_InterlockedCompareExchange64(&ref_iDest, old ^ value, old) != old);
175 _InterlockedXor64(&ref_iDest, value);
185 plInt32 iOldValue = ref_iDest;
186 plInt32 iNewValue = value < iOldValue ? value : iOldValue;
188 if (_InterlockedCompareExchange(
reinterpret_cast<long*
>(&ref_iDest), iNewValue, iOldValue) == iOldValue)
198 plInt64 iOldValue = ref_iDest;
199 plInt64 iNewValue = value < iOldValue ? value : iOldValue;
201 if (_InterlockedCompareExchange64(&ref_iDest, iNewValue, iOldValue) == iOldValue)
211 plInt32 iOldValue = ref_iDest;
212 plInt32 iNewValue = iOldValue < value ? value : iOldValue;
214 if (_InterlockedCompareExchange(
reinterpret_cast<long*
>(&ref_iDest), iNewValue, iOldValue) == iOldValue)
224 plInt64 iOldValue = ref_iDest;
225 plInt64 iNewValue = iOldValue < value ? value : iOldValue;
227 if (_InterlockedCompareExchange64(&ref_iDest, iNewValue, iOldValue) == iOldValue)
235 return _InterlockedExchange(
reinterpret_cast<long*
>(&ref_iDest), value);
240#if PL_ENABLED(PL_PLATFORM_32BIT)
245 }
while (_InterlockedCompareExchange64(&ref_iDest, value, old) != old);
248 return _InterlockedExchange64(&ref_iDest, value);
255 return _InterlockedCompareExchange(
reinterpret_cast<long*
>(&ref_iDest), value, iExpected) == iExpected;
260 return _InterlockedCompareExchange64(&ref_iDest, value, iExpected) == iExpected;
265 return _InterlockedCompareExchangePointer(pDest, value, pExpected) == pExpected;
270 return _InterlockedCompareExchange(
reinterpret_cast<long*
>(&ref_iDest), value, iExpected);
275 return _InterlockedCompareExchange64(&ref_iDest, value, iExpected);
static plInt32 Decrement(plInt32 &ref_iDest)
Decrements dest as an atomic operation and returns the new value.
Definition AtomicUtils_posix.h:31
static void Add(plInt32 &ref_iDest, plInt32 value)
Adds value to dest as an atomic operation.
Definition AtomicUtils_posix.h:62
static plInt32 CompareAndSwap(plInt32 &ref_iDest, plInt32 iExpected, plInt32 value)
If dest is equal to expected, this function sets dest to value. Otherwise dest will not be modified....
Definition AtomicUtils_posix.h:192
static void Or(plInt32 &ref_iDest, plInt32 value)
Performs an atomic bitwise OR on dest using value.
Definition AtomicUtils_posix.h:84
static plInt32 Read(const plInt32 &iSrc)
Returns src as an atomic operation and returns its value.
Definition AtomicUtils_posix.h:10
static void Min(plInt32 &ref_iDest, plInt32 value)
Performs an atomic min operation on dest using value.
Definition AtomicUtils_posix.h:106
static void And(plInt32 &ref_iDest, plInt32 value)
Performs an atomic bitwise AND on dest using value.
Definition AtomicUtils_posix.h:73
static void Xor(plInt32 &ref_iDest, plInt32 value)
Performs an atomic bitwise XOR on dest using value.
Definition AtomicUtils_posix.h:95
static plInt32 PostIncrement(plInt32 &ref_iDest)
Increments dest as an atomic operation and returns the old value.
Definition AtomicUtils_posix.h:41
static plInt32 Increment(plInt32 &ref_iDest)
Increments dest as an atomic operation and returns the new value.
Definition AtomicUtils_posix.h:20
static void Max(plInt32 &ref_iDest, plInt32 value)
Performs an atomic max operation on dest using value.
Definition AtomicUtils_posix.h:133
static plInt32 PostDecrement(plInt32 &ref_iDest)
Decrements dest as an atomic operation and returns the old value.
Definition AtomicUtils_posix.h:52
static plInt32 Set(plInt32 &ref_iDest, plInt32 value)
Sets dest to value as an atomic operation and returns the original value of dest.
Definition AtomicUtils_posix.h:160
static bool TestAndSet(plInt32 &ref_iDest, plInt32 iExpected, plInt32 value)
If dest is equal to expected, this function sets dest to value and returns true. Otherwise dest will ...
Definition AtomicUtils_posix.h:171