42 #ifndef QATOMIC_I386_H
43 #define QATOMIC_I386_H
48 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
49 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE
56 #define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
57 #define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE
64 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
65 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
72 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
73 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE
80 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
81 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE
90 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
91 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
100 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
101 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE
103 template <
typename T>
106 template <
typename T>
110 #if defined(Q_CC_GNU) || defined(Q_CC_INTEL)
115 asm volatile(
"lock\n"
127 asm volatile(
"lock\n"
139 asm volatile(
"lock\n"
142 :
"=a" (newValue),
"=qm" (ret),
"+m" (
_q_value)
143 :
"r" (newValue),
"0" (expectedValue)
150 asm volatile(
"xchgl %0,%1"
159 asm volatile(
"lock\n"
161 :
"=r" (valueToAdd),
"+m" (
_q_value)
167 template <
typename T>
171 asm volatile(
"lock\n"
174 :
"=a" (newValue),
"=qm" (ret),
"+m" (_q_value)
175 :
"r" (newValue),
"0" (expectedValue)
180 template <
typename T>
183 asm volatile(
"xchgl %0,%1"
184 :
"=r" (newValue),
"+m" (_q_value)
190 template <
typename T>
193 asm volatile(
"lock\n"
195 :
"=r" (valueToAdd),
"+m" (_q_value)
196 :
"0" (valueToAdd *
sizeof(T))
198 return reinterpret_cast<T *
>(valueToAdd);
239 template <
typename T>
245 template <
typename T>
251 template <
typename T>
304 template <
typename T>
307 return testAndSetOrdered(expectedValue, newValue);
310 template <
typename T>
313 return testAndSetOrdered(expectedValue, newValue);
316 template <
typename T>
319 return testAndSetOrdered(expectedValue, newValue);
322 template <
typename T>
325 return fetchAndStoreOrdered(newValue);
328 template <
typename T>
331 return fetchAndStoreOrdered(newValue);
334 template <
typename T>
337 return fetchAndStoreOrdered(newValue);
340 template <
typename T>
343 return fetchAndAddOrdered(valueToAdd);
346 template <
typename T>
349 return fetchAndAddOrdered(valueToAdd);
352 template <
typename T>
355 return fetchAndAddOrdered(valueToAdd);
361 #endif // QATOMIC_I386_H
int fetchAndStoreRelaxed(int newValue)
bool testAndSetRelease(int expectedValue, int newValue)
static bool isFetchAndAddNative()
Q_CORE_EXPORT int q_atomic_increment(volatile int *ptr)
T * fetchAndAddAcquire(qptrdiff valueToAdd)
Q_CORE_EXPORT int q_atomic_test_and_set_int(volatile int *ptr, int expected, int newval)
T * fetchAndAddOrdered(qptrdiff valueToAdd)
Q_CORE_EXPORT void * q_atomic_fetch_and_add_ptr(volatile void *ptr, int value)
static bool isReferenceCountingNative()
int fetchAndAddRelaxed(int valueToAdd)
T * fetchAndStoreAcquire(T *newValue)
T * fetchAndAddRelease(qptrdiff valueToAdd)
int fetchAndAddAcquire(int valueToAdd)
static bool isReferenceCountingWaitFree()
T * fetchAndAddRelaxed(qptrdiff valueToAdd)
static bool isFetchAndAddNative()
bool testAndSetOrdered(T *expectedValue, T *newValue)
bool testAndSetAcquire(int expectedValue, int newValue)
Q_CORE_EXPORT int q_atomic_fetch_and_add_int(volatile int *ptr, int value)
static bool isFetchAndStoreNative()
#define QT_BEGIN_NAMESPACE
Q_CORE_EXPORT int q_atomic_test_and_set_ptr(volatile void *ptr, const void *expected, const void *newval)
static bool isTestAndSetNative()
static bool isTestAndSetNative()
static bool isFetchAndStoreNative()
T * fetchAndStoreRelaxed(T *newValue)
static bool isFetchAndAddWaitFree()
bool testAndSetRelaxed(int expectedValue, int newValue)
Q_CORE_EXPORT int q_atomic_decrement(volatile int *ptr)
T * fetchAndStoreRelease(T *newValue)
bool testAndSetRelease(T *expectedValue, T *newValue)
Q_CORE_EXPORT int q_atomic_set_int(volatile int *ptr, int newval)
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)
int fetchAndAddOrdered(int valueToAdd)
int fetchAndStoreOrdered(int newValue)
int fetchAndAddRelease(int valueToAdd)
int fetchAndStoreRelease(int newValue)