+ }
+
+ bool compareAndExchange(unsigned oldValue, unsigned newValue)
+ {
+#if defined(SGATOMIC_USE_GCC4_BUILTINS)
+ return __sync_bool_compare_and_swap(&mValue, oldValue, newValue);
+#elif defined(SGATOMIC_USE_MIPOSPRO_BUILTINS)
+ return __compare_and_swap(&mValue, oldValue, newValue);
+#elif defined(SGATOMIC_USE_WIN32_INTERLOCKED)
+ long volatile* lvPtr = reinterpret_cast<long volatile*>(&mValue);
+ return oldValue == InterlockedCompareExchange(lvPtr, newValue, oldValue);
+#else
+ SGGuard<SGMutex> lock(mMutex);
+ if (mValue != oldValue)
+ return false;
+ mValue = newValue;
+ return true;
+#endif
+ }