mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add compare-exchange function to Atomic
This commit is contained in:
@@ -204,6 +204,7 @@ int32_t Dec32(volatile int32_t *i);
|
||||
int64_t Inc64(volatile int64_t *i);
|
||||
int64_t Dec64(volatile int64_t *i);
|
||||
int64_t ExchAdd64(volatile int64_t *i, int64_t a);
|
||||
int32_t CmpExch32(volatile int32_t *dest, int32_t exch, int32_t comp);
|
||||
};
|
||||
|
||||
namespace Callstack
|
||||
|
||||
@@ -59,6 +59,11 @@ int64_t ExchAdd64(volatile int64_t *i, int64_t a)
|
||||
{
|
||||
return __sync_add_and_fetch(i, int64_t(a));
|
||||
}
|
||||
|
||||
int32_t CmpExch32(volatile int32_t *dest, int32_t exch, int32_t comp)
|
||||
{
|
||||
return __sync_val_compare_and_swap(dest, comp, exch);
|
||||
}
|
||||
};
|
||||
|
||||
namespace Threading
|
||||
|
||||
@@ -72,6 +72,11 @@ int64_t ExchAdd64(volatile int64_t *i, int64_t a)
|
||||
{
|
||||
return (int64_t)InterlockedExchangeAdd64((volatile LONG64 *)i, a);
|
||||
}
|
||||
|
||||
int32_t CmpExch32(volatile int32_t *dest, int32_t exch, int32_t comp)
|
||||
{
|
||||
return (int32_t)InterlockedCompareExchange((volatile LONG *)dest, exch, comp);
|
||||
}
|
||||
};
|
||||
|
||||
namespace Threading
|
||||
|
||||
Reference in New Issue
Block a user