diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2021-09-28 17:50:02 -0700 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-08 05:23:42 +0000 |
commit | 60230870a7f121ddc0779f1eecbaf8de6cb60cdc (patch) | |
tree | 9c8e7e5c891953cd88e63ee448ac1020bf2585d2 /src | |
parent | 7201084d744710b04b8f8033804bdad5ab48f5e7 (diff) |
QtTest: fix build with MinGW/GCC 9: no std::mutex support
Unfortunately we can't depend on the C++11, 14 or 17 Standard
Library, which is not properly and completely implemented
everywhere. All Library features above C++98 must be checked with
their corresponding __cpp_lib macro before use. This does not
apply to the C++17 Core Language.
qwaitcondition_p.h:144:20: error: 'mutex' in namespace 'std' does not name a type
144 | using mutex = std::mutex;
| ^~~~~
qwaitcondition_p.h:59:1: note: 'std::mutex' is defined in header '<mutex>'; did you forget to '#include <mutex>'?
58 | #include <condition_variable>
+++ |+#include <mutex>
59 | #include <mutex>
qwaitcondition_p.h:145:33: error: 'condition_variable' in namespace 'std' does not name a type
145 | using condition_variable = std::condition_variable;
| ^~~~~~~~~~~~~~~~~~
qwaitcondition_p.h:59:1: note: 'std::condition_variable' is defined in header '<condition_variable>'; did you forget to '#include <condition_variable>'?
58 | #include <condition_variable>
+++ |+#include <condition_variable>
59 | #include <mutex>
Change-Id: I2bbf422288924c198645fffd16a9249e5330136a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 1bac82fa99c4abb33dcf99fa588d72e6cf95d496)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/thread/qwaitcondition_p.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/corelib/thread/qwaitcondition_p.h b/src/corelib/thread/qwaitcondition_p.h index 93ae628143..26a7e03ba7 100644 --- a/src/corelib/thread/qwaitcondition_p.h +++ b/src/corelib/thread/qwaitcondition_p.h @@ -58,12 +58,20 @@ #include <condition_variable> #include <mutex> +// There's no feature macro for C++11 std::mutex, so we use the C++14 one +// for shared_mutex to detect it. +// Needed for: MinGW without gthreads, Integrity +#if __has_include(<shared_mutex>) +# include <shared_mutex> +#endif + QT_BEGIN_NAMESPACE namespace QtPrivate { -#if defined(Q_OS_INTEGRITY) +#if !defined(__cpp_lib_shared_timed_mutex) +enum class cv_status { no_timeout, timeout }; class condition_variable; class mutex : private QMutex @@ -97,12 +105,12 @@ public: } template <typename Rep, typename Period> - std::cv_status wait_for(std::unique_lock<QtPrivate::mutex> &lock, + cv_status wait_for(std::unique_lock<QtPrivate::mutex> &lock, const std::chrono::duration<Rep, Period> &d) { return QWaitCondition::wait(lock.mutex(), QDeadlineTimer{d}) - ? std::cv_status::no_timeout - : std::cv_status::timeout; + ? cv_status::no_timeout + : cv_status::timeout; } template <typename Rep, typename Period, typename Predicate> bool wait_for(std::unique_lock<QtPrivate::mutex> &lock, @@ -117,12 +125,12 @@ public: } template <typename Clock, typename Duration> - std::cv_status wait_until(std::unique_lock<QtPrivate::mutex> &lock, + cv_status wait_until(std::unique_lock<QtPrivate::mutex> &lock, const std::chrono::time_point<Clock, Duration> &t) { return QWaitCondition::wait(lock.mutex(), QDeadlineTimer{t}) - ? std::cv_status::no_timeout - : std::cv_status::timeout; + ? cv_status::no_timeout + : cv_status::timeout; } template <typename Clock, typename Duration, typename Predicate> @@ -139,12 +147,12 @@ public: }; -#else // Integrity +#else // C++11 threads using mutex = std::mutex; using condition_variable = std::condition_variable; -#endif // Integrity +#endif // C++11 threads } // namespace QtPrivate |