summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qgenericatomic.h
Commit message (Collapse)AuthorAgeFilesLines
* Make loadAcquire const.Stephen Kelly2012-02-291-3/+3
| | | | | Change-Id: Iad2d60d1abe363a3b85eaf152861d0979a997d81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Silence syncqt warnings for atomic implementation headersBradley T. Hughes2012-02-061-0/+4
| | | | | | | | | | Most of these headers are either forwarding headers, or we explicitly stop syncqt so that it doesn't generate class includes for the atomic implementation. Either way, syncqt doesn't see the QT_END_* (and sometimes not QT_BEGIN_*), which this commit fixes. Change-Id: Icc8da6f384f38b1ff4eb265c731ce2f2ed92a1a3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port the Windows atomic implementation to use QGenericAtomicOpsBradley T. Hughes2012-02-021-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | First, we do not need to have the QT_INTERLOCKED_REMOVE_VOLATILE(a) macro anymore either, since the value stored in QBasicAtomicInteger is not volatile. Windows provides Interlocked*Pointer() functions in some configurations, so we provide a partial specialization of QAtomicOps for pointer types. For integer types, QAtomicOps selects an implementation based on the size of the type. At the moment, we only support 32-bit types, but it will be possible to add 64-bit later. Note that the 32-bit specialization of QAtomicOpsBySize declares the Type typedef as long, not int, since the Windows Interlocked*() API takes parameters as longs and long pointers. Since this typedef differs from the type given to QBasicAtomicInteger<T> by the QBasicAtomicInt typedef, we need to templatise the _q_value parameter separately from the other arguments in QGenericAtomicOps. This templatisation would be necessary to port other architectures, such as PA_RISC, where we need to have an int[4] array in the atomic type while the arguments do not need this array. Change-Id: Id71fa1ae334da2023553cb402b45e6c285f1d344 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-0/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Add Contact: information in the license headerBradley T. Hughes2012-01-201-0/+1
| | | | | | | | Contact point is the Qt Project, and needs to be included for all new files added to the repository. Change-Id: Id0e7219e1d11a169f1a91439728cbda55ab29eeb Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Use Q_FOREVER instead of foreverBradley T. Hughes2012-01-201-2/+2
| | | | | | | | | | Public headers should compile with QT_NO_KEYWORDS defined. Change-Id: I5620b4b2600f5e39bb402b97d14fdb257dfe9942 Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Jonas Gastal <jgastal@profusion.mobi> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Add the new QBasicAtomicXXX implementation - no backends yetThiago Macieira2012-01-201-0/+232
The new implementation is API- and ABI-compatible with the old implementation, provided that QBasicAtomicInt isn't used as an argument in a function call or the return value: now, QBasicAtomicInt is a typedef to QBasicAtomicInteger<int>. The new design is based on CRTP: the QGenericAtomicOps template class takes as a template parameter the derived class itself. This way, we implement a "poor man's virtual" without a virtual table and everything is inline. QGenericAtomicOps implements most of the atomics code that is repeated in many classes all over: * Acquire semantics are obtained by placing an acquire barrier after the Relaxed operation * Release semantics are obtained by placing a release barrier before the Relaxed operation * Ordered semantics are obtained by placing an ordered barrier before the Relaxed operation (either way would be fine) * fetchAndStoreRelaxed and fetchAndAddRelaxed are implemented on top of testAndSetRelaxed * ref and deref are implemented on top of fetchAndAddRelaxed It also adds load, loadAcquire, store and storeRelease: the default implementations of loadAcquire and storeRelease operate on a volatile variable and add barriers. There are no direct operators for accessing the value. Each architecture-specific implementation can override any of the functions or the memory barrier functions. It must implement at least the testAndSetRelaxed function. In addition, by specialising one template class, the implementations can allow QBasicAtomicInteger for additional types (of different sizes). At the very least, int, unsigned and pointers must be supported. Change-Id: I6da647e225bb330d3cfc16f84d0e7849dff85ec7 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>