From dec81ad2dac347ae380f405eb2a58d0a4d0abad4 Mon Sep 17 00:00:00 2001 From: Roger Maclean Date: Tue, 9 Dec 2014 11:44:50 -0500 Subject: QNX: Revert the change to give higher precision timers. The previous change (SHA 82c2118c) to provide better than 1ms accuracy for timers on QNX is not safe. According to the docs, ClockCycles is not guaranteed to return consistent information if called from different CPUs. While this can be addressed by locking the thread to a single CPU, you wouldn't want to do that here. On some systems (e.g. BB10) the behavior is extremely bad since ClockCycles only has 32 bits of precision. This results in overflows in the calculations making short timers run very slowly (16ms timers were around 1s). Also ClockCycles wraps in under three minutes causing even more problems. I've talked to the kernel developers and there is currently nothing that will give you better than 1ms accuracy. An individual program could use ClockCycles to calculate more accurate times if they want. It's not clear to me what benefit one would get with increased accuracy. Unless I've missed something, these times are only used to calculate timeouts for calls such as select. These timeouts will themselves have the same resolution as clock_gettime provides so the increased accuracy would appear to be for naught. Change-Id: Ia38b154ca41949becbd0b8558a9ff4ddd5e01a43 Reviewed-by: Thiago Macieira Reviewed-by: Bernd Weimer Reviewed-by: Oswald Buddenhagen Reviewed-by: Rafael Roquetto --- src/corelib/tools/qelapsedtimer_unix.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'src/corelib/tools/qelapsedtimer_unix.cpp') diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index 9dd5df0266..d29447fa03 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -37,10 +37,6 @@ #include "qelapsedtimer.h" #if defined(Q_OS_VXWORKS) #include "qfunctions_vxworks.h" -#elif defined(Q_OS_QNX) -#include -#include -#include #else #include #include @@ -88,18 +84,7 @@ QT_BEGIN_NAMESPACE * see http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html */ -#if defined(Q_OS_QNX) -static inline void qt_clock_gettime(clockid_t clock, struct timespec *ts) -{ - // The standard POSIX clock calls only have 1ms accuracy on QNX. To get - // higher accuracy, this platform-specific function must be used instead - quint64 cycles_per_sec = SYSPAGE_ENTRY(qtime)->cycles_per_sec; - quint64 cycles = ClockCycles(); - ts->tv_sec = cycles / cycles_per_sec; - quint64 mod = cycles % cycles_per_sec; - ts->tv_nsec = mod * Q_INT64_C(1000000000) / cycles_per_sec; -} -#elif !defined(CLOCK_REALTIME) +#if !defined(CLOCK_REALTIME) # define CLOCK_REALTIME 0 static inline void qt_clock_gettime(int, struct timespec *ts) { -- cgit v1.2.3