Remove preprocessor conditionals for chrono include
__has_include(<chrono>) is always true, because C++11 chrono include is required since 6.0. Pick-to: 6.4 6.3 6.2 Change-Id: I50cb92571bf4f1f86e2f3f2b5f486dd3c3f30f4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
22d4c67234
commit
ec2af0a9df
@ -7,9 +7,7 @@
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -30,7 +28,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())); }
|
||||
@ -39,7 +36,6 @@ public:
|
||||
{
|
||||
return std::chrono::milliseconds(staleLockTime());
|
||||
}
|
||||
#endif
|
||||
|
||||
bool isLocked() const;
|
||||
bool getLockInfo(qint64 *pid, QString *hostname, QString *appname) const;
|
||||
|
@ -16,9 +16,7 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -84,7 +82,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)
|
||||
@ -142,7 +139,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;
|
||||
@ -156,7 +152,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
|
||||
|
||||
|
@ -20,9 +20,7 @@
|
||||
#include <QtCore/qobject_impl.h>
|
||||
#include <QtCore/qbindingstorage.h>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -128,13 +126,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>
|
||||
|
@ -11,9 +11,7 @@
|
||||
#include <QtCore/qbasictimer.h> // conceptual inheritance
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
#endif
|
||||
#include <chrono>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -145,7 +143,6 @@ Q_SIGNALS:
|
||||
void timeout(QPrivateSignal);
|
||||
|
||||
public:
|
||||
#if __has_include(<chrono>) || defined(Q_QDOC)
|
||||
void setInterval(std::chrono::milliseconds value)
|
||||
{
|
||||
setInterval(int(value.count()));
|
||||
@ -175,7 +172,6 @@ public:
|
||||
{
|
||||
start(int(value.count()));
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *) override;
|
||||
@ -192,7 +188,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())); }
|
||||
|
||||
@ -202,7 +197,6 @@ private:
|
||||
singleShotImpl(int(interval.count()),
|
||||
timerType, receiver, slotObj);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -9,10 +9,8 @@
|
||||
#include <QtCore/qtsan_impl.h>
|
||||
#include <new>
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
# include <chrono>
|
||||
# include <limits>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
|
||||
class tst_QMutex;
|
||||
|
||||
@ -31,7 +29,6 @@ class QMutex;
|
||||
class QRecursiveMutex;
|
||||
class QMutexPrivate;
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
namespace QtPrivate
|
||||
{
|
||||
template<class Rep, class Period>
|
||||
@ -57,7 +54,6 @@ namespace QtPrivate
|
||||
return ms < maxInt ? int(ms) : maxInt;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
class Q_CORE_EXPORT QBasicMutex
|
||||
{
|
||||
|
@ -8,9 +8,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
|
||||
|
||||
@ -495,9 +493,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);
|
||||
|
||||
@ -697,7 +692,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)
|
||||
|
@ -240,19 +240,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;
|
||||
@ -293,7 +288,6 @@ void tst_QTimer::basic_chrono()
|
||||
QCOMPARE(timeoutSpy.count(), 1);
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(timeoutSpy.count(), 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QTimer::livelock_data()
|
||||
@ -890,9 +884,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;
|
||||
{
|
||||
@ -929,7 +920,6 @@ void tst_QTimer::singleShot_chrono()
|
||||
QTRY_COMPARE(count, 3);
|
||||
|
||||
_e.reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
class DontBlockEvents : public QObject
|
||||
|
@ -67,9 +67,7 @@ enum {
|
||||
waitTime = 100
|
||||
};
|
||||
|
||||
#if __has_include(<chrono>)
|
||||
static constexpr std::chrono::milliseconds waitTimeAsDuration(waitTime);
|
||||
#endif
|
||||
|
||||
void tst_QMutex::convertToMilliseconds_data()
|
||||
{
|
||||
@ -78,10 +76,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)
|
||||
@ -134,9 +128,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);
|
||||
@ -174,7 +165,6 @@ void tst_QMutex::convertToMilliseconds()
|
||||
#undef DO
|
||||
#undef CASE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QMutex::tryLock_non_recursive()
|
||||
@ -302,10 +292,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:
|
||||
@ -427,14 +415,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:
|
||||
@ -556,7 +540,6 @@ void tst_QMutex::try_lock_until_non_recursive()
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QMutex::tryLock_recursive()
|
||||
@ -685,9 +668,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:
|
||||
@ -808,14 +788,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:
|
||||
@ -937,7 +913,6 @@ void tst_QMutex::try_lock_until_recursive()
|
||||
testsTurn.acquire();
|
||||
threadsTurn.release();
|
||||
thread.wait();
|
||||
#endif
|
||||
}
|
||||
|
||||
class mutex_Thread : public QThread
|
||||
|
Loading…
Reference in New Issue
Block a user