|
|
|
@ -61,7 +61,7 @@ namespace nv {
|
|
|
|
|
*ptr = value; // on x86, stores are Release
|
|
|
|
|
nvCompilerWriteBarrier();
|
|
|
|
|
#else
|
|
|
|
|
#error "Not implemented"
|
|
|
|
|
#error "Atomics not implemented."
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -84,6 +84,25 @@ namespace nv {
|
|
|
|
|
|
|
|
|
|
return (uint32)_InterlockedDecrement((long *)value);
|
|
|
|
|
}
|
|
|
|
|
#elif NV_CC_GNUC
|
|
|
|
|
// Many alternative implementations at:
|
|
|
|
|
// http://www.memoryhole.net/kyle/2007/05/atomic_incrementing.html
|
|
|
|
|
|
|
|
|
|
inline uint32 atomicIncrement(uint32 * value)
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck((intptr_t(value) & 3) == 0);
|
|
|
|
|
|
|
|
|
|
return __sync_fetch_and_add(value, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline uint32 atomicDecrement(uint32 * value)
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck((intptr_t(value) & 3) == 0);
|
|
|
|
|
|
|
|
|
|
return __sync_fetch_and_sub(value, 1);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
#error "Atomics not implemented."
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|