mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
scope the monotonic clock check to QElapsedTimer::isMonotonic()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0fa8602e7b
commit
3b89abc643
1 changed files with 8 additions and 8 deletions
|
@ -27,20 +27,20 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#if defined(_SC_MONOTONIC_CLOCK)
|
|
||||||
static const bool monotonicClockAvailable = (sysconf(_SC_MONOTONIC_CLOCK) >= 200112L);
|
|
||||||
#else
|
|
||||||
static const bool monotonicClockAvailable = (_POSIX_MONOTONIC_CLOCK > 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool QElapsedTimer::isMonotonic()
|
bool QElapsedTimer::isMonotonic()
|
||||||
{
|
{
|
||||||
|
#if defined(_SC_MONOTONIC_CLOCK)
|
||||||
|
static const bool monotonicClockAvailable = (sysconf(_SC_MONOTONIC_CLOCK) >= 200112L);
|
||||||
|
#else
|
||||||
|
static const bool monotonicClockAvailable = (_POSIX_MONOTONIC_CLOCK > 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
return monotonicClockAvailable;
|
return monotonicClockAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
QElapsedTimer::ClockType QElapsedTimer::clockType()
|
QElapsedTimer::ClockType QElapsedTimer::clockType()
|
||||||
{
|
{
|
||||||
if (Q_LIKELY(monotonicClockAvailable)) {
|
if (Q_LIKELY(QElapsedTimer::isMonotonic())) {
|
||||||
return QElapsedTimer::MonotonicClock;
|
return QElapsedTimer::MonotonicClock;
|
||||||
}
|
}
|
||||||
return QElapsedTimer::SystemTime;
|
return QElapsedTimer::SystemTime;
|
||||||
|
@ -49,7 +49,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType()
|
||||||
static inline void do_gettime(qint64 *sec, qint64 *frac)
|
static inline void do_gettime(qint64 *sec, qint64 *frac)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if (Q_LIKELY(monotonicClockAvailable)) {
|
if (Q_LIKELY(QElapsedTimer::isMonotonic())) {
|
||||||
::clock_gettime(CLOCK_MONOTONIC, &ts);
|
::clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
} else {
|
} else {
|
||||||
::clock_gettime(CLOCK_REALTIME, &ts);
|
::clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
|
Loading…
Add table
Reference in a new issue