diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-10 16:14:48 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-28 07:13:23 +0100 |
commit | bf5f2a9e3e3bf70c373b65bf95a332f4e1c514f9 (patch) | |
tree | ae2925a69f3f69854d7d0c30d2e51eee9dec321f /src/corelib/kernel/qeventdispatcher_unix.cpp | |
parent | 5c5c9c26d299cd230dc48efcaaf3627861efa673 (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/kernel/qeventdispatcher_unix.cpp')
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_unix.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index 233b7eef2f..c79fe89105 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -173,7 +173,7 @@ QEventDispatcherUNIXPrivate::~QEventDispatcherUNIXPrivate() qDeleteAll(timerList); } -int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, timeval *timeout) +int QEventDispatcherUNIXPrivate::doSelect(QEventLoop::ProcessEventsFlags flags, timespec *timeout) { Q_Q(QEventDispatcherUNIX); @@ -327,7 +327,7 @@ QEventDispatcherUNIX::~QEventDispatcherUNIX() } int QEventDispatcherUNIX::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - timeval *timeout) + timespec *timeout) { return qt_safe_select(nfds, readfds, writefds, exceptfds, timeout); } @@ -600,8 +600,8 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags) if (!d->interrupt) { // return the maximum time we can wait for an event. - timeval *tm = 0; - timeval wait_tm = { 0l, 0l }; + timespec *tm = 0; + timespec wait_tm = { 0l, 0l }; if (!(flags & QEventLoop::X11ExcludeTimers)) { if (d->timerList.timerWait(wait_tm)) tm = &wait_tm; @@ -613,7 +613,7 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags) // no time to wait tm->tv_sec = 0l; - tm->tv_usec = 0l; + tm->tv_nsec = 0l; } nevents = d->doSelect(flags, tm); |