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 04d6495bf7.
Change-Id: Id9335cffdd43094cafb231fdde2523d013abe1d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
parent
99ce1d3d97
commit
cad9c7cbc9
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ public:
|
|||
|
||||
static int nextId()
|
||||
{
|
||||
static QBasicAtomicInt counter;
|
||||
static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(0);
|
||||
return 1 + counter.fetchAndAddRelaxed(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue