diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-07-23 11:14:35 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-07-23 11:16:27 (GMT) |
commit | c2fe149aa4bc5ca212fcee3d149abb96098f31b5 (patch) | |
tree | f9720f61f3fd0e3e960e7fba8ab5518ad54d7580 | |
parent | 7ade13540e6caa6449c02a8832e670a499e97189 (diff) | |
download | Qt-c2fe149aa4bc5ca212fcee3d149abb96098f31b5.zip Qt-c2fe149aa4bc5ca212fcee3d149abb96098f31b5.tar.gz Qt-c2fe149aa4bc5ca212fcee3d149abb96098f31b5.tar.bz2 |
Omit monotonic timer detection/conditional code on Mac OS X
Now that we have a monotonic time source on the Mac, we don't need to
compile in the code to detect wall-time changes and do timer
adjustments.
Reviewed-by: nrc
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_unix.cpp | 30 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_unix_p.h | 2 |
2 files changed, 14 insertions, 18 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 9deb78f..fac8a28 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -291,9 +291,6 @@ QTimerInfoList::QTimerInfoList() msPerTick = 0; } #else -# if defined(Q_OS_MAC) - useMonotonicTimers = true; -# endif // using monotonic timers unconditionally getTime(currentTime); #endif @@ -307,7 +304,7 @@ timeval QTimerInfoList::updateCurrentTime() return currentTime; } -#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED) +#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED) /* Returns true if the real time clock has changed by more than 10% @@ -342,19 +339,7 @@ bool QTimerInfoList::timeChanged(timeval *delta) void QTimerInfoList::getTime(timeval &t) { -#if defined(Q_OS_MAC) - { - static mach_timebase_info_data_t info = {0,0}; - if (info.denom == 0) - mach_timebase_info(&info); - - uint64_t cpu_time = mach_absolute_time(); - uint64_t nsecs = cpu_time * (info.numer / info.denom); - t.tv_sec = nsecs * 1e-9; - t.tv_usec = nsecs * 1e-3 - (t.tv_sec * 1e6); - return; - } -#elif !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED) +#if !defined(QT_NO_CLOCK_MONOTONIC) && !defined(QT_BOOTSTRAPPED) if (useMonotonicTimers) { timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -394,10 +379,21 @@ void QTimerInfoList::repairTimersIfNeeded() void QTimerInfoList::getTime(timeval &t) { +#if defined(Q_OS_MAC) + static mach_timebase_info_data_t info = {0,0}; + if (info.denom == 0) + mach_timebase_info(&info); + + uint64_t cpu_time = mach_absolute_time(); + uint64_t nsecs = cpu_time * (info.numer / info.denom); + t.tv_sec = nsecs * 1e-9; + t.tv_usec = nsecs * 1e-3 - (t.tv_sec * 1e6); +#else timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); t.tv_sec = ts.tv_sec; t.tv_usec = ts.tv_nsec / 1000; +#endif } void QTimerInfoList::repairTimersIfNeeded() diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h index d1f7431..ebba21b 100644 --- a/src/corelib/kernel/qeventdispatcher_unix_p.h +++ b/src/corelib/kernel/qeventdispatcher_unix_p.h @@ -116,7 +116,7 @@ struct QTimerInfo { class QTimerInfoList : public QList<QTimerInfo*> { -#if (_POSIX_MONOTONIC_CLOCK-0 <= 0) || defined(QT_BOOTSTRAPPED) +#if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED) bool useMonotonicTimers; timeval previousTime; |