summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qwaitcondition_unix.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-02-24 17:19:40 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-02-24 21:02:08 +0100
commit34b14a8472f44f8517577756e033b92ebd4c5912 (patch)
tree66a0575156d0a17a835430137e218e2b3f04cc65 /src/corelib/thread/qwaitcondition_unix.cpp
parentd34353a065c443aac20376cbd88323480d769183 (diff)
parentedd555425a08f9e074f0a4d9333862636ccaae8d (diff)
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts: examples/xml/htmlinfo/simpleexample.html examples/xml/rsslisting/rsslisting.cpp qmake/generators/win32/msbuild_objectmodel.cpp src/3rdparty/harfbuzz-ng/src/hb-private.hh src/corelib/global/qlogging.cpp src/corelib/io/qstorageinfo_unix.cpp src/corelib/thread/qwaitcondition_unix.cpp src/gui/kernel/qguiapplication.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp src/testlib/doc/src/qt-webpages.qdoc tests/auto/other/qaccessibility/tst_qaccessibility.cpp Change-Id: Ib272ff0bc30a1a5d51275eb3cd2f201dc82c11ff
Diffstat (limited to 'src/corelib/thread/qwaitcondition_unix.cpp')
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index 90dfcb7ba1..fd6af7db39 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -52,9 +52,12 @@
QT_BEGIN_NAMESPACE
#ifdef Q_OS_ANDROID
-// Android lacks pthread_condattr_setclock, but it does have a nice function
-// for relative waits. Use weakref so we can determine at runtime whether it is
-// present.
+// pthread_condattr_setclock is available only since Android 5.0. On older versions, there's
+// a private function for relative waits (hidden in 5.0).
+// Use weakref so we can determine at runtime whether each of them is present.
+static int local_condattr_setclock(pthread_condattr_t*, clockid_t)
+__attribute__((weakref("pthread_condattr_setclock")));
+
static int local_cond_timedwait_relative(pthread_cond_t*, pthread_mutex_t *, const timespec *)
__attribute__((weakref("__pthread_cond_timedwait_relative")));
#endif
@@ -70,10 +73,15 @@ void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
pthread_condattr_t condattr;
pthread_condattr_init(&condattr);
-#if !defined(Q_OS_MAC) && !defined(Q_OS_ANDROID) && !defined(Q_OS_HAIKU) && (_POSIX_MONOTONIC_CLOCK-0 >= 0)
+#if (_POSIX_MONOTONIC_CLOCK-0 >= 0)
+#if defined(Q_OS_ANDROID)
+ if (local_condattr_setclock && QElapsedTimer::clockType() == QElapsedTimer::MonotonicClock)
+ local_condattr_setclock(&condattr, CLOCK_MONOTONIC);
+#elif !defined(Q_OS_MAC) && !defined(Q_OS_HAIKU)
if (QElapsedTimer::clockType() == QElapsedTimer::MonotonicClock)
pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
#endif
+#endif
report_error(pthread_cond_init(cond, &condattr), where, "cv init");
pthread_condattr_destroy(&condattr);
}
@@ -108,7 +116,7 @@ public:
{
timespec ti;
#ifdef Q_OS_ANDROID
- if (Q_LIKELY(local_cond_timedwait_relative)) {
+ if (local_cond_timedwait_relative) {
ti.tv_sec = time / 1000;
ti.tv_nsec = time % 1000 * Q_UINT64_C(1000) * 1000;
return local_cond_timedwait_relative(&cond, &mutex, &ti);