summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobalstatic.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-061-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/qtestlib/tutorial5/containers.cpp examples/widgets/tools/tools.pro src/corelib/io/qprocess.cpp src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/network/kernel/qdnslookup_unix.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/testlib/qtestcase.cpp tools/configure/configureapp.cpp Change-Id: I838ae7f082535a67a4a53aa13a21ba5580758be8
| * Fix UB (data race) in Q_GLOBAL_STATICMarc Mutz2016-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The store to guard in the inner function's critical section was not synchronized-with the load at the start of the function: T1 T2 guard.load() mutex.lock() guard.load() d = new Type guard.store() guard.load() // use d mutex.unlock() The use of d in T2 does not synchronize with the write to d in T1 -> data race -> UB. Fix by storing with release memory ordering, so that the guard.load() in T2 synchronizes with the guard.store() in T1. Change-Id: I5c1cd1fa097c6397cb0b48b0d8e8012f95978558 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Update the Intel copyright yearThiago Macieira2016-01-211-1/+1
| | | | | | | | | | | | | | | | | | Not that we require it, but since The Qt Company did it for all files they have copyright, even if they haven't touched the file in years (especially not in 2016), I'm doing the same. Change-Id: I7a9e11d7b64a4cc78e24ffff142b4c9d53039846 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-13/+19
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-08-041-1/+10
|\ | | | | | | | | | | | | | | | | Conflicts: config.tests/arch/arch.cpp src/opengl/qgl_qpa.cpp src/widgets/kernel/qapplication.cpp Change-Id: I80b442a4c2c9632743a5b5c7319ff201ec5bc4fd
| * Work around ICC bug in local static symbols for Q_GLOBAL_STATICThiago Macieira2014-07-301-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling the innerFunction() of the Q_GLOBAL_STATIC expansion, ICC emits global symbols for the internal "holder" local static variable and its guard. If there are two global statics of the same name in two different .cpp files, the linker will incorrectly merge the two "holder" variables. This was noted between the "customTypes" global statics of qmetatype.cpp and qdbusmetatype.cpp in a static build. The C++ standard requires that local static variables declared in inline functions must be the same, regardless of whether the body of the function got inlined or not. The IA-64 C++ ABI does that by requiring local static symbols for inline functions to be global and mergeable ("link once"). However, two functions in anonymous namespaces in different files are not considered to be the same function, so their local statics should not be merged. This is where ICC failed: the local statics are global and mergeable, even though the function is in an anonymous namespace. ICC correctly emits the function itself as a local symbol. Alternative solutions were: 1) add "static", but you can't use a static symbol in a template parameter in C++98 mode 2) remove the "inline" keyword, but then GCC 4.8 will not inline Intel issue ID: 6000058488 Task-number: QTBUG-40053 Change-Id: I307622222499682dde711b2771c8cf7557400799 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Add Q_COMPILER_THREADSAFE_STATICS (a.k.a. "Magic Statics")Thiago Macieira2014-06-271-1/+1
|/ | | | | | | | | | | | It had been so far only supported by GNU-style compilers due to the IA-64 portable C++ ABI. But it's mandated by C++11, so let's add the macro and use it in Q_GLOBAL_STATIC. Looks like Visual Studio "14" will support it. Change-Id: I9710b5146606c7e494c43413f49900419396cfe0 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Avoid other threads blocking for Q_GLOBAL_STATIC constructor on MacKai Koehne2013-10-151-2/+7
| | | | | | | | | | | | | | | | | | | | | The compiler inserts __cxa_guard_acquire, __cxa_guard_release calls around the initialization of local static objects to make the initialization thread safe. However, the implementation of _cxa_guard_acquire in Apple's libc++abi uses a global lock, which means that only one thread can initialize a local static variable at a time. This can be a problem if e.g. the constructor of the variable is blocking while waiting for another thread ... This behavior has caused issues so far in webkit and the qml debugging infrastructure. Better avoid it by using our custom lock implementation. __cxa_guard_acquire implementation: http://www.opensource.apple.com/source/libcppabi/libcppabi-24.2/src/cxa_guard.cxx Task-number: QTBUG-33967 Change-Id: I0d50531ed91ddd074aa07f61f6bf7791e23d990b Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add assert if a global static is used after deletion.Jędrzej Nowacki2013-09-131-2/+10
| | | | | | | | | Q_GLOBAL_STATIC accessor is documented to return dangling pointer if called after destruction. Change-Id: Ieafd5619b20ad256d9d5ad007d939f1430ef681f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix Q_GLOBAL_STATIC support for exceptionsThiago Macieira2013-02-281-1/+2
| | | | | | | | | | | | | | | | | The problem was that the HolderBase destructor was getting called after the contained type's constructor threw an exception, as is required by RAII semantics (the base was fully initialized, so it had to be destroyed). That was required because we want to return a non-null pointer from operator() during destruction and return null after destruction, to keep compatibility with Qt 4. The solution is to only set the guard to Destroyed only if it is already at value Initialized. This way, if the HolderBase destructor is run as part of the stack unwinding, it knows that the construction did not complete. Change-Id: I9849b43ed7112bf9e70861b48a56a924c286617e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-3/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Doc: write up the docs for Q_GLOBAL_STATICThiago Macieira2013-01-241-13/+0
| | | | | | Change-Id: I5bf4d0d027dc8f960c94b4be3ebf7381e9ef4be1 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Add a new Q_GLOBAL_STATIC implementationThiago Macieira2013-01-221-0/+157
Unlike the previous implementation, this implementation is locked: only one initialisation is ever run at the same time. It is exception-safe, meaning that a throwing constructor will restart the process. Also, start using the thread-safe behaviour that GCC has offered for a long time and C++11 requires. Change-Id: I20db44f57d258923df64c0051358fd0d9a5ccd51 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: David Faure (KDE) <faure@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>