2021-01-26 07:38:33 +01:00
|
|
|
int Helper_AtomicMaxS32(int index, int offset, int value)
|
|
|
|
{
|
|
|
|
uint oldValue, newValue;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
oldValue = $STORAGE_MEM$[index].data[offset];
|
|
|
|
newValue = uint(max(int(oldValue), value));
|
2021-10-19 01:24:15 +02:00
|
|
|
} while (atomicCompSwap($STORAGE_MEM$[index].data[offset], oldValue, newValue) != oldValue);
|
2021-01-26 07:38:33 +01:00
|
|
|
return int(oldValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Helper_AtomicMinS32(int index, int offset, int value)
|
|
|
|
{
|
|
|
|
uint oldValue, newValue;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
oldValue = $STORAGE_MEM$[index].data[offset];
|
|
|
|
newValue = uint(min(int(oldValue), value));
|
2021-10-19 01:24:15 +02:00
|
|
|
} while (atomicCompSwap($STORAGE_MEM$[index].data[offset], oldValue, newValue) != oldValue);
|
2021-01-26 07:38:33 +01:00
|
|
|
return int(oldValue);
|
|
|
|
}
|