QtCore/qatomic_symbian.h Source File

qatomic_symbian.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QATOMIC_SYMBIAN_H
43 #define QATOMIC_SYMBIAN_H
44 
45 #include <QtCore/qglobal.h>
46 #include <e32std.h>
47 
49 
51 
52 QT_MODULE(Core)
53 
54 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
55 
57 { return false; }
58 
59 #define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE
60 
62 { return false; }
63 
64 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
65 
67 { return false; }
68 
69 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
70 
72 { return false; }
73 
74 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE
75 
76 Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative();
77 template <typename T>
78 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
80 template <typename T>
81 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
82 { return false; }
83 
84 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
85 
87 template <typename T>
88 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreNative()
90 template <typename T>
92 { return false; }
93 
94 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
95 
96 Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative();
97 template <typename T>
98 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddNative()
100 template <typename T>
101 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
102 { return false; }
103 
104 Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int);
105 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int);
106 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int);
107 Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetRelaxed(volatile int *, int, int);
108 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *, int);
109 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *, int);
110 Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetAcquire(volatile int *, int, int);
111 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *, int);
112 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddAcquire(volatile int *, int);
113 Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetRelease(volatile int *, int, int);
114 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreRelease(volatile int *, int);
115 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddRelease(volatile int *, int);
116 
117 Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *);
118 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *);
119 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff);
120 Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetRelaxed(void * volatile *, void *, void *);
121 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreRelaxed(void * volatile *, void *);
122 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddRelaxed(void * volatile *, qptrdiff);
123 Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetAcquire(void * volatile *, void *, void *);
124 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreAcquire(void * volatile *, void *);
125 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddAcquire(void * volatile *, qptrdiff);
126 Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetRelease(void * volatile *, void *, void *);
127 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreRelease(void * volatile *, void *);
128 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddRelease(void * volatile *, qptrdiff);
129 
130 // Reference counting
131 
132 //LockedInc and LockedDec are machine coded for ARMv6 (and future proof)
133 inline bool QBasicAtomicInt::ref()
134 {
135  int original = User::LockedInc((TInt&)_q_value);
136  return original != -1;
137 }
138 
139 inline bool QBasicAtomicInt::deref()
140 {
141  int original = User::LockedDec((TInt&)_q_value);
142  return original != 1;
143 }
144 
145 // Test and set for integers
146 
147 inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
148 {
149  return QBasicAtomicInt_testAndSetOrdered(&_q_value, expectedValue, newValue);
150 }
151 
152 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
153 {
154  return QBasicAtomicInt_testAndSetRelaxed(&_q_value, expectedValue, newValue);
155 }
156 
157 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
158 {
159  return QBasicAtomicInt_testAndSetAcquire(&_q_value, expectedValue, newValue);
160 }
161 
162 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
163 {
164  return QBasicAtomicInt_testAndSetRelease(&_q_value, expectedValue, newValue);
165 }
166 
167 // Fetch and store for integers
168 
169 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
170 {
172 }
173 
174 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
175 {
177 }
178 
179 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
180 {
182 }
183 
184 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
185 {
187 }
188 
189 // Fetch and add for integers
190 
191 inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
192 {
193  return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, valueToAdd);
194 }
195 
196 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
197 {
198  return QBasicAtomicInt_fetchAndAddRelaxed(&_q_value, valueToAdd);
199 }
200 
201 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
202 {
203  return QBasicAtomicInt_fetchAndAddAcquire(&_q_value, valueToAdd);
204 }
205 
206 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
207 {
208  return QBasicAtomicInt_fetchAndAddRelease(&_q_value, valueToAdd);
209 }
210 
211 // Test and set for pointers
212 
213 template <typename T>
214 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
215 {
216  return QBasicAtomicPointer_testAndSetOrdered(reinterpret_cast<void * volatile *>(&_q_value),
217  expectedValue, newValue);
218 }
219 
220 template <typename T>
221 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
222 {
223  return QBasicAtomicPointer_testAndSetRelaxed(reinterpret_cast<void * volatile *>(&_q_value),
224  expectedValue, newValue);
225 }
226 
227 template <typename T>
228 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
229 {
230  return QBasicAtomicPointer_testAndSetAcquire(reinterpret_cast<void * volatile *>(&_q_value),
231  expectedValue, newValue);
232 }
233 
234 template <typename T>
235 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
236 {
237  return QBasicAtomicPointer_testAndSetRelease(reinterpret_cast<void * volatile *>(&_q_value),
238  expectedValue, newValue);
239 }
240 
241 // Fetch and store for pointers
242 
243 template <typename T>
244 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
245 {
246  return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreOrdered(
247  reinterpret_cast<void * volatile *>(&_q_value)
248  , newValue));
249 }
250 
251 template <typename T>
252 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
253 {
254  return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreRelaxed(
255  reinterpret_cast<void * volatile *>(&_q_value)
256  , newValue));
257 }
258 
259 template <typename T>
260 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
261 {
262  return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreAcquire(
263  reinterpret_cast<void * volatile *>(&_q_value)
264  , newValue));
265 }
266 
267 template <typename T>
268 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
269 {
270  return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreRelease(
271  reinterpret_cast<void * volatile *>(&_q_value)
272  , newValue));
273 }
274 
275 // Fetch and add for pointers
276 
277 template <typename T>
278 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
279 {
280  return static_cast<T*>(QBasicAtomicPointer_fetchAndAddOrdered(
281  reinterpret_cast<void * volatile *>(&_q_value),
282  valueToAdd * sizeof(T)));
283 }
284 
285 template <typename T>
286 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
287 {
288  return static_cast<T*>(QBasicAtomicPointer_fetchAndAddRelaxed(
289  reinterpret_cast<void * volatile *>(&_q_value),
290  valueToAdd * sizeof(T)));
291 }
292 
293 template <typename T>
294 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
295 {
296  return static_cast<T*>(QBasicAtomicPointer_fetchAndAddAcquire(
297  reinterpret_cast<void * volatile *>(&_q_value),
298  valueToAdd * sizeof(T)));
299 }
300 
301 template <typename T>
302 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
303 {
304  return static_cast<T*>(QBasicAtomicPointer_fetchAndAddRelease(
305  reinterpret_cast<void * volatile *>(&_q_value),
306  valueToAdd * sizeof(T)));
307 }
308 
310 
312 
313 #endif // QATOMIC_SYMBIAN_H
int fetchAndStoreRelaxed(int newValue)
bool testAndSetRelease(int expectedValue, int newValue)
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddRelease(volatile int *, int)
#define QT_END_NAMESPACE
Definition: qglobal.h:128
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreRelaxed(volatile int *, int)
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int)
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndStoreRelease(void *volatile *, void *)
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndStoreRelaxed(void *volatile *, void *)
Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetRelease(void *volatile *, void *, void *)
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddRelaxed(volatile int *, int)
T * fetchAndAddAcquire(qptrdiff valueToAdd)
T * fetchAndAddOrdered(qptrdiff valueToAdd)
Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetRelease(volatile int *, int, int)
int fetchAndAddRelaxed(int valueToAdd)
Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int)
Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetRelaxed(volatile int *, int, int)
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddAcquire(volatile int *, int)
T * fetchAndStoreAcquire(T *newValue)
T * fetchAndAddRelease(qptrdiff valueToAdd)
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreAcquire(volatile int *, int)
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndStoreOrdered(void *volatile *, void *)
int fetchAndAddAcquire(int valueToAdd)
static bool isReferenceCountingWaitFree()
Definition: qatomic_alpha.h:53
T * fetchAndAddRelaxed(qptrdiff valueToAdd)
static bool isFetchAndAddNative()
Definition: qatomic_alpha.h:98
bool testAndSetOrdered(T *expectedValue, T *newValue)
bool testAndSetAcquire(int expectedValue, int newValue)
static bool isFetchAndStoreNative()
Definition: qatomic_alpha.h:89
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int)
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
static bool isTestAndSetNative()
Definition: qatomic_alpha.h:80
T * fetchAndStoreRelaxed(T *newValue)
Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreRelease(volatile int *, int)
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndAddOrdered(void *volatile *, qptrdiff)
static bool isFetchAndAddWaitFree()
bool testAndSetRelaxed(int expectedValue, int newValue)
Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void *volatile *, void *, void *)
volatile long _q_value
Definition: qbasicatomic.h:61
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndStoreAcquire(void *volatile *, void *)
T * fetchAndStoreRelease(T *newValue)
bool testAndSetRelease(T *expectedValue, T *newValue)
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndAddRelaxed(void *volatile *, qptrdiff)
static bool isFetchAndStoreWaitFree()
Definition: qatomic_alpha.h:92
static bool isTestAndSetWaitFree()
Definition: qatomic_alpha.h:60
Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetAcquire(void *volatile *, void *, void *)
bool testAndSetAcquire(T *expectedValue, T *newValue)
Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative()
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndAddRelease(void *volatile *, qptrdiff)
static bool isFetchAndAddWaitFree()
Definition: qatomic_alpha.h:74
T * fetchAndStoreOrdered(T *newValue)
static bool isFetchAndStoreWaitFree()
Definition: qatomic_alpha.h:67
Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetRelaxed(void *volatile *, void *, void *)
bool testAndSetRelaxed(T *expectedValue, T *newValue)
int fetchAndStoreAcquire(int newValue)
Q_CORE_EXPORT void * QBasicAtomicPointer_fetchAndAddAcquire(void *volatile *, qptrdiff)
static bool isTestAndSetWaitFree()
Definition: qatomic_alpha.h:83
bool testAndSetOrdered(int expectedValue, int newValue)
Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative()
Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetAcquire(volatile int *, int, int)
#define QT_END_HEADER
Definition: qglobal.h:142
int fetchAndAddOrdered(int valueToAdd)
int fetchAndStoreOrdered(int newValue)
Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative()
int fetchAndAddRelease(int valueToAdd)
int fetchAndStoreRelease(int newValue)