diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2017-02-16 15:03:01 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2017-02-16 19:26:46 +0000 |
commit | cad9c7cbc9339165bb71a54c3981ccd56b6d8ef8 (patch) | |
tree | a04365ff0f0969a8d5f43418daea01ae0e7381c0 | |
parent | 99ce1d3d97c0423c3ee63ccf58deed964db0770e (diff) |
Use static initialization for QBasicAtomics
A default-constructed static QBasicAtomicInt at function scope
will be dynamically initialized. It will still be zero-initialized,
but at least GCC adds guard variables for such objects.
When using aggregate initialization, the guard disappears.
Amends 04d6495bf773a6bb0d4fa6980df22d3b81a605b0.
Change-Id: Id9335cffdd43094cafb231fdde2523d013abe1d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qicon.cpp | 2 | ||||
-rw-r--r-- | src/gui/image/qimage.cpp | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopengltextureglyphcache.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qftp.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 2 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp | 2 |
8 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 1a7073a069..0afce7fcf0 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -968,7 +968,7 @@ QUuid QUuid::createUuid() if (!uuidseed.hasLocalData()) { int *pseed = new int; - static QBasicAtomicInt serial; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); qsrand(*pseed = QDateTime::currentSecsSinceEpoch() + quintptr(&pseed) + 2 + serial.fetchAndAddRelaxed(1)); diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 0c3323636a..7d6cd50bac 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -99,7 +99,7 @@ QT_BEGIN_NAMESPACE static int nextSerialNumCounter() { - static QBasicAtomicInt serial; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); return 1 + serial.fetchAndAddRelaxed(1); } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 75229ada6c..c1ea053204 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -91,7 +91,7 @@ static QImage rotated270(const QImage &src); static int next_qimage_serial_number() { - static QBasicAtomicInt serial; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); return 1 + serial.fetchAndAddRelaxed(1); } diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp index 9a4527b4e6..556d52ef99 100644 --- a/src/gui/opengl/qopengltextureglyphcache.cpp +++ b/src/gui/opengl/qopengltextureglyphcache.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE static int next_qopengltextureglyphcache_serial_number() { - static QBasicAtomicInt serial; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); return 1 + serial.fetchAndAddRelaxed(1); } diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 18c5a16cb5..e9cb3aa498 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -250,7 +250,7 @@ public: static int nextId() { - static QBasicAtomicInt counter; + static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(0); return 1 + counter.fetchAndAddRelaxed(1); } diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index d3a1858f86..46123eb8a7 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -185,7 +185,7 @@ void emit_results_ready(const QHostInfo &hostInfo, const QObject *receiver, static int nextId() { - static QBasicAtomicInt counter; + static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(0); return 1 + counter.fetchAndAddRelaxed(1); } diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index c1c5661da4..d5ce4efd1a 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE static int next_qgltextureglyphcache_serial_number() { - static QBasicAtomicInt serial; + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); return 1 + serial.fetchAndAddRelaxed(1); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp index d0b4b5d5bd..1abc430da6 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_emu/qeglfsemulatorintegration.cpp @@ -127,7 +127,7 @@ EGLNativeWindowType QEglFSEmulatorIntegration::createNativeWindow(QPlatformWindo // Let the emulator know which screen the window surface is attached to setDisplay(screen->id()); } - static QBasicAtomicInt uniqueWindowId; + static QBasicAtomicInt uniqueWindowId = Q_BASIC_ATOMIC_INITIALIZER(0); return EGLNativeWindowType(qintptr(1 + uniqueWindowId.fetchAndAddRelaxed(1))); } |