From bf5f2a9e3e3bf70c373b65bf95a332f4e1c514f9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Aug 2012 16:14:48 +0200 Subject: Switch to struct timespec everywhere instead of timeval This avoids an extra division by 1000 when getting the current time. This can't overflow, under normal circumstances, even on 32-bit: when adding two values less than 1 billion, the result is less than 2 billion, which is less than 2^31. Change-Id: I6f8e1aadfe2fcf6ac8da584eab4c1e61aee51cbb Reviewed-by: David Faure (KDE) Reviewed-by: Thiago Macieira --- src/corelib/kernel/qtimerinfo_unix_p.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/corelib/kernel/qtimerinfo_unix_p.h') diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h index 549062bd1f..ec7560429b 100644 --- a/src/corelib/kernel/qtimerinfo_unix_p.h +++ b/src/corelib/kernel/qtimerinfo_unix_p.h @@ -66,7 +66,7 @@ struct QTimerInfo { int id; // - timer identifier int interval; // - timer interval in milliseconds Qt::TimerType timerType; // - timer type - timeval timeout; // - when to actually fire + timespec timeout; // - when to actually fire QObject *obj; // - object to receive event QTimerInfo **activateRef; // - ref from activateTimers @@ -80,13 +80,13 @@ struct QTimerInfo { class Q_CORE_EXPORT QTimerInfoList : public QList { #if ((_POSIX_MONOTONIC_CLOCK-0 <= 0) && !defined(Q_OS_MAC)) || defined(QT_BOOTSTRAPPED) - timeval previousTime; + timespec previousTime; clock_t previousTicks; int ticksPerSecond; int msPerTick; - bool timeChanged(timeval *delta); - void timerRepair(const timeval &); + bool timeChanged(timespec *delta); + void timerRepair(const timespec &); #endif // state variables used by activateTimers() @@ -95,13 +95,13 @@ class Q_CORE_EXPORT QTimerInfoList : public QList public: QTimerInfoList(); - timeval currentTime; - timeval updateCurrentTime(); + timespec currentTime; + timespec updateCurrentTime(); // must call updateCurrentTime() first! void repairTimersIfNeeded(); - bool timerWait(timeval &); + bool timerWait(timespec &); void timerInsert(QTimerInfo *); int timerRemainingTime(int timerId); -- cgit v1.2.3