42 #ifndef QATOMIC_X86_64_H
43 #define QATOMIC_X86_64_H
49 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
50 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE
57 #define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
58 #define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE
65 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
66 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
73 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
74 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE
81 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
82 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE
91 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
92 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
101 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
102 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE
104 template <
typename T>
107 template <
typename T>
111 #if defined(Q_CC_GNU) || defined(Q_CC_INTEL)
116 asm volatile(
"lock\n"
128 asm volatile(
"lock\n"
140 asm volatile(
"lock\n"
143 :
"=a" (newValue),
"=qm" (ret),
"+m" (
_q_value)
144 :
"r" (newValue),
"0" (expectedValue)
151 asm volatile(
"xchgl %0,%1"
160 asm volatile(
"lock\n"
162 :
"=r" (valueToAdd),
"+m" (
_q_value)
168 template <
typename T>
172 asm volatile(
"lock\n"
175 :
"=a" (newValue),
"=qm" (ret),
"+m" (_q_value)
176 :
"r" (newValue),
"0" (expectedValue)
181 template <
typename T>
184 asm volatile(
"xchg %0,%1"
185 :
"=r" (newValue),
"+m" (_q_value)
191 template <
typename T>
194 asm volatile(
"lock\n"
196 :
"=r" (valueToAdd),
"+m" (_q_value)
197 :
"0" (valueToAdd *
sizeof(T))
199 return reinterpret_cast<T *
>(valueToAdd);
202 #else // !Q_CC_INTEL && !Q_CC_GNU
240 template <
typename T>
246 template <
typename T>
252 template <
typename T>
258 #endif // Q_CC_GNU || Q_CC_INTEL
305 template <
typename T>
308 return testAndSetOrdered(expectedValue, newValue);
311 template <
typename T>
314 return testAndSetOrdered(expectedValue, newValue);
317 template <
typename T>
320 return testAndSetOrdered(expectedValue, newValue);
323 template <
typename T>
326 return fetchAndStoreOrdered(newValue);
329 template <
typename T>
332 return fetchAndStoreOrdered(newValue);
335 template <
typename T>
338 return fetchAndStoreOrdered(newValue);
341 template <
typename T>
344 return fetchAndAddOrdered(valueToAdd);
347 template <
typename T>
350 return fetchAndAddOrdered(valueToAdd);
353 template <
typename T>
356 return fetchAndAddOrdered(valueToAdd);
363 #endif // QATOMIC_X86_64_H
int fetchAndStoreRelaxed(int newValue)
bool testAndSetRelease(int expectedValue, int newValue)
static bool isFetchAndAddNative()
T * fetchAndAddAcquire(qptrdiff valueToAdd)
T * fetchAndAddOrdered(qptrdiff valueToAdd)
static bool isReferenceCountingNative()
int fetchAndAddRelaxed(int valueToAdd)
Q_CORE_EXPORT int q_atomic_fetch_and_add_int(volatile int *ptr, int value)
Q_CORE_EXPORT int q_atomic_increment(volatile int *ptr)
T * fetchAndStoreAcquire(T *newValue)
T * fetchAndAddRelease(qptrdiff valueToAdd)
Q_CORE_EXPORT int q_atomic_test_and_set_ptr(volatile void *ptr, void *expected, void *newval)
int fetchAndAddAcquire(int valueToAdd)
static bool isReferenceCountingWaitFree()
T * fetchAndAddRelaxed(qptrdiff valueToAdd)
Q_CORE_EXPORT int q_atomic_set_int(volatile int *ptr, int newval)
static bool isFetchAndAddNative()
bool testAndSetOrdered(T *expectedValue, T *newValue)
Q_CORE_EXPORT int q_atomic_decrement(volatile int *ptr)
bool testAndSetAcquire(int expectedValue, int newValue)
static bool isFetchAndStoreNative()
#define QT_BEGIN_NAMESPACE
static bool isTestAndSetNative()
static bool isTestAndSetNative()
static bool isFetchAndStoreNative()
T * fetchAndStoreRelaxed(T *newValue)
static bool isFetchAndAddWaitFree()
bool testAndSetRelaxed(int expectedValue, int newValue)
T * fetchAndStoreRelease(T *newValue)
bool testAndSetRelease(T *expectedValue, T *newValue)
Q_CORE_EXPORT void * q_atomic_fetch_and_add_ptr(volatile void *ptr, qptrdiff value)
static bool isFetchAndStoreWaitFree()
static bool isTestAndSetWaitFree()
GLsizei const GLfloat * value
Q_CORE_EXPORT void * q_atomic_set_ptr(volatile void *ptr, void *newval)
bool testAndSetAcquire(T *expectedValue, T *newValue)
static bool isFetchAndAddWaitFree()
T * fetchAndStoreOrdered(T *newValue)
static bool isFetchAndStoreWaitFree()
bool testAndSetRelaxed(T *expectedValue, T *newValue)
int fetchAndStoreAcquire(int newValue)
static bool isTestAndSetWaitFree()
bool testAndSetOrdered(int expectedValue, int newValue)
Q_CORE_EXPORT int q_atomic_test_and_set_int(volatile int *ptr, int expected, int newval)
int fetchAndAddOrdered(int valueToAdd)
int fetchAndStoreOrdered(int newValue)
int fetchAndAddRelease(int valueToAdd)
int fetchAndStoreRelease(int newValue)