42 #ifndef QATOMIC_WINDOWS_H 43 #define QATOMIC_WINDOWS_H 50 # include "QtCore/qatomic_i386.h" 52 # include "QtCore/qatomic_x86_64.h" 62 # define QT_INTERLOCKED_PREFIX _ 63 # define QT_INTERLOCKED_PROTOTYPE __cdecl 64 # define QT_INTERLOCKED_DECLARE_PROTOTYPES 65 # define QT_INTERLOCKED_INTRINSIC 69 # if _WIN32_WCE < 0x600 && defined(_X86_) 77 # define QT_INTERLOCKED_NO_VOLATILE 79 # else // _WIN32_WCE >= 0x600 || !_X86_ 81 # define QT_INTERLOCKED_PROTOTYPE __cdecl 82 # define QT_INTERLOCKED_DECLARE_PROTOTYPES 84 # if _WIN32_WCE >= 0x600 86 # define QT_INTERLOCKED_PREFIX _ 87 # define QT_INTERLOCKED_INTRINSIC 90 # define QT_INTERLOCKED_NO_VOLATILE 93 # endif // _WIN32_WCE >= 0x600 || !_X86_ 100 #define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \ 102 #define QT_INTERLOCKED_CONCAT(prefix, suffix) \ 103 QT_INTERLOCKED_CONCAT_I(prefix, suffix) 110 #define QT_INTERLOCKED_FUNCTION(name) \ 111 QT_INTERLOCKED_CONCAT( \ 112 QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, Interlocked), name) 114 #ifdef QT_INTERLOCKED_NO_VOLATILE 115 # define QT_INTERLOCKED_VOLATILE 116 # define QT_INTERLOCKED_REMOVE_VOLATILE(a) qt_interlocked_remove_volatile(a) 118 # define QT_INTERLOCKED_VOLATILE volatile 119 # define QT_INTERLOCKED_REMOVE_VOLATILE(a) a 122 #ifndef QT_INTERLOCKED_PREFIX 123 #define QT_INTERLOCKED_PREFIX 126 #ifndef QT_INTERLOCKED_PROTOTYPE 127 #define QT_INTERLOCKED_PROTOTYPE 130 #ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES 131 #undef QT_INTERLOCKED_DECLARE_PROTOTYPES 135 long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment )(
long QT_INTERLOCKED_VOLATILE *);
136 long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement )(
long QT_INTERLOCKED_VOLATILE *);
137 long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange )(
long QT_INTERLOCKED_VOLATILE *, long, long);
138 long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(
long QT_INTERLOCKED_VOLATILE *, long);
139 long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(
long QT_INTERLOCKED_VOLATILE *, long);
141 # if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) 142 void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(
void * QT_INTERLOCKED_VOLATILE *,
void *,
void *);
143 void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(
void * QT_INTERLOCKED_VOLATILE *,
void *);
144 __int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
149 #endif // QT_INTERLOCKED_DECLARE_PROTOTYPES 151 #undef QT_INTERLOCKED_PROTOTYPE 155 #ifdef QT_INTERLOCKED_INTRINSIC 156 #undef QT_INTERLOCKED_INTRINSIC 158 # pragma intrinsic (_InterlockedIncrement) 159 # pragma intrinsic (_InterlockedDecrement) 160 # pragma intrinsic (_InterlockedExchange) 161 # pragma intrinsic (_InterlockedCompareExchange) 162 # pragma intrinsic (_InterlockedExchangeAdd) 164 # if !defined(Q_OS_WINCE) && !defined(_M_IX86) 165 # pragma intrinsic (_InterlockedCompareExchangePointer) 166 # pragma intrinsic (_InterlockedExchangePointer) 167 # pragma intrinsic (_InterlockedExchangeAdd64) 170 #endif // QT_INTERLOCKED_INTRINSIC 175 #define QT_INTERLOCKED_INCREMENT(value) \ 176 QT_INTERLOCKED_FUNCTION( Increment )( \ 177 QT_INTERLOCKED_REMOVE_VOLATILE( value ) ) 179 #define QT_INTERLOCKED_DECREMENT(value) \ 180 QT_INTERLOCKED_FUNCTION( Decrement )( \ 181 QT_INTERLOCKED_REMOVE_VOLATILE( value ) ) 183 #define QT_INTERLOCKED_COMPARE_EXCHANGE(value, newValue, expectedValue) \ 184 QT_INTERLOCKED_FUNCTION( CompareExchange )( \ 185 QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ 189 #define QT_INTERLOCKED_EXCHANGE(value, newValue) \ 190 QT_INTERLOCKED_FUNCTION( Exchange )( \ 191 QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ 194 #define QT_INTERLOCKED_EXCHANGE_ADD(value, valueToAdd) \ 195 QT_INTERLOCKED_FUNCTION( ExchangeAdd )( \ 196 QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ 199 #if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86) 201 # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ 202 reinterpret_cast<void *>( \ 203 QT_INTERLOCKED_FUNCTION( CompareExchange )( \ 204 QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ 205 (long)( newValue ), \ 206 (long)( expectedValue ) )) 208 # define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ 209 QT_INTERLOCKED_FUNCTION( Exchange )( \ 210 QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ 211 (quintptr)( newValue ) ) 213 # define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ 214 QT_INTERLOCKED_FUNCTION( ExchangeAdd )( \ 215 QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ 218 #else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) 220 # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ 221 QT_INTERLOCKED_FUNCTION( CompareExchangePointer )( \ 222 reinterpret_cast<void * QT_INTERLOCKED_VOLATILE *>( QT_INTERLOCKED_REMOVE_VOLATILE( value ) ), \ 226 # define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ 227 QT_INTERLOCKED_FUNCTION( ExchangePointer )( \ 228 reinterpret_cast<void * QT_INTERLOCKED_VOLATILE *>( QT_INTERLOCKED_REMOVE_VOLATILE( value ) ), \ 231 # define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ 232 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )( \ 233 QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ 236 #endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) 244 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE 245 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE 252 #define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE 253 #define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE 260 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE 261 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE 268 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE 269 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE 276 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE 277 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE 279 template <
typename T>
282 template <
typename T>
286 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE 287 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE 289 template <
typename T>
292 template <
typename T>
296 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE 297 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE 298 template <
typename T>
301 template <
typename T>
307 #ifdef QT_INTERLOCKED_NO_VOLATILE 311 return const_cast<T *
>(t);
313 #endif // !QT_INTERLOCKED_NO_VOLATILE 319 return QT_INTERLOCKED_INCREMENT(&
_q_value) != 0;
324 return QT_INTERLOCKED_DECREMENT(&
_q_value) != 0;
329 return QT_INTERLOCKED_COMPARE_EXCHANGE(&
_q_value, newValue, expectedValue)
335 return QT_INTERLOCKED_EXCHANGE(&
_q_value, newValue);
340 return QT_INTERLOCKED_EXCHANGE_ADD(&
_q_value, valueToAdd);
345 template <
typename T>
348 return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&
_q_value, newValue, expectedValue)
352 template <
typename T>
355 return reinterpret_cast<T *
>(
356 QT_INTERLOCKED_EXCHANGE_POINTER(&
_q_value, newValue));
359 template <
typename T>
362 return reinterpret_cast<T *
>(
363 QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&
_q_value, valueToAdd *
sizeof(T)));
415 template <
typename T>
421 template <
typename T>
427 template <
typename T>
433 template <
typename T>
439 template <
typename T>
445 template <
typename T>
451 template <
typename T>
457 template <
typename T>
463 template <
typename T>
472 #undef QT_INTERLOCKED_CONCAT_I 473 #undef QT_INTERLOCKED_CONCAT 474 #undef QT_INTERLOCKED_FUNCTION 475 #undef QT_INTERLOCKED_PREFIX 477 #undef QT_INTERLOCKED_NO_VOLATILE 478 #undef QT_INTERLOCKED_VOLATILE 479 #undef QT_INTERLOCKED_REMOVE_VOLATILE 481 #undef QT_INTERLOCKED_INCREMENT 482 #undef QT_INTERLOCKED_DECREMENT 483 #undef QT_INTERLOCKED_COMPARE_EXCHANGE 484 #undef QT_INTERLOCKED_EXCHANGE 485 #undef QT_INTERLOCKED_EXCHANGE_ADD 486 #undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER 487 #undef QT_INTERLOCKED_EXCHANGE_POINTER 488 #undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER 496 #endif // QATOMIC_WINDOWS_H static bool isFetchAndStoreNative()
static bool isTestAndSetNative()
int fetchAndStoreRelease(int newValue)
static bool isReferenceCountingNative()
T * fetchAndAddRelaxed(qptrdiff valueToAdd)
#define QT_END_NAMESPACE
This macro expands to.
static bool isFetchAndAddNative()
static bool isTestAndSetNative()
static bool isFetchAndAddNative()
T * fetchAndStoreRelease(T *newValue)
static bool isTestAndSetWaitFree()
T * fetchAndAddRelease(qptrdiff valueToAdd)
bool testAndSetOrdered(T *expectedValue, T *newValue)
int fetchAndAddAcquire(int valueToAdd)
T * fetchAndAddAcquire(qptrdiff valueToAdd)
int fetchAndStoreRelaxed(int newValue)
T * fetchAndAddOrdered(qptrdiff valueToAdd)
bool testAndSetAcquire(int expectedValue, int newValue)
bool testAndSetRelaxed(int expectedValue, int newValue)
#define QT_BEGIN_NAMESPACE
This macro expands to.
int fetchAndStoreAcquire(int newValue)
QIntegerForSizeof< void * >::Signed qptrdiff
T * fetchAndStoreOrdered(T *newValue)
#define Q_INLINE_TEMPLATE
int fetchAndAddRelease(int valueToAdd)
bool testAndSetOrdered(int expectedValue, int newValue)
T * fetchAndStoreAcquire(T *newValue)
static bool isFetchAndStoreWaitFree()
static bool isTestAndSetWaitFree()
static bool isReferenceCountingWaitFree()
int fetchAndAddOrdered(int valueToAdd)
static bool isFetchAndStoreWaitFree()
static bool isFetchAndAddWaitFree()
static bool isFetchAndAddWaitFree()
bool testAndSetRelease(int expectedValue, int newValue)
int fetchAndAddRelaxed(int valueToAdd)
int fetchAndStoreOrdered(int newValue)
bool testAndSetRelaxed(T *expectedValue, T *newValue)
bool testAndSetRelease(T *expectedValue, T *newValue)
T * fetchAndStoreRelaxed(T *newValue)
static bool isFetchAndStoreNative()
bool testAndSetAcquire(T *expectedValue, T *newValue)