102 { return false; } |
102 { return false; } |
103 |
103 |
104 Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int); |
104 Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int); |
105 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int); |
105 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int); |
106 Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(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); |
107 |
116 |
108 Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *); |
117 Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *); |
109 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *); |
118 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *); |
110 Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff); |
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); |
111 |
129 |
112 // Reference counting |
130 // Reference counting |
113 |
131 |
114 //LockedInc and LockedDec are machine coded for ARMv6 (and future proof) |
132 //LockedInc and LockedDec are machine coded for ARMv6 (and future proof) |
115 inline bool QBasicAtomicInt::ref() |
133 inline bool QBasicAtomicInt::ref() |
131 return QBasicAtomicInt_testAndSetOrdered(&_q_value, expectedValue, newValue); |
149 return QBasicAtomicInt_testAndSetOrdered(&_q_value, expectedValue, newValue); |
132 } |
150 } |
133 |
151 |
134 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) |
152 inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) |
135 { |
153 { |
136 return testAndSetOrdered(expectedValue, newValue); |
154 return QBasicAtomicInt_testAndSetRelaxed(&_q_value, expectedValue, newValue); |
137 } |
155 } |
138 |
156 |
139 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) |
157 inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue) |
140 { |
158 { |
141 return testAndSetOrdered(expectedValue, newValue); |
159 return QBasicAtomicInt_testAndSetAcquire(&_q_value, expectedValue, newValue); |
142 } |
160 } |
143 |
161 |
144 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) |
162 inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue) |
145 { |
163 { |
146 return testAndSetOrdered(expectedValue, newValue); |
164 return QBasicAtomicInt_testAndSetRelease(&_q_value, expectedValue, newValue); |
147 } |
165 } |
148 |
166 |
149 // Fetch and store for integers |
167 // Fetch and store for integers |
150 |
168 |
151 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) |
169 inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue) |
175 return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, valueToAdd); |
193 return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, valueToAdd); |
176 } |
194 } |
177 |
195 |
178 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) |
196 inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) |
179 { |
197 { |
180 return fetchAndAddOrdered(valueToAdd); |
198 return QBasicAtomicInt_fetchAndAddRelaxed(&_q_value, valueToAdd); |
181 } |
199 } |
182 |
200 |
183 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) |
201 inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd) |
184 { |
202 { |
185 return fetchAndAddOrdered(valueToAdd); |
203 return QBasicAtomicInt_fetchAndAddAcquire(&_q_value, valueToAdd); |
186 } |
204 } |
187 |
205 |
188 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) |
206 inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd) |
189 { |
207 { |
190 return fetchAndAddOrdered(valueToAdd); |
208 return QBasicAtomicInt_fetchAndAddRelease(&_q_value, valueToAdd); |
191 } |
209 } |
192 |
210 |
193 // Test and set for pointers |
211 // Test and set for pointers |
194 |
212 |
195 template <typename T> |
213 template <typename T> |
196 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue) |
214 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue) |
197 { |
215 { |
198 union { T * volatile * typed; void * volatile * voidp; } pointer; |
216 return QBasicAtomicPointer_testAndSetOrdered(reinterpret_cast<void * volatile *>(&_q_value), |
199 pointer.typed = &_q_value; |
217 expectedValue, newValue); |
200 return QBasicAtomicPointer_testAndSetOrdered(pointer.voidp, expectedValue, newValue); |
|
201 } |
218 } |
202 |
219 |
203 template <typename T> |
220 template <typename T> |
204 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue) |
221 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue) |
205 { |
222 { |
206 return testAndSetOrdered(expectedValue, newValue); |
223 return QBasicAtomicPointer_testAndSetRelaxed(reinterpret_cast<void * volatile *>(&_q_value), |
|
224 expectedValue, newValue); |
207 } |
225 } |
208 |
226 |
209 template <typename T> |
227 template <typename T> |
210 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue) |
228 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue) |
211 { |
229 { |
212 return testAndSetOrdered(expectedValue, newValue); |
230 return QBasicAtomicPointer_testAndSetAcquire(reinterpret_cast<void * volatile *>(&_q_value), |
|
231 expectedValue, newValue); |
213 } |
232 } |
214 |
233 |
215 template <typename T> |
234 template <typename T> |
216 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue) |
235 Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue) |
217 { |
236 { |
218 return testAndSetOrdered(expectedValue, newValue); |
237 return QBasicAtomicPointer_testAndSetRelease(reinterpret_cast<void * volatile *>(&_q_value), |
|
238 expectedValue, newValue); |
219 } |
239 } |
220 |
240 |
221 // Fetch and store for pointers |
241 // Fetch and store for pointers |
222 |
242 |
223 template <typename T> |
243 template <typename T> |
224 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue) |
244 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue) |
225 { |
245 { |
226 union { T * volatile * typed; void * volatile * voidp; } pointer; |
246 return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreOrdered( |
227 union { T *typed; void *voidp; } returnValue; |
247 reinterpret_cast<void * volatile *>(&_q_value) |
228 pointer.typed = &_q_value; |
248 , newValue)); |
229 returnValue.voidp = QBasicAtomicPointer_fetchAndStoreOrdered(pointer.voidp, newValue); |
|
230 return returnValue.typed; |
|
231 } |
249 } |
232 |
250 |
233 template <typename T> |
251 template <typename T> |
234 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) |
252 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) |
235 { |
253 { |
236 return fetchAndStoreOrdered(newValue); |
254 return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreRelaxed( |
|
255 reinterpret_cast<void * volatile *>(&_q_value) |
|
256 , newValue)); |
237 } |
257 } |
238 |
258 |
239 template <typename T> |
259 template <typename T> |
240 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue) |
260 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue) |
241 { |
261 { |
242 return fetchAndStoreOrdered(newValue); |
262 return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreAcquire( |
|
263 reinterpret_cast<void * volatile *>(&_q_value) |
|
264 , newValue)); |
243 } |
265 } |
244 |
266 |
245 template <typename T> |
267 template <typename T> |
246 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue) |
268 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue) |
247 { |
269 { |
248 return fetchAndStoreOrdered(newValue); |
270 return static_cast<T*>(QBasicAtomicPointer_fetchAndStoreRelease( |
|
271 reinterpret_cast<void * volatile *>(&_q_value) |
|
272 , newValue)); |
249 } |
273 } |
250 |
274 |
251 // Fetch and add for pointers |
275 // Fetch and add for pointers |
252 |
276 |
253 template <typename T> |
277 template <typename T> |
254 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd) |
278 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd) |
255 { |
279 { |
256 union { T * volatile *typed; void * volatile *voidp; } pointer; |
280 return static_cast<T*>(QBasicAtomicPointer_fetchAndAddOrdered( |
257 union { T *typed; void *voidp; } returnValue; |
281 reinterpret_cast<void * volatile *>(&_q_value), |
258 pointer.typed = &_q_value; |
282 valueToAdd * sizeof(T))); |
259 returnValue.voidp = QBasicAtomicPointer_fetchAndAddOrdered(pointer.voidp, valueToAdd * sizeof(T)); |
|
260 return returnValue.typed; |
|
261 } |
283 } |
262 |
284 |
263 template <typename T> |
285 template <typename T> |
264 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd) |
286 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd) |
265 { |
287 { |
266 return fetchAndAddOrdered(valueToAdd); |
288 return static_cast<T*>(QBasicAtomicPointer_fetchAndAddRelaxed( |
|
289 reinterpret_cast<void * volatile *>(&_q_value), |
|
290 valueToAdd * sizeof(T))); |
267 } |
291 } |
268 |
292 |
269 template <typename T> |
293 template <typename T> |
270 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd) |
294 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd) |
271 { |
295 { |
272 return fetchAndAddOrdered(valueToAdd); |
296 return static_cast<T*>(QBasicAtomicPointer_fetchAndAddAcquire( |
|
297 reinterpret_cast<void * volatile *>(&_q_value), |
|
298 valueToAdd * sizeof(T))); |
273 } |
299 } |
274 |
300 |
275 template <typename T> |
301 template <typename T> |
276 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd) |
302 Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd) |
277 { |
303 { |
278 return fetchAndAddOrdered(valueToAdd); |
304 return static_cast<T*>(QBasicAtomicPointer_fetchAndAddRelease( |
|
305 reinterpret_cast<void * volatile *>(&_q_value), |
|
306 valueToAdd * sizeof(T))); |
279 } |
307 } |
280 |
308 |
281 QT_END_NAMESPACE |
309 QT_END_NAMESPACE |
282 |
310 |
283 QT_END_HEADER |
311 QT_END_HEADER |