diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-03-27 13:55:13 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-03-27 20:55:31 (GMT) |
commit | ba25c4a832516124bcd97758de9eede32797c5a0 (patch) | |
tree | 225082cb39525883b292563fbf1a815278cdcbf1 | |
parent | ff30a91eedd30c0e2e0b62ad50ade3d7d27651a8 (diff) | |
download | Qt-ba25c4a832516124bcd97758de9eede32797c5a0.zip Qt-ba25c4a832516124bcd97758de9eede32797c5a0.tar.gz Qt-ba25c4a832516124bcd97758de9eede32797c5a0.tar.bz2 |
Make use of a thread-specific variable in qFlagLocation.
We're a bit too deep in the stack here for QThreadStorage. So just use
the system support, provided it works.
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 05015c0..0e632db 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2179,13 +2179,29 @@ void QObject::deleteLater() Signals and slots *****************************************************************************/ +// list taken from http://en.wikipedia.org/wiki/Thread-Specific_Storage +#if defined(Q_OS_WIN) +// Some people like to dynamically load Qt (LoadLibrary), so we can't use this +#elif defined(Q_CC_GNU) && !defined(Q_WS_QWS) +// GCC has warnings about this not being ported to all archs +// So we only enable what we know to work. More archs can be added later, like Mac +# if defined(Q_OS_LINUX) && (defined(QT_ARCH_I386) || defined(QT_ARCH_X86_64) || defined(QT_ARCH_IA64)) +# define THRSPECIFIC __thread __attribute__((tls_model("local-dynamic"))) +# endif +#elif defined(Q_CC_SUN) || defined(Q_CC_INTEL) || defined(Q_CC_XLC) +# define THRSPECIFIC __thread +#endif + +#ifndef THRSPECIFIC +# define THRSPECIFIC +#endif const int flagged_locations_count = 2; -static const char* flagged_locations[flagged_locations_count] = {0}; +static THRSPECIFIC const char* flagged_locations[flagged_locations_count] = {0}; const char *qFlagLocation(const char *method) { - static int idx = 0; + static THRSPECIFIC int idx = 0; flagged_locations[idx] = method; idx = (idx+1) % flagged_locations_count; return method; |