|
|
@@ -8,13 +8,13 @@
|
|
|
#endif // BX_CPU_H_HEADER_GUARD
|
|
|
|
|
|
#if BX_COMPILER_MSVC
|
|
|
-# if BX_PLATFORM_WINRT || (BX_PLATFORM_WINDOWS && (!BX_CPU_X86))
|
|
|
+# if BX_PLATFORM_WINRT || (BX_PLATFORM_WINDOWS && !BX_CPU_X86)
|
|
|
# include <windows.h>
|
|
|
-# endif // BX_PLATFORM_WINRT || (BX_PLATFORM_WINDOWS && (!BX_CPU_X86))
|
|
|
+# endif // BX_PLATFORM_WINRT || (BX_PLATFORM_WINDOWS && !BX_CPU_X86)
|
|
|
|
|
|
# if BX_CPU_X86
|
|
|
# include <emmintrin.h> // _mm_fence
|
|
|
-# endif
|
|
|
+# endif // BX_CPU_X86
|
|
|
|
|
|
extern "C" void _ReadBarrier();
|
|
|
# pragma intrinsic(_ReadBarrier)
|
|
|
@@ -68,7 +68,7 @@ namespace bx
|
|
|
_ReadBarrier();
|
|
|
#else
|
|
|
asm volatile("":::"memory");
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
inline void writeBarrier()
|
|
|
@@ -77,7 +77,7 @@ namespace bx
|
|
|
_WriteBarrier();
|
|
|
#else
|
|
|
asm volatile("":::"memory");
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
inline void readWriteBarrier()
|
|
|
@@ -86,17 +86,17 @@ namespace bx
|
|
|
_ReadWriteBarrier();
|
|
|
#else
|
|
|
asm volatile("":::"memory");
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
inline void memoryBarrier()
|
|
|
{
|
|
|
#if BX_COMPILER_MSVC
|
|
|
-# if BX_CPU_X86
|
|
|
+# if BX_CPU_X86
|
|
|
_mm_mfence();
|
|
|
-# else
|
|
|
+# else
|
|
|
MemoryBarrier();
|
|
|
-# endif // BX_CPU_X86
|
|
|
+# endif // BX_CPU_X86
|
|
|
#else
|
|
|
__sync_synchronize();
|
|
|
#endif // BX_COMPILER_MSVC
|
|
|
@@ -109,7 +109,7 @@ namespace bx
|
|
|
return int32_t(_InterlockedCompareExchange( (volatile long*)(_ptr), long(_new), long(_old) ) );
|
|
|
#else
|
|
|
return __sync_val_compare_and_swap( (volatile int32_t*)_ptr, _old, _new);
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -119,7 +119,7 @@ namespace bx
|
|
|
return uint32_t(_InterlockedCompareExchange( (volatile long*)(_ptr), long(_new), long(_old) ) );
|
|
|
#else
|
|
|
return __sync_val_compare_and_swap( (volatile int32_t*)_ptr, _old, _new);
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -129,7 +129,7 @@ namespace bx
|
|
|
return _InterlockedCompareExchange64(_ptr, _new, _old);
|
|
|
#else
|
|
|
return __sync_val_compare_and_swap( (volatile int64_t*)_ptr, _old, _new);
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -139,7 +139,7 @@ namespace bx
|
|
|
return uint64_t(_InterlockedCompareExchange64( (volatile int64_t*)(_ptr), int64_t(_new), int64_t(_old) ) );
|
|
|
#else
|
|
|
return __sync_val_compare_and_swap( (volatile int64_t*)_ptr, _old, _new);
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -149,7 +149,7 @@ namespace bx
|
|
|
return _InterlockedExchangeAdd( (volatile long*)_ptr, _add);
|
|
|
#else
|
|
|
return __sync_fetch_and_add(_ptr, _add);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -178,7 +178,7 @@ namespace bx
|
|
|
# endif
|
|
|
#else
|
|
|
return __sync_fetch_and_add(_ptr, _add);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -194,7 +194,7 @@ namespace bx
|
|
|
return atomicFetchAndAdd(_ptr, _add) + _add;
|
|
|
#else
|
|
|
return __sync_add_and_fetch(_ptr, _add);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -204,7 +204,7 @@ namespace bx
|
|
|
return atomicFetchAndAdd(_ptr, _add) + _add;
|
|
|
#else
|
|
|
return __sync_add_and_fetch(_ptr, _add);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -226,7 +226,7 @@ namespace bx
|
|
|
return atomicFetchAndAdd(_ptr, -_sub);
|
|
|
#else
|
|
|
return __sync_fetch_and_sub(_ptr, _sub);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -236,7 +236,7 @@ namespace bx
|
|
|
return atomicFetchAndAdd(_ptr, -_sub);
|
|
|
#else
|
|
|
return __sync_fetch_and_sub(_ptr, _sub);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -258,7 +258,7 @@ namespace bx
|
|
|
return atomicFetchAndAdd(_ptr, -_sub) - _sub;
|
|
|
#else
|
|
|
return __sync_sub_and_fetch(_ptr, _sub);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -268,7 +268,7 @@ namespace bx
|
|
|
return atomicFetchAndAdd(_ptr, -_sub) - _sub;
|
|
|
#else
|
|
|
return __sync_sub_and_fetch(_ptr, _sub);
|
|
|
-#endif // BX_COMPILER_
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
template<>
|
|
|
@@ -349,7 +349,7 @@ namespace bx
|
|
|
return _InterlockedExchangePointer(_ptr, _new);
|
|
|
#else
|
|
|
return __sync_lock_test_and_set(_ptr, _new);
|
|
|
-#endif // BX_COMPILER
|
|
|
+#endif // BX_COMPILER_*
|
|
|
}
|
|
|
|
|
|
} // namespace bx
|