- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qatomic_avr32.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtCore module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QATOMIC_AVR32_H
    00043 #define QATOMIC_AVR32_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 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
    00065
    00066 inline bool QBasicAtomicInt::isFetchAndStoreNative()
    00067 { return true; }
    00068 inline bool QBasicAtomicInt::isFetchAndStoreWaitFree()
    00069 { return true; }
    00070
    00071 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
    00072
    00073 inline bool QBasicAtomicInt::isFetchAndAddNative()
    00074 { return true; }
    00075 inline bool QBasicAtomicInt::isFetchAndAddWaitFree()
    00076 { return false; }
    00077
    00078 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
    00079
    00080 template <typename T>
    00081 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
    00082 { return true; }
    00083 template <typename T>
    00084 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
    00085 { return false; }
    00086
    00087 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
    00088 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
    00089
    00090 template <typename T>
    00091 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreNative()
    00092 { return true; }
    00093 template <typename T>
    00094 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreWaitFree()
    00095 { return true; }
    00096
    00097 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
    00098
    00099 template <typename T>
    00100 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddNative()
    00101 { return true; }
    00102 template <typename T>
    00103 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
    00104 { return false; }
    00105
    00106 inline bool QBasicAtomicInt::ref()
    00107 {
    00108     return __sync_add_and_fetch(&_q_value, 1);
    00109 }
    00110
    00111 inline bool QBasicAtomicInt::deref()
    00112 {
    00113     return __sync_sub_and_fetch(&_q_value, 1);
    00114 }
    00115
    00116 inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
    00117 {
    00118     return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue);
    00119 }
    00120
    00121 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
    00122 {
    00123     return testAndSetOrdered(expectedValue, newValue);
    00124 }
    00125
    00126 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
    00127 {
    00128     return testAndSetOrdered(expectedValue, newValue);
    00129 }
    00130
    00131 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
    00132 {
    00133     return testAndSetOrdered(expectedValue, newValue);
    00134 }
    00135
    00136 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
    00137 {
    00138     return __sync_lock_test_and_set(&_q_value, newValue);
    00139 }
    00140
    00141 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
    00142 {
    00143     return fetchAndStoreOrdered(newValue);
    00144 }
    00145
    00146 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
    00147 {
    00148     return fetchAndStoreOrdered(newValue);
    00149 }
    00150
    00151 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
    00152 {
    00153     return fetchAndStoreOrdered(newValue);
    00154 }
    00155
    00156 inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
    00157 {
    00158     return __sync_fetch_and_add(&_q_value, valueToAdd);
    00159 }
    00160
    00161 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
    00162 {
    00163     return fetchAndAddOrdered(valueToAdd);
    00164 }
    00165
    00166 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
    00167 {
    00168     return fetchAndAddOrdered(valueToAdd);
    00169 }
    00170
    00171 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
    00172 {
    00173     return fetchAndAddOrdered(valueToAdd);
    00174 }
    00175
    00176 template <typename T>
    00177 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
    00178 {
    00179     return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue);
    00180 }
    00181
    00182 template <typename T>
    00183 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
    00184 {
    00185     return testAndSetOrdered(expectedValue, newValue);
    00186 }
    00187
    00188 template <typename T>
    00189 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
    00190 {
    00191     return testAndSetOrdered(expectedValue, newValue);
    00192 }
    00193
    00194 template <typename T>
    00195 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
    00196 {
    00197     return testAndSetOrdered(expectedValue, newValue);
    00198 }
    00199
    00200 template <typename T>
    00201 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
    00202 {
    00203     return __sync_lock_test_and_set(&_q_value, newValue);
    00204 }
    00205
    00206 template <typename T>
    00207 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
    00208 {
    00209     return fetchAndStoreOrdered(newValue);
    00210 }
    00211
    00212 template <typename T>
    00213 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
    00214 {
    00215     return fetchAndStoreOrdered(newValue);
    00216 }
    00217
    00218 template <typename T>
    00219 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
    00220 {
    00221     return fetchAndStoreOrdered(newValue);
    00222 }
    00223
    00224 template <typename T>
    00225 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
    00226 {
    00227     return __sync_fetch_and_add(&_q_value, valueToAdd * sizeof(T));
    00228 }
    00229
    00230 template <typename T>
    00231 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
    00232 {
    00233     return fetchAndAddOrdered(valueToAdd);
    00234 }
    00235
    00236 template <typename T>
    00237 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
    00238 {
    00239     return fetchAndAddOrdered(valueToAdd);
    00240 }
    00241
    00242 template <typename T>
    00243 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
    00244 {
    00245     return fetchAndAddOrdered(valueToAdd);
    00246 }
    00247
    00248 QT_END_NAMESPACE
    00249
    00250 QT_END_HEADER
    00251
    00252 #endif // QATOMIC_AVR32_H