00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QATOMIC_POWERPC_H
00043 #define QATOMIC_POWERPC_H
00044
00045 QT_BEGIN_HEADER
00046
00047 QT_BEGIN_NAMESPACE
00048
00049 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
00050
00051 inline bool QBasicAtomicInt::isReferenceCountingNative()
00052 { return true; }
00053 inline bool QBasicAtomicInt::isReferenceCountingWaitFree()
00054 { return false; }
00055
00056 #define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
00057
00058 inline bool QBasicAtomicInt::isTestAndSetNative()
00059 { return true; }
00060 inline bool QBasicAtomicInt::isTestAndSetWaitFree()
00061 { return false; }
00062
00063 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
00064
00065 inline bool QBasicAtomicInt::isFetchAndStoreNative()
00066 { return true; }
00067 inline bool QBasicAtomicInt::isFetchAndStoreWaitFree()
00068 { return false; }
00069
00070 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
00071
00072 inline bool QBasicAtomicInt::isFetchAndAddNative()
00073 { return true; }
00074 inline bool QBasicAtomicInt::isFetchAndAddWaitFree()
00075 { return false; }
00076
00077 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
00078
00079 template <typename T>
00080 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
00081 { return true; }
00082 template <typename T>
00083 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
00084 { return false; }
00085
00086 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
00087
00088 template <typename T>
00089 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreNative()
00090 { return true; }
00091 template <typename T>
00092 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreWaitFree()
00093 { return false; }
00094
00095 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
00096
00097 template <typename T>
00098 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddNative()
00099 { return true; }
00100 template <typename T>
00101 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
00102 { return false; }
00103
00104 #if defined(Q_CC_GNU)
00105
00106 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) \
00107 || (!defined(__64BIT__) && !defined(__powerpc64__) && !defined(__ppc64__))
00108 # define _Q_VALUE "0, %[_q_value]"
00109 # define _Q_VALUE_MEMORY_OPERAND "+m" (_q_value)
00110 # define _Q_VALUE_REGISTER_OPERAND [_q_value] "r" (&_q_value),
00111 #else
00112
00113 # define _Q_VALUE "%y[_q_value]"
00114 # define _Q_VALUE_MEMORY_OPERAND [_q_value] "+Z" (_q_value)
00115 # define _Q_VALUE_REGISTER_OPERAND
00116 #endif
00117
00118 inline bool QBasicAtomicInt::ref()
00119 {
00120 register int originalValue;
00121 register int newValue;
00122 asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
00123 "addi %[newValue], %[originalValue], %[one]\n"
00124 "stwcx. %[newValue]," _Q_VALUE "\n"
00125 "bne- $-12\n"
00126 : [originalValue] "=&b" (originalValue),
00127 [newValue] "=&r" (newValue),
00128 _Q_VALUE_MEMORY_OPERAND
00129 : _Q_VALUE_REGISTER_OPERAND
00130 [one] "i" (1)
00131 : "cc", "memory");
00132 return newValue != 0;
00133 }
00134
00135 inline bool QBasicAtomicInt::deref()
00136 {
00137 register int originalValue;
00138 register int newValue;
00139 asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
00140 "addi %[newValue], %[originalValue], %[minusOne]\n"
00141 "stwcx. %[newValue]," _Q_VALUE "\n"
00142 "bne- $-12\n"
00143 : [originalValue] "=&b" (originalValue),
00144 [newValue] "=&r" (newValue),
00145 _Q_VALUE_MEMORY_OPERAND
00146 : _Q_VALUE_REGISTER_OPERAND
00147 [minusOne] "i" (-1)
00148 : "cc", "memory");
00149 return newValue != 0;
00150 }
00151
00152 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
00153 {
00154 register int result;
00155 asm volatile("lwarx %[result]," _Q_VALUE "\n"
00156 "xor. %[result], %[result], %[expectedValue]\n"
00157 "bne $+12\n"
00158 "stwcx. %[newValue]," _Q_VALUE "\n"
00159 "bne- $-16\n"
00160 : [result] "=&r" (result),
00161 _Q_VALUE_MEMORY_OPERAND
00162 : _Q_VALUE_REGISTER_OPERAND
00163 [expectedValue] "r" (expectedValue),
00164 [newValue] "r" (newValue)
00165 : "cc", "memory");
00166 return result == 0;
00167 }
00168
00169 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
00170 {
00171 register int result;
00172 asm volatile("lwarx %[result]," _Q_VALUE "\n"
00173 "xor. %[result], %[result], %[expectedValue]\n"
00174 "bne $+16\n"
00175 "stwcx. %[newValue]," _Q_VALUE "\n"
00176 "bne- $-16\n"
00177 "isync\n"
00178 : [result] "=&r" (result),
00179 _Q_VALUE_MEMORY_OPERAND
00180 : _Q_VALUE_REGISTER_OPERAND
00181 [expectedValue] "r" (expectedValue),
00182 [newValue] "r" (newValue)
00183 : "cc", "memory");
00184 return result == 0;
00185 }
00186
00187 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
00188 {
00189 register int result;
00190 asm volatile("eieio\n"
00191 "lwarx %[result]," _Q_VALUE "\n"
00192 "xor. %[result], %[result], %[expectedValue]\n"
00193 "bne $+12\n"
00194 "stwcx. %[newValue]," _Q_VALUE "\n"
00195 "bne- $-16\n"
00196 : [result] "=&r" (result),
00197 _Q_VALUE_MEMORY_OPERAND
00198 : _Q_VALUE_REGISTER_OPERAND
00199 [expectedValue] "r" (expectedValue),
00200 [newValue] "r" (newValue)
00201 : "cc", "memory");
00202 return result == 0;
00203 }
00204
00205 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
00206 {
00207 register int originalValue;
00208 asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
00209 "stwcx. %[newValue]," _Q_VALUE "\n"
00210 "bne- $-8\n"
00211 : [originalValue] "=&r" (originalValue),
00212 _Q_VALUE_MEMORY_OPERAND
00213 : _Q_VALUE_REGISTER_OPERAND
00214 [newValue] "r" (newValue)
00215 : "cc", "memory");
00216 return originalValue;
00217 }
00218
00219 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
00220 {
00221 register int originalValue;
00222 asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
00223 "stwcx. %[newValue]," _Q_VALUE "\n"
00224 "bne- $-8\n"
00225 "isync\n"
00226 : [originalValue] "=&r" (originalValue),
00227 _Q_VALUE_MEMORY_OPERAND
00228 : _Q_VALUE_REGISTER_OPERAND
00229 [newValue] "r" (newValue)
00230 : "cc", "memory");
00231 return originalValue;
00232 }
00233
00234 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
00235 {
00236 register int originalValue;
00237 asm volatile("eieio\n"
00238 "lwarx %[originalValue]," _Q_VALUE "\n"
00239 "stwcx. %[newValue]," _Q_VALUE "\n"
00240 "bne- $-8\n"
00241 : [originalValue] "=&r" (originalValue),
00242 _Q_VALUE_MEMORY_OPERAND
00243 : _Q_VALUE_REGISTER_OPERAND
00244 [newValue] "r" (newValue)
00245 : "cc", "memory");
00246 return originalValue;
00247 }
00248
00249 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
00250 {
00251 register int originalValue;
00252 register int newValue;
00253 asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
00254 "add %[newValue], %[originalValue], %[valueToAdd]\n"
00255 "stwcx. %[newValue]," _Q_VALUE "\n"
00256 "bne- $-12\n"
00257 : [originalValue] "=&r" (originalValue),
00258 [newValue] "=&r" (newValue),
00259 _Q_VALUE_MEMORY_OPERAND
00260 : _Q_VALUE_REGISTER_OPERAND
00261 [valueToAdd] "r" (valueToAdd)
00262 : "cc", "memory");
00263 return originalValue;
00264 }
00265
00266 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
00267 {
00268 register int originalValue;
00269 register int newValue;
00270 asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
00271 "add %[newValue], %[originalValue], %[valueToAdd]\n"
00272 "stwcx. %[newValue]," _Q_VALUE "\n"
00273 "bne- $-12\n"
00274 "isync\n"
00275 : [originalValue] "=&r" (originalValue),
00276 [newValue] "=&r" (newValue),
00277 _Q_VALUE_MEMORY_OPERAND
00278 : _Q_VALUE_REGISTER_OPERAND
00279 [valueToAdd] "r" (valueToAdd)
00280 : "cc", "memory");
00281 return originalValue;
00282 }
00283
00284 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
00285 {
00286 register int originalValue;
00287 register int newValue;
00288 asm volatile("eieio\n"
00289 "lwarx %[originalValue]," _Q_VALUE "\n"
00290 "add %[newValue], %[originalValue], %[valueToAdd]\n"
00291 "stwcx. %[newValue]," _Q_VALUE "\n"
00292 "bne- $-12\n"
00293 : [originalValue] "=&r" (originalValue),
00294 [newValue] "=&r" (newValue),
00295 _Q_VALUE_MEMORY_OPERAND
00296 : _Q_VALUE_REGISTER_OPERAND
00297 [valueToAdd] "r" (valueToAdd)
00298 : "cc", "memory");
00299 return originalValue;
00300 }
00301
00302 #if defined(__64BIT__) || defined(__powerpc64__) || defined(__ppc64__)
00303 # define LPARX "ldarx"
00304 # define STPCX "stdcx."
00305 #else
00306 # define LPARX "lwarx"
00307 # define STPCX "stwcx."
00308 #endif
00309
00310 template <typename T>
00311 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
00312 {
00313 register void *result;
00314 asm volatile(LPARX" %[result]," _Q_VALUE "\n"
00315 "xor. %[result], %[result], %[expectedValue]\n"
00316 "bne $+12\n"
00317 STPCX" %[newValue]," _Q_VALUE "\n"
00318 "bne- $-16\n"
00319 : [result] "=&r" (result),
00320 _Q_VALUE_MEMORY_OPERAND
00321 : _Q_VALUE_REGISTER_OPERAND
00322 [expectedValue] "r" (expectedValue),
00323 [newValue] "r" (newValue)
00324 : "cc", "memory");
00325 return result == 0;
00326 }
00327
00328 template <typename T>
00329 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
00330 {
00331 register void *result;
00332 asm volatile(LPARX" %[result]," _Q_VALUE "\n"
00333 "xor. %[result], %[result], %[expectedValue]\n"
00334 "bne $+16\n"
00335 STPCX" %[newValue]," _Q_VALUE "\n"
00336 "bne- $-16\n"
00337 "isync\n"
00338 : [result] "=&r" (result),
00339 _Q_VALUE_MEMORY_OPERAND
00340 : _Q_VALUE_REGISTER_OPERAND
00341 [expectedValue] "r" (expectedValue),
00342 [newValue] "r" (newValue)
00343 : "cc", "memory");
00344 return result == 0;
00345 }
00346
00347 template <typename T>
00348 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
00349 {
00350 register void *result;
00351 asm volatile("eieio\n"
00352 LPARX" %[result]," _Q_VALUE "\n"
00353 "xor. %[result], %[result], %[expectedValue]\n"
00354 "bne $+12\n"
00355 STPCX" %[newValue]," _Q_VALUE "\n"
00356 "bne- $-16\n"
00357 : [result] "=&r" (result),
00358 _Q_VALUE_MEMORY_OPERAND
00359 : _Q_VALUE_REGISTER_OPERAND
00360 [expectedValue] "r" (expectedValue),
00361 [newValue] "r" (newValue)
00362 : "cc", "memory");
00363 return result == 0;
00364 }
00365
00366 template <typename T>
00367 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
00368 {
00369 register T *originalValue;
00370 asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
00371 STPCX" %[newValue]," _Q_VALUE "\n"
00372 "bne- $-8\n"
00373 : [originalValue] "=&r" (originalValue),
00374 _Q_VALUE_MEMORY_OPERAND
00375 : _Q_VALUE_REGISTER_OPERAND
00376 [newValue] "r" (newValue)
00377 : "cc", "memory");
00378 return originalValue;
00379 }
00380
00381 template <typename T>
00382 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
00383 {
00384 register T *originalValue;
00385 asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
00386 STPCX" %[newValue]," _Q_VALUE "\n"
00387 "bne- $-8\n"
00388 "isync\n"
00389 : [originalValue] "=&r" (originalValue),
00390 _Q_VALUE_MEMORY_OPERAND
00391 : _Q_VALUE_REGISTER_OPERAND
00392 [newValue] "r" (newValue)
00393 : "cc", "memory");
00394 return originalValue;
00395 }
00396
00397 template <typename T>
00398 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
00399 {
00400 register T *originalValue;
00401 asm volatile("eieio\n"
00402 LPARX" %[originalValue]," _Q_VALUE "\n"
00403 STPCX" %[newValue]," _Q_VALUE "\n"
00404 "bne- $-8\n"
00405 : [originalValue] "=&r" (originalValue),
00406 _Q_VALUE_MEMORY_OPERAND
00407 : _Q_VALUE_REGISTER_OPERAND
00408 [newValue] "r" (newValue)
00409 : "cc", "memory");
00410 return originalValue;
00411 }
00412
00413 template <typename T>
00414 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
00415 {
00416 register T *originalValue;
00417 register T *newValue;
00418 asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
00419 "add %[newValue], %[originalValue], %[valueToAdd]\n"
00420 STPCX" %[newValue]," _Q_VALUE "\n"
00421 "bne- $-12\n"
00422 : [originalValue] "=&r" (originalValue),
00423 [newValue] "=&r" (newValue),
00424 _Q_VALUE_MEMORY_OPERAND
00425 : _Q_VALUE_REGISTER_OPERAND
00426 [valueToAdd] "r" (valueToAdd * sizeof(T))
00427 : "cc", "memory");
00428 return originalValue;
00429 }
00430
00431 template <typename T>
00432 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
00433 {
00434 register T *originalValue;
00435 register T *newValue;
00436 asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
00437 "add %[newValue], %[originalValue], %[valueToAdd]\n"
00438 STPCX" %[newValue]," _Q_VALUE "\n"
00439 "bne- $-12\n"
00440 "isync\n"
00441 : [originalValue] "=&r" (originalValue),
00442 [newValue] "=&r" (newValue),
00443 _Q_VALUE_MEMORY_OPERAND
00444 : _Q_VALUE_REGISTER_OPERAND
00445 [valueToAdd] "r" (valueToAdd * sizeof(T))
00446 : "cc", "memory");
00447 return originalValue;
00448 }
00449
00450 template <typename T>
00451 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
00452 {
00453 register T *originalValue;
00454 register T *newValue;
00455 asm volatile("eieio\n"
00456 LPARX" %[originalValue]," _Q_VALUE "\n"
00457 "add %[newValue], %[originalValue], %[valueToAdd]\n"
00458 STPCX" %[newValue]," _Q_VALUE "\n"
00459 "bne- $-12\n"
00460 : [originalValue] "=&r" (originalValue),
00461 [newValue] "=&r" (newValue),
00462 _Q_VALUE_MEMORY_OPERAND
00463 : _Q_VALUE_REGISTER_OPERAND
00464 [valueToAdd] "r" (valueToAdd * sizeof(T))
00465 : "cc", "memory");
00466 return originalValue;
00467 }
00468
00469 #undef LPARX
00470 #undef STPCX
00471 #undef _Q_VALUE
00472 #undef _Q_VALUE_MEMORY_OPERAND
00473 #undef _Q_VALUE_REGISTER_OPERAND
00474
00475 #else
00476
00477 extern "C" {
00478 int q_atomic_test_and_set_int(volatile int *ptr, int expectedValue, int newValue);
00479 int q_atomic_test_and_set_acquire_int(volatile int *ptr, int expectedValue, int newValue);
00480 int q_atomic_test_and_set_release_int(volatile int *ptr, int expectedValue, int newValue);
00481 int q_atomic_test_and_set_ptr(volatile void *ptr, void *expectedValue, void *newValue);
00482 int q_atomic_test_and_set_acquire_ptr(volatile void *ptr, void *expectedValue, void *newValue);
00483 int q_atomic_test_and_set_release_ptr(volatile void *ptr, void *expectedValue, void *newValue);
00484 int q_atomic_increment(volatile int *);
00485 int q_atomic_decrement(volatile int *);
00486 int q_atomic_set_int(volatile int *, int);
00487 int q_atomic_fetch_and_store_acquire_int(volatile int *ptr, int newValue);
00488 int q_atomic_fetch_and_store_release_int(volatile int *ptr, int newValue);
00489 void *q_atomic_set_ptr(volatile void *, void *);
00490 int q_atomic_fetch_and_store_acquire_ptr(volatile void *ptr, void *newValue);
00491 int q_atomic_fetch_and_store_release_ptr(volatile void *ptr, void *newValue);
00492 int q_atomic_fetch_and_add_int(volatile int *ptr, int valueToAdd);
00493 int q_atomic_fetch_and_add_acquire_int(volatile int *ptr, int valueToAdd);
00494 int q_atomic_fetch_and_add_release_int(volatile int *ptr, int valueToAdd);
00495 void *q_atomic_fetch_and_add_ptr(volatile void *ptr, qptrdiff valueToAdd);
00496 void *q_atomic_fetch_and_add_acquire_ptr(volatile void *ptr, qptrdiff valueToAdd);
00497 void *q_atomic_fetch_and_add_release_ptr(volatile void *ptr, qptrdiff valueToAdd);
00498 }
00499
00500
00501 inline bool QBasicAtomicInt::ref()
00502 {
00503 return q_atomic_increment(&_q_value) != 0;
00504 }
00505
00506 inline bool QBasicAtomicInt::deref()
00507 {
00508 return q_atomic_decrement(&_q_value) != 0;
00509 }
00510
00511 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
00512 {
00513 return q_atomic_test_and_set_int(&_q_value, expectedValue, newValue) != 0;
00514 }
00515
00516 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
00517 {
00518 return q_atomic_test_and_set_acquire_int(&_q_value, expectedValue, newValue) != 0;
00519 }
00520
00521 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
00522 {
00523 return q_atomic_test_and_set_release_int(&_q_value, expectedValue, newValue) != 0;
00524 }
00525
00526 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
00527 {
00528 return q_atomic_set_int(&_q_value, newValue);
00529 }
00530
00531 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
00532 {
00533 return q_atomic_fetch_and_store_acquire_int(&_q_value, newValue);
00534 }
00535
00536 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
00537 {
00538 return q_atomic_fetch_and_store_release_int(&_q_value, newValue);
00539 }
00540
00541 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
00542 {
00543 return q_atomic_fetch_and_add_int(&_q_value, valueToAdd);
00544 }
00545
00546 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
00547 {
00548 return q_atomic_fetch_and_add_acquire_int(&_q_value, valueToAdd);
00549 }
00550
00551 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
00552 {
00553 return q_atomic_fetch_and_add_release_int(&_q_value, valueToAdd);
00554 }
00555
00556 template <typename T>
00557 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
00558 {
00559 return q_atomic_test_and_set_ptr(&_q_value, expectedValue, newValue) != 0;
00560 }
00561
00562 template <typename T>
00563 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
00564 {
00565 return q_atomic_test_and_set_acquire_ptr(&_q_value, expectedValue, newValue) != 0;
00566 }
00567
00568 template <typename T>
00569 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
00570 {
00571 return q_atomic_test_and_set_release_ptr(&_q_value, expectedValue, newValue) != 0;
00572 }
00573
00574 template <typename T>
00575 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
00576 {
00577 return reinterpret_cast<T *>(q_atomic_set_ptr(&_q_value, newValue));
00578 }
00579
00580 template <typename T>
00581 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
00582 {
00583 return reinterpret_cast<T *>(q_atomic_fetch_and_store_acquire_ptr(&_q_value, newValue));
00584 }
00585
00586 template <typename T>
00587 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
00588 {
00589 return reinterpret_cast<T *>(q_atomic_fetch_and_store_release_ptr(&_q_value, newValue));
00590 }
00591
00592 template <typename T>
00593 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
00594 {
00595 return reinterpret_cast<T *>(q_atomic_fetch_and_add_ptr(&_q_value, valueToAdd * sizeof(T)));
00596 }
00597 template <typename T>
00598 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
00599 {
00600 return reinterpret_cast<T *>(q_atomic_fetch_and_add_acquire_ptr(&_q_value, valueToAdd * sizeof(T)));
00601 }
00602
00603 template <typename T>
00604 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
00605 {
00606 return reinterpret_cast<T *>(q_atomic_fetch_and_add_release_ptr(&_q_value, valueToAdd * sizeof(T)));
00607 }
00608
00609 #endif
00610
00611 inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
00612 {
00613 return testAndSetAcquire(expectedValue, newValue);
00614 }
00615
00616 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
00617 {
00618 return fetchAndStoreAcquire(newValue);
00619 }
00620
00621 inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
00622 {
00623 return fetchAndAddAcquire(valueToAdd);
00624 }
00625
00626 template <typename T>
00627 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
00628 {
00629 return testAndSetAcquire(expectedValue, newValue);
00630 }
00631
00632 template <typename T>
00633 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
00634 {
00635 return fetchAndStoreAcquire(newValue);
00636 }
00637
00638 template <typename T>
00639 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
00640 {
00641 return fetchAndAddAcquire(valueToAdd);
00642 }
00643
00644 QT_END_NAMESPACE
00645
00646 QT_END_HEADER
00647
00648 #endif // QATOMIC_POWERPC_H