Qt 4.8
qatomic_m68k.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_M68K_H
43 #define QATOMIC_M68K_H
44 
46 
48 
49 #define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
50 
52 { return true; }
54 { return false; }
55 
56 #define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
57 
59 { return true; }
61 { return false; }
62 
63 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
64 #define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
65 
67 { return true; }
69 { return true; }
70 
71 #define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
72 
74 { return true; }
76 { return false; }
77 
78 #define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
79 
80 template <typename T>
82 { return true; }
83 template <typename T>
85 { return false; }
86 
87 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
88 #define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
89 
90 template <typename T>
92 { return true; }
93 template <typename T>
95 { return true; }
96 
97 #define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
98 
99 template <typename T>
101 { return true; }
102 template <typename T>
104 { return false; }
105 
106 inline bool QBasicAtomicInt::ref()
107 {
108  return __sync_add_and_fetch(&_q_value, 1);
109 }
110 
111 inline bool QBasicAtomicInt::deref()
112 {
113  return __sync_sub_and_fetch(&_q_value, 1);
114 }
115 
116 inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
117 {
118  return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue);
119 }
120 
121 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
122 {
123  return testAndSetOrdered(expectedValue, newValue);
124 }
125 
126 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
127 {
128  return testAndSetOrdered(expectedValue, newValue);
129 }
130 
131 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
132 {
133  return testAndSetOrdered(expectedValue, newValue);
134 }
135 
136 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
137 {
138  return __sync_lock_test_and_set(&_q_value, newValue);
139 }
140 
141 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
142 {
143  return fetchAndStoreOrdered(newValue);
144 }
145 
146 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
147 {
148  return fetchAndStoreOrdered(newValue);
149 }
150 
151 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
152 {
153  return fetchAndStoreOrdered(newValue);
154 }
155 
156 inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
157 {
158  return __sync_fetch_and_add(&_q_value, valueToAdd);
159 }
160 
161 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
162 {
163  return fetchAndAddOrdered(valueToAdd);
164 }
165 
166 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
167 {
168  return fetchAndAddOrdered(valueToAdd);
169 }
170 
171 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
172 {
173  return fetchAndAddOrdered(valueToAdd);
174 }
175 
176 template <typename T>
177 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
178 {
179  return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue);
180 }
181 
182 template <typename T>
183 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
184 {
185  return testAndSetOrdered(expectedValue, newValue);
186 }
187 
188 template <typename T>
189 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
190 {
191  return testAndSetOrdered(expectedValue, newValue);
192 }
193 
194 template <typename T>
195 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
196 {
197  return testAndSetOrdered(expectedValue, newValue);
198 }
199 
200 template <typename T>
202 {
203  return __sync_lock_test_and_set(&_q_value, newValue);
204 }
205 
206 template <typename T>
208 {
209  return fetchAndStoreOrdered(newValue);
210 }
211 
212 template <typename T>
214 {
215  return fetchAndStoreOrdered(newValue);
216 }
217 
218 template <typename T>
220 {
221  return fetchAndStoreOrdered(newValue);
222 }
223 
224 template <typename T>
226 {
227  return __sync_fetch_and_add(&_q_value, valueToAdd * sizeof(T));
228 }
229 
230 template <typename T>
232 {
233  return fetchAndAddOrdered(valueToAdd);
234 }
235 
236 template <typename T>
238 {
239  return fetchAndAddOrdered(valueToAdd);
240 }
241 
242 template <typename T>
244 {
245  return fetchAndAddOrdered(valueToAdd);
246 }
247 
249 
251 
252 #endif // QATOMIC_M68K_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)
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)
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)