diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 5ab1d510ef..241658acb1 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -90,7 +90,14 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, // loop and recalculate the timeout as needed int ret; forever { +#ifndef Q_OS_QNX ret = ::pselect(nfds, fdread, fdwrite, fdexcept, &timeout, 0); +#else + timeval timeoutVal; + timeoutVal.tv_sec = timeout.tv_sec; + timeoutVal.tv_usec = timeout.tv_nsec / 1000; + ret = ::select(nfds, fdread, fdwrite, fdexcept, &timeoutVal); +#endif if (ret != -1 || errno != EINTR) return ret; diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 3e958ee277..5206334c09 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -271,13 +271,13 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif } } -static inline int timevalToMillisecs(const timeval &tv) +static inline int timespecToMillisecs(const timespec &tv) { - return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); + return (tv.tv_sec * 1000) + (tv.tv_nsec / 1000000); } int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - timeval *timeout) + timespec *timeout) { Q_UNUSED(nfds); Q_D(QEventDispatcherBlackberry); @@ -306,9 +306,9 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef // Convert timeout to milliseconds int timeoutTotal = -1; if (timeout) - timeoutTotal = timevalToMillisecs(*timeout); + timeoutTotal = timespecToMillisecs(*timeout); int timeoutLeft = timeoutTotal; - timeval startTime = qt_gettime(); + timespec startTime = qt_gettime(); // This loop exists such that we can drain the bps event queue of all native events // more efficiently than if we were to return control to Qt after each event. This @@ -332,16 +332,16 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef // Update the timeout // Clock source is monotonic, so we can recalculate how much timeout is left if (timeoutTotal != -1) { - timeval t2 = qt_gettime(); + timespec t2 = qt_gettime(); timeoutLeft = timeoutTotal - - (timevalToMillisecs(t2) - timevalToMillisecs(startTime)); + - (timespecToMillisecs(t2) - timespecToMillisecs(startTime)); if (timeoutLeft < 0) timeoutLeft = 0; } - timeval tnext; + timespec tnext; if (d->timerList.timerWait(tnext)) { - int timeoutNext = timevalToMillisecs(tnext); + int timeoutNext = timespecToMillisecs(tnext); if (timeoutNext < timeoutLeft || timeoutTotal == -1) { timeoutTotal = timeoutLeft = timeoutNext; startTime = qt_gettime(); diff --git a/src/corelib/kernel/qeventdispatcher_blackberry_p.h b/src/corelib/kernel/qeventdispatcher_blackberry_p.h index 79ed21dbf2..5a4c3a9dcd 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry_p.h +++ b/src/corelib/kernel/qeventdispatcher_blackberry_p.h @@ -77,7 +77,7 @@ protected: QEventDispatcherBlackberry(QEventDispatcherBlackberryPrivate &dd, QObject *parent = 0); int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, - timeval *timeout); + timespec *timeout); int ioEvents(int fd); };