Qt 4.8
qatomic_bfin.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_BFIN_H
43 #define QATOMIC_BFIN_H
44 
46 
48 
49 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_NOT_NATIVE
50 
52 { return false; }
54 { return false; }
55 
56 #define Q_ATOMIC_INT_TEST_AND_SET_IS_NOT_NATIVE
57 
59 { return false; }
61 { return false; }
62 
63 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_NOT_NATIVE
64 
66 { return false; }
68 { return false; }
69 
70 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_NOT_NATIVE
71 
73 { return false; }
75 { return false; }
76 
77 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_NOT_NATIVE
78 
79 template <typename T>
81 { return false; }
82 template <typename T>
84 { return false; }
85 
86 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_NOT_NATIVE
87 
88 template <typename T>
90 { return false; }
91 template <typename T>
93 { return false; }
94 
95 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_NOT_NATIVE
96 
97 template <typename T>
99 { return false; }
100 template <typename T>
102 { return false; }
103 
104 #if defined(Q_OS_LINUX) && defined(Q_CC_GNU)
105 
107 #include <asm/fixed_code.h>
109 
110 inline bool QBasicAtomicInt::ref()
111 {
112  int ret;
113  asm volatile("R0 = 1;\n\t"
114  "P0 = %3;\n\t"
115  "CALL (%2);\n\t"
116  "%0 = R0;"
117  : "=da" (ret), "=m" (_q_value)
118  : "a" (ATOMIC_ADD32), "da" (&_q_value), "m" (_q_value)
119  : "R0", "R1", "P0", "RETS", "memory");
120  return ret != 0;
121 }
122 
123 inline bool QBasicAtomicInt::deref()
124 {
125  int ret;
126  asm volatile("R0 = 1;\n\t"
127  "P0 = %3;\n\t"
128  "CALL (%2);\n\t"
129  "%0 = R0;"
130  : "=da" (ret), "=m" (_q_value)
131  : "a" (ATOMIC_SUB32), "da" (&_q_value), "m" (_q_value)
132  : "R0", "R1", "P0", "RETS", "memory");
133  return ret != 0;
134 }
135 
136 inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
137 {
138  long int readval;
139  asm volatile ("P0 = %2;\n\t"
140  "R1 = %3;\n\t"
141  "R2 = %4;\n\t"
142  "CALL (%5);\n\t"
143  "%0 = R0;\n\t"
144  : "=da" (readval), "=m" (_q_value)
145  : "da" (&_q_value),
146  "da" (expectedValue),
147  "da" (newValue),
148  "a" (ATOMIC_CAS32),
149  "m" (_q_value)
150  : "P0", "R0", "R1", "R2", "RETS", "memory", "cc");
151  return readval == expectedValue;
152 }
153 
154 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
155 {
156  asm volatile("R1 = %2;\n\t"
157  "P0 = %4;\n\t"
158  "CALL (%3);\n\t"
159  "%0 = R0;"
160  : "=da" (newValue), "=m" (_q_value)
161  : "da" (newValue), "a" (ATOMIC_XCHG32), "da" (&_q_value), "m" (_q_value)
162  : "R0", "R1", "P0", "RETS", "memory");
163  return newValue;
164 }
165 
166 inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
167 {
168  int ret;
169  asm volatile("R0 = %[val];\n\t"
170  "P0 = %[qvalp];\n\t"
171  "CALL (%[addr]);\n\t"
172  "%[ret] = R1;"
173  : [ret] "=da" (ret), "=m" (_q_value)
174  : [addr] "a" (ATOMIC_ADD32), [qvalp] "da" (&_q_value), "m" (_q_value), [val] "da" (valueToAdd)
175  : "R0", "R1", "P0", "RETS", "memory");
176  return ret;
177 }
178 
179 template <typename T>
180 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
181 {
182  T *readval;
183  asm volatile ("P0 = %2;\n\t"
184  "R1 = %3;\n\t"
185  "R2 = %4;\n\t"
186  "CALL (%5);\n\t"
187  "%0 = R0;\n\t"
188  : "=da" (readval), "=m" (_q_value)
189  : "da" (&_q_value),
190  "da" (expectedValue),
191  "da" (newValue),
192  "a" (ATOMIC_CAS32),
193  "m" (_q_value)
194  : "P0", "R0", "R1", "R2", "RETS", "memory", "cc");
195  return readval == expectedValue;
196 }
197 
198 template <typename T>
200 {
201  asm volatile("R1 = %2;\n\t"
202  "P0 = %4;\n\t"
203  "CALL (%3);\n\t"
204  "%0 = R0;"
205  : "=da" (newValue), "=m" (_q_value)
206  : "da" (newValue), "a" (ATOMIC_XCHG32), "da" (&_q_value), "m" (_q_value)
207  : "R0", "R1", "P0", "RETS", "memory");
208  return newValue;
209 }
210 
211 template <typename T>
213 {
214  T* ret;
215  asm volatile("R0 = %[val];\n\t"
216  "P0 = %[qvalp];\n\t"
217  "CALL (%[addr]);\n\t"
218  "%[ret] = R1;"
219  : [ret] "=da" (ret), "=m" (_q_value)
220  : [addr] "a" (ATOMIC_ADD32), [qvalp] "da" (&_q_value), "m" (_q_value), [val] "da" (valueToAdd * sizeof(T))
221  : "R0", "R1", "P0", "RETS", "memory");
222  return ret;
223 }
224 
225 
226 #endif // Q_OS_LINUX && Q_CC_GNU
227 
228 // Test and set for integers
229 
230 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
231 {
232  return testAndSetOrdered(expectedValue, newValue);
233 }
234 
235 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
236 {
237  return testAndSetOrdered(expectedValue, newValue);
238 }
239 
240 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
241 {
242  return testAndSetOrdered(expectedValue, newValue);
243 }
244 
245 // Fetch and store for integers
246 
247 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
248 {
249  return fetchAndStoreOrdered(newValue);
250 }
251 
252 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
253 {
254  return fetchAndStoreOrdered(newValue);
255 }
256 
257 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
258 {
259  return fetchAndStoreOrdered(newValue);
260 }
261 
262 // Fetch and add for integers
263 
264 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
265 {
266  return fetchAndAddOrdered(valueToAdd);
267 }
268 
269 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
270 {
271  return fetchAndAddOrdered(valueToAdd);
272 }
273 
274 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
275 {
276  return fetchAndAddOrdered(valueToAdd);
277 }
278 
279 // Test and set for pointers
280 
281 template <typename T>
282 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
283 {
284  return testAndSetOrdered(expectedValue, newValue);
285 }
286 
287 template <typename T>
288 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
289 {
290  return testAndSetOrdered(expectedValue, newValue);
291 }
292 
293 template <typename T>
294 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
295 {
296  return testAndSetOrdered(expectedValue, newValue);
297 }
298 
299 // Fetch and store for pointers
300 
301 template <typename T>
303 {
304  return fetchAndStoreOrdered(newValue);
305 }
306 
307 template <typename T>
309 {
310  return fetchAndStoreOrdered(newValue);
311 }
312 
313 template <typename T>
315 {
316  return fetchAndStoreOrdered(newValue);
317 }
318 
319 // Fetch and add for pointers
320 
321 template <typename T>
323 {
324  return fetchAndAddOrdered(valueToAdd);
325 }
326 
327 template <typename T>
329 {
330  return fetchAndAddOrdered(valueToAdd);
331 }
332 
333 template <typename T>
335 {
336  return fetchAndAddOrdered(valueToAdd);
337 }
338 
340 
342 
343 #endif // QATOMIC_BFIN_H
static bool isFetchAndStoreNative()
Definition: qatomic_alpha.h:65
static bool isTestAndSetNative()
Definition: qatomic_alpha.h:58
int fetchAndStoreRelease(int newValue)
static bool isReferenceCountingNative()
Definition: qatomic_alpha.h:51
T * fetchAndAddRelaxed(qptrdiff valueToAdd)
volatile int _q_value
Definition: qbasicatomic.h:64
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static bool isFetchAndAddNative()
Definition: qatomic_alpha.h:98
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
static bool isTestAndSetNative()
Definition: qatomic_alpha.h:80
static bool isFetchAndAddNative()
Definition: qatomic_alpha.h:72
T * fetchAndStoreRelease(T *newValue)
static bool isTestAndSetWaitFree()
Definition: qatomic_alpha.h:83
T * fetchAndAddRelease(qptrdiff valueToAdd)
bool testAndSetOrdered(T *expectedValue, T *newValue)
int fetchAndAddAcquire(int valueToAdd)
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
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.
Definition: qglobal.h:89
int fetchAndStoreAcquire(int newValue)
QIntegerForSizeof< void * >::Signed qptrdiff
Definition: qglobal.h:987
T * fetchAndStoreOrdered(T *newValue)
#define Q_INLINE_TEMPLATE
Definition: qglobal.h:1713
int fetchAndAddRelease(int valueToAdd)
bool testAndSetOrdered(int expectedValue, int newValue)
T * fetchAndStoreAcquire(T *newValue)
static bool isFetchAndStoreWaitFree()
Definition: qatomic_alpha.h:67
static bool isTestAndSetWaitFree()
Definition: qatomic_alpha.h:60
static bool isReferenceCountingWaitFree()
Definition: qatomic_alpha.h:53
int fetchAndAddOrdered(int valueToAdd)
static bool isFetchAndStoreWaitFree()
Definition: qatomic_alpha.h:92
static bool isFetchAndAddWaitFree()
Definition: qatomic_alpha.h:74
static bool isFetchAndAddWaitFree()
bool testAndSetRelease(int expectedValue, int newValue)
int fetchAndAddRelaxed(int valueToAdd)
int fetchAndStoreOrdered(int newValue)
bool testAndSetRelaxed(T *expectedValue, T *newValue)
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
bool testAndSetRelease(T *expectedValue, T *newValue)
#define QT_END_HEADER
Definition: qglobal.h:137
T * fetchAndStoreRelaxed(T *newValue)
static bool isFetchAndStoreNative()
Definition: qatomic_alpha.h:89
bool testAndSetAcquire(T *expectedValue, T *newValue)