mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
GCC atomics also work in clang 3.0+
This commit is contained in:
parent
0181fae076
commit
c3bf91d608
@ -39,14 +39,19 @@ typedef AtomicAdjustI386Impl AtomicAdjust;
|
||||
#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1
|
||||
#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1
|
||||
|
||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
|
||||
#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (defined(__clang__) && (__clang_major__ >= 3))
|
||||
// GCC 4.7 and above has built-in __atomic functions for atomic operations.
|
||||
// Clang 3.0 and above also supports them.
|
||||
|
||||
#include "atomicAdjustGccImpl.h"
|
||||
typedef AtomicAdjustGccImpl AtomicAdjust;
|
||||
|
||||
#if (__GCC_ATOMIC_INT_LOCK_FREE + __GCC_ATOMIC_INT_LOCK_FREE) > 0
|
||||
#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE 1
|
||||
#endif
|
||||
#if __GCC_ATOMIC_POINTER_LOCK_FREE > 0
|
||||
#define HAVE_ATOMIC_COMPARE_AND_EXCHANGE_PTR 1
|
||||
#endif
|
||||
|
||||
#elif defined(THREAD_WIN32_IMPL)
|
||||
|
||||
|
@ -125,7 +125,7 @@ compare_and_exchange(TVOLATILE AtomicAdjustGccImpl::Integer &mem,
|
||||
AtomicAdjustGccImpl::Integer old_value,
|
||||
AtomicAdjustGccImpl::Integer new_value) {
|
||||
|
||||
__atomic_compare_exchange_n(&mem, &old_value, new_value, false,
|
||||
__atomic_compare_exchange_n(&mem, &old_value, new_value, true,
|
||||
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||
return old_value;
|
||||
}
|
||||
@ -142,7 +142,7 @@ compare_and_exchange_ptr(TVOLATILE AtomicAdjustGccImpl::Pointer &mem,
|
||||
AtomicAdjustGccImpl::Pointer old_value,
|
||||
AtomicAdjustGccImpl::Pointer new_value) {
|
||||
|
||||
__atomic_compare_exchange_n(&mem, &old_value, new_value, false,
|
||||
__atomic_compare_exchange_n(&mem, &old_value, new_value, true,
|
||||
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||
return old_value;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "dtoolbase.h"
|
||||
#include "selectThreadImpl.h"
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
|
||||
#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (defined(__clang__) && (__clang_major__ >= 3))
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : AtomicAdjustGccImpl
|
||||
|
Loading…
x
Reference in New Issue
Block a user