2021-01-26 01:38:33 -05:00
|
|
|
int Helper_AtomicMaxS32(int offset, int value)
|
|
|
|
{
|
|
|
|
uint oldValue, newValue;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
oldValue = $SHARED_MEM$[offset];
|
|
|
|
newValue = uint(max(int(oldValue), value));
|
2021-10-18 19:24:15 -04:00
|
|
|
} while (atomicCompSwap($SHARED_MEM$[offset], oldValue, newValue) != oldValue);
|
2021-01-26 01:38:33 -05:00
|
|
|
return int(oldValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Helper_AtomicMinS32(int offset, int value)
|
|
|
|
{
|
|
|
|
uint oldValue, newValue;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
oldValue = $SHARED_MEM$[offset];
|
|
|
|
newValue = uint(min(int(oldValue), value));
|
2021-10-18 19:24:15 -04:00
|
|
|
} while (atomicCompSwap($SHARED_MEM$[offset], oldValue, newValue) != oldValue);
|
2021-01-26 01:38:33 -05:00
|
|
|
return int(oldValue);
|
|
|
|
}
|