summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobalstatic.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-03-20 18:35:59 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-03-21 09:13:00 +0100
commitb8b50c6c7a6df17db03ff6fd3a2501511e51703f (patch)
treec2e432b305f6f94ae79abce9f48997aea7f37935 /src/corelib/global/qglobalstatic.h
parent52e0a91fbc187ca09d3ea6279e8bdce982edc586 (diff)
Clenaup Q_COMPILER_THREADSAFE_STATICS
Change-Id: I1cf0646d4e6c9b30a7ef6538d81f92faf2e511e1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qglobalstatic.h')
-rw-r--r--src/corelib/global/qglobalstatic.h43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h
index 674a2aea65..034ef274fa 100644
--- a/src/corelib/global/qglobalstatic.h
+++ b/src/corelib/global/qglobalstatic.h
@@ -55,17 +55,6 @@ enum GuardValues {
};
}
-#if !QT_CONFIG(thread) || defined(Q_COMPILER_THREADSAFE_STATICS)
-// some compilers support thread-safe statics
-// The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4
-// support it. C++11 also requires this behavior.
-// Clang and Intel CC masquerade as GCC when compiling on Linux.
-//
-// Apple's libc++abi however uses a global lock for initializing local statics,
-// which will block other threads also trying to initialize a local static
-// until the constructor returns ...
-// We better avoid these kind of problems by using our own locked implementation.
-
#if defined(Q_OS_UNIX) && defined(Q_CC_INTEL)
// Work around Intel issue ID 6000058488:
// local statics inside an inline function inside an anonymous namespace are global
@@ -94,39 +83,7 @@ enum GuardValues {
} holder; \
return &holder.value; \
}
-#else
-// We don't know if this compiler supports thread-safe global statics
-// so use our own locked implementation
-QT_END_NAMESPACE
-#include <QtCore/qmutex.h>
-#include <mutex>
-QT_BEGIN_NAMESPACE
-
-#define Q_GLOBAL_STATIC_INTERNAL(ARGS) \
- Q_DECL_HIDDEN inline Type *innerFunction() \
- { \
- static Type *d; \
- static QBasicMutex mutex; \
- int x = guard.loadAcquire(); \
- if (Q_UNLIKELY(x >= QtGlobalStatic::Uninitialized)) { \
- const std::lock_guard<QBasicMutex> locker(mutex); \
- if (guard.loadRelaxed() == QtGlobalStatic::Uninitialized) { \
- d = new Type ARGS; \
- static struct Cleanup { \
- Cleanup() = default; \
- ~Cleanup() { \
- delete d; \
- guard.storeRelaxed(QtGlobalStatic::Destroyed); \
- } \
- Q_DISABLE_COPY_MOVE(Cleanup) \
- } cleanup; \
- guard.storeRelease(QtGlobalStatic::Initialized); \
- } \
- } \
- return d; \
- }
-#endif
// this class must be POD, unless the compiler supports thread-safe statics
template <typename T, T *(&innerFunction)(), QBasicAtomicInt &guard>