Remove preprocessor conditionals for chrono include
__has_include(<chrono>) is always true, because C++11 chrono include is required since 6.0. Change-Id: I50cb92571bf4f1f86e2f3f2b5f486dd3c3f30f4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ec2af0a9df0ac7bf9036f59a94ac3f3ef45c6740) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ff975be6b4
commit
45f0ae809b
@ -43,9 +43,7 @@
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -66,7 +64,6 @@ public:
|
||||
void setStaleLockTime(int);
|
||||
int staleLockTime() const;
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
bool tryLock(std::chrono::milliseconds timeout) { return tryLock(int(timeout.count())); }
|
||||
|
||||
void setStaleLockTime(std::chrono::milliseconds value) { setStaleLockTime(int(value.count())); }
|
||||
@ -75,7 +72,6 @@ public:
|
||||
{
|
||||
return std::chrono::milliseconds(staleLockTime());
|
||||
}
|
||||
#endif
|
||||
|
||||
bool isLocked() const;
|
||||
bool getLockInfo(qint64 *pid, QString *hostname, QString *appname) const;
|
||||
|
@ -52,9 +52,7 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -120,7 +118,6 @@ public:
|
||||
QDeadlineTimer &operator-=(qint64 msecs)
|
||||
{ *this = *this + (-msecs); return *this; }
|
||||
|
||||
#if __has_include(<chrono>) || defined(Q_CLANG_QDOC)
|
||||
template <class Clock, class Duration>
|
||||
QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline_,
|
||||
Qt::TimerType type_ = Qt::CoarseTimer) : t2(0)
|
||||
@ -178,7 +175,6 @@ public:
|
||||
template <class Rep, class Period>
|
||||
friend QDeadlineTimer operator+=(QDeadlineTimer &dt, std::chrono::duration<Rep, Period> value)
|
||||
{ return dt = dt + value; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
qint64 t1;
|
||||
@ -192,7 +188,7 @@ public:
|
||||
QPair<qint64, unsigned> _q_data() const { return qMakePair(t1, t2); }
|
||||
};
|
||||
|
||||
#if __has_include(<chrono>) && (defined(Q_OS_DARWIN) || defined(Q_OS_LINUX) || (defined(Q_CC_MSVC) && Q_CC_MSVC >= 1900))
|
||||
#if defined(Q_OS_DARWIN) || defined(Q_OS_LINUX) || (defined(Q_CC_MSVC) && Q_CC_MSVC >= 1900)
|
||||
// We know for these OS/compilers that the std::chrono::steady_clock uses the same
|
||||
// reference time as QDeadlineTimer
|
||||
|
||||
|
@ -56,9 +56,7 @@
|
||||
#include <QtCore/qobject_impl.h>
|
||||
#include <QtCore/qbindingstorage.h>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -155,13 +153,11 @@ public:
|
||||
void moveToThread(QThread *thread);
|
||||
|
||||
int startTimer(int interval, Qt::TimerType timerType = Qt::CoarseTimer);
|
||||
#if __has_include(<chrono>)
|
||||
Q_ALWAYS_INLINE
|
||||
int startTimer(std::chrono::milliseconds time, Qt::TimerType timerType = Qt::CoarseTimer)
|
||||
{
|
||||
return startTimer(int(time.count()), timerType);
|
||||
}
|
||||
#endif
|
||||
void killTimer(int id);
|
||||
|
||||
template<typename T>
|
||||
|
@ -47,9 +47,7 @@
|
||||
#include <QtCore/qbasictimer.h> // conceptual inheritance
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -181,7 +179,6 @@ Q_SIGNALS:
|
||||
void timeout(QPrivateSignal);
|
||||
|
||||
public:
|
||||
#if __has_include(<chrono>) || defined(Q_QDOC)
|
||||
void setInterval(std::chrono::milliseconds value)
|
||||
{
|
||||
setInterval(int(value.count()));
|
||||
@ -211,7 +208,6 @@ public:
|
||||
{
|
||||
start(int(value.count()));
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
@ -228,7 +224,6 @@ private:
|
||||
static void singleShotImpl(int msec, Qt::TimerType timerType,
|
||||
const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj);
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
static Qt::TimerType defaultTypeFor(std::chrono::milliseconds interval)
|
||||
{ return defaultTypeFor(int(interval.count())); }
|
||||
|
||||
@ -238,7 +233,6 @@ private:
|
||||
singleShotImpl(int(interval.count()),
|
||||
timerType, receiver, slotObj);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -44,10 +44,8 @@
|
||||
#include <QtCore/qatomic.h>
|
||||
#include <new>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
# include <limits>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
|
||||
class tst_QMutex;
|
||||
|
||||
@ -66,7 +64,6 @@ class QMutex;
|
||||
class QRecursiveMutex;
|
||||
class QMutexPrivate;
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
namespace QtPrivate
|
||||
{
|
||||
template<class Rep, class Period>
|
||||
@ -92,7 +89,6 @@ namespace QtPrivate
|
||||
return ms < maxInt ? int(ms) : maxInt;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class Q_CORE_EXPORT QBasicMutex
|
||||
{
|
||||
|
@ -33,9 +33,7 @@
|
||||
#include <QTest>
|
||||
#include <QTimer>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
static const int minResolution = 400; // the minimum resolution for the tests
|
||||
|
||||
@ -520,9 +518,6 @@ void tst_QDeadlineTimer::expire()
|
||||
|
||||
void tst_QDeadlineTimer::stdchrono()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("std::chrono not found on this system");
|
||||
#else
|
||||
using namespace std::chrono;
|
||||
QFETCH_GLOBAL(Qt::TimerType, timerType);
|
||||
|
||||
@ -722,7 +717,6 @@ void tst_QDeadlineTimer::stdchrono()
|
||||
QVERIFY(deadline.deadline<steady_clock>() <= (steady_clock::now() + seconds(1) + milliseconds(minResolution)));
|
||||
QVERIFY(deadline.deadline<system_clock>() > (system_clock::now() + seconds(1) - milliseconds(minResolution)));
|
||||
QVERIFY(deadline.deadline<system_clock>() <= (system_clock::now() + seconds(1) + milliseconds(minResolution)));
|
||||
#endif
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QDeadlineTimer)
|
||||
|
@ -265,19 +265,14 @@ void tst_QTimer::remainingTimeDuringActivation()
|
||||
|
||||
namespace {
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
template <typename T>
|
||||
std::chrono::milliseconds to_ms(T t)
|
||||
{ return std::chrono::duration_cast<std::chrono::milliseconds>(t); }
|
||||
#endif
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
void tst_QTimer::basic_chrono()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires C++11 <chrono> support");
|
||||
#else
|
||||
// duplicates zeroTimer, singleShotTimeout, interval and remainingTime
|
||||
using namespace std::chrono;
|
||||
QTimer timer;
|
||||
@ -318,7 +313,6 @@ void tst_QTimer::basic_chrono()
|
||||
QCOMPARE(timeoutSpy.count(), 1);
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(timeoutSpy.count(), 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QTimer::livelock_data()
|
||||
@ -915,9 +909,6 @@ void tst_QTimer::singleShotToFunctors()
|
||||
|
||||
void tst_QTimer::singleShot_chrono()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires C++11 <chrono> support");
|
||||
#else
|
||||
// duplicates singleShotStaticFunctionZeroTimeout and singleShotToFunctors
|
||||
using namespace std::chrono;
|
||||
{
|
||||
@ -954,7 +945,6 @@ void tst_QTimer::singleShot_chrono()
|
||||
QTRY_COMPARE(count, 3);
|
||||
|
||||
_e.reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
class DontBlockEvents : public QObject
|
||||
|
@ -91,9 +91,7 @@ enum {
|
||||
waitTime = 100
|
||||
};
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
static constexpr std::chrono::milliseconds waitTimeAsDuration(waitTime);
|
||||
#endif
|
||||
|
||||
void tst_QMutex::convertToMilliseconds_data()
|
||||
{
|
||||
@ -102,10 +100,6 @@ void tst_QMutex::convertToMilliseconds_data()
|
||||
QTest::addColumn<qint64>("intValue");
|
||||
QTest::addColumn<qint64>("expected");
|
||||
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires <chrono>");
|
||||
#endif
|
||||
|
||||
auto add = [](TimeUnit unit, double d, long long i, qint64 expected) {
|
||||
const QScopedArrayPointer<char> enumName(QTest::toString(unit));
|
||||
QTest::addRow("%s:%f:%lld", enumName.data(), d, i)
|
||||
@ -158,9 +152,6 @@ void tst_QMutex::convertToMilliseconds_data()
|
||||
|
||||
void tst_QMutex::convertToMilliseconds()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires <chrono>");
|
||||
#else
|
||||
QFETCH(TimeUnit, unit);
|
||||
QFETCH(double, doubleValue);
|
||||
QFETCH(qint64, intValue);
|
||||
@ -198,7 +189,6 @@ void tst_QMutex::convertToMilliseconds()
|
||||
#undef DO
|
||||
#undef CASE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QMutex::tryLock_non_recursive()
|
||||
@ -326,10 +316,8 @@ void tst_QMutex::tryLock_non_recursive()
|
||||
thread.wait();
|
||||
}
|
||||
|
||||
void tst_QMutex::try_lock_for_non_recursive() {
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires <chrono>");
|
||||
#else
|
||||
void tst_QMutex::try_lock_for_non_recursive()
|
||||
{
|
||||
class Thread : public QThread
|
||||
{
|
||||
public:
|
||||
@ -451,14 +439,10 @@ void tst_QMutex::try_lock_for_non_recursive() {
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QMutex::try_lock_until_non_recursive()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires <chrono>");
|
||||
#else
|
||||
class Thread : public QThread
|
||||
{
|
||||
public:
|
||||
@ -580,7 +564,6 @@ void tst_QMutex::try_lock_until_non_recursive()
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QMutex::tryLock_recursive()
|
||||
@ -709,9 +692,6 @@ void tst_QMutex::tryLock_recursive()
|
||||
|
||||
void tst_QMutex::try_lock_for_recursive()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires <chrono>");
|
||||
#else
|
||||
class Thread : public QThread
|
||||
{
|
||||
public:
|
||||
@ -832,14 +812,10 @@ void tst_QMutex::try_lock_for_recursive()
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QMutex::try_lock_until_recursive()
|
||||
{
|
||||
#if !__has_include(<chrono>)
|
||||
QSKIP("This test requires <chrono>");
|
||||
#else
|
||||
class Thread : public QThread
|
||||
{
|
||||
public:
|
||||
@ -961,7 +937,6 @@ void tst_QMutex::try_lock_until_recursive()
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
class mutex_Thread : public QThread
|
||||
|
Loading…
x
Reference in New Issue
Block a user