Qt 4.8
qatomic_parisc.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_PARISC_H
43 #define QATOMIC_PARISC_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 extern "C" {
105  Q_CORE_EXPORT void q_atomic_lock(int *lock);
106  Q_CORE_EXPORT void q_atomic_unlock(int *lock);
107 }
108 
109 // Reference counting
110 
111 inline bool QBasicAtomicInt::ref()
112 {
113  q_atomic_lock(_q_lock);
114  bool ret = (++_q_value != 0);
115  q_atomic_unlock(_q_lock);
116  return ret;
117 }
118 
119 inline bool QBasicAtomicInt::deref()
120 {
121  q_atomic_lock(_q_lock);
122  bool ret = (--_q_value != 0);
123  q_atomic_unlock(_q_lock);
124  return ret;
125 }
126 
127 // Test-and-set for integers
128 
129 inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
130 {
131  q_atomic_lock(_q_lock);
132  if (_q_value == expectedValue) {
133  _q_value = newValue;
134  q_atomic_unlock(_q_lock);
135  return true;
136  }
137  q_atomic_unlock(_q_lock);
138  return false;
139 }
140 
141 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
142 {
143  return testAndSetOrdered(expectedValue, newValue);
144 }
145 
146 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
147 {
148  return testAndSetOrdered(expectedValue, newValue);
149 }
150 
151 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
152 {
153  return testAndSetOrdered(expectedValue, newValue);
154 }
155 
156 // Fetch-and-store for integers
157 
158 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
159 {
160  q_atomic_lock(_q_lock);
161  int returnValue = _q_value;
162  _q_value = newValue;
163  q_atomic_unlock(_q_lock);
164  return returnValue;
165 }
166 
167 inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
168 {
169  return fetchAndStoreOrdered(newValue);
170 }
171 
172 inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
173 {
174  return fetchAndStoreOrdered(newValue);
175 }
176 
177 inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
178 {
179  return fetchAndStoreOrdered(newValue);
180 }
181 
182 // Fetch-and-add for integers
183 
184 inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
185 {
186  q_atomic_lock(_q_lock);
187  int originalValue = _q_value;
188  _q_value += valueToAdd;
189  q_atomic_unlock(_q_lock);
190  return originalValue;
191 }
192 
193 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
194 {
195  return fetchAndAddOrdered(valueToAdd);
196 }
197 
198 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
199 {
200  return fetchAndAddOrdered(valueToAdd);
201 }
202 
203 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
204 {
205  return fetchAndAddOrdered(valueToAdd);
206 }
207 
208 // Test and set for pointers
209 
210 template <typename T>
211 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
212 {
213  q_atomic_lock(_q_lock);
214  if (_q_value == expectedValue) {
215  _q_value = newValue;
216  q_atomic_unlock(_q_lock);
217  return true;
218  }
219  q_atomic_unlock(_q_lock);
220  return false;
221 }
222 
223 template <typename T>
224 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
225 {
226  return testAndSetOrdered(expectedValue, newValue);
227 }
228 
229 template <typename T>
230 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
231 {
232  return testAndSetOrdered(expectedValue, newValue);
233 }
234 
235 template <typename T>
236 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
237 {
238  return testAndSetOrdered(expectedValue, newValue);
239 }
240 
241 // Fetch and store for pointers
242 
243 template <typename T>
245 {
246  q_atomic_lock(_q_lock);
247  T *returnValue = (_q_value);
248  _q_value = newValue;
249  q_atomic_unlock(_q_lock);
250  return returnValue;
251 }
252 
253 template <typename T>
255 {
256  return fetchAndStoreOrdered(newValue);
257 }
258 
259 template <typename T>
261 {
262  return fetchAndStoreOrdered(newValue);
263 }
264 
265 template <typename T>
267 {
268  return fetchAndStoreOrdered(newValue);
269 }
270 
271 // Fetch and add for pointers
272 
273 template <typename T>
275 {
276  q_atomic_lock(_q_lock);
277  T *returnValue = (_q_value);
278  _q_value += valueToAdd;
279  q_atomic_unlock(_q_lock);
280  return returnValue;
281 }
282 
283 template <typename T>
285 {
286  return fetchAndAddOrdered(valueToAdd);
287 }
288 
289 template <typename T>
291 {
292  return fetchAndAddOrdered(valueToAdd);
293 }
294 
295 template <typename T>
297 {
298  return fetchAndAddOrdered(valueToAdd);
299 }
300 
302 
304 
305 #endif // QATOMIC_PARISC_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)
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
static QReadWriteLock lock
Definition: proxyconf.cpp:399
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)
Q_CORE_EXPORT void q_atomic_unlock(int *lock)
Q_CORE_EXPORT void q_atomic_lock(int *lock)
static bool isFetchAndStoreNative()
Definition: qatomic_alpha.h:89
bool testAndSetAcquire(T *expectedValue, T *newValue)