summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qelapsedtimer_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-08-10 16:14:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-28 07:13:23 +0100
commitbf5f2a9e3e3bf70c373b65bf95a332f4e1c514f9 (patch)
treeae2925a69f3f69854d7d0c30d2e51eee9dec321f /src/corelib/tools/qelapsedtimer_unix.cpp
parent5c5c9c26d299cd230dc48efcaaf3627861efa673 (diff)
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) <faure@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qelapsedtimer_unix.cpp')
-rw-r--r--src/corelib/tools/qelapsedtimer_unix.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp
index b0dbb1f047..f81a723aa5 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/tools/qelapsedtimer_unix.cpp
@@ -172,14 +172,14 @@ static inline void do_gettime(qint64 *sec, qint64 *frac)
}
// used in qcore_unix.cpp and qeventdispatcher_unix.cpp
-timeval qt_gettime() Q_DECL_NOTHROW
+struct timespec qt_gettime() Q_DECL_NOTHROW
{
qint64 sec, frac;
do_gettime(&sec, &frac);
- timeval tv;
+ timespec tv;
tv.tv_sec = sec;
- tv.tv_usec = frac / 1000;
+ tv.tv_nsec = frac;
return tv;
}