summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qwaitcondition_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-02-23 11:09:23 -0800
committerThiago Macieira <thiago.macieira@intel.com>2023-04-18 19:23:40 -0300
commit2a997942dbcc34ff1c9078edd2faff458da84081 (patch)
treebf7d06d7d8540d94b28bcdf3e326684f6533bb28 /src/corelib/thread/qwaitcondition_unix.cpp
parentccd3f2369a514a40c4d0427415bd7fcad9382002 (diff)
QWaitCondition/Android: remove support for relative time waits
This actually saves two clock_gettime(CLOCK_MONOTONIC) system calls (albeit to the vDSO): one inside QDeadlineTimer::remainingTimeNSecs() to calculate the remaining time from the deadline, then one other inside pthread_cond_timedwait_relative_np() to calculate the deadline from the timeout, so it can place the FUTEX_WAIT_BITSET system call. In fact, I can't find __pthread_cond_timedwait_relative() in the Bionic source any more. The last reference was removed in 2015, when Bionic started using FUTEX_WAIT_BITSET. So this commit is just removing dead code in current Android. Pick-to: 6.5 Change-Id: Ieec322d73c1e40ad95c8fffd174689c4fcff40ae Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/thread/qwaitcondition_unix.cpp')
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp24
1 files changed, 0 insertions, 24 deletions
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index 68fb92a0c8..ec215cfb23 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -22,17 +22,6 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_ANDROID
-// 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
-
static void report_error(int code, const char *where, const char *what)
{
if (code != 0)
@@ -49,13 +38,8 @@ void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
pthread_condattr_init(&condattr);
auto destroy = qScopeGuard([&] { pthread_condattr_destroy(&condattr); });
-#if defined(Q_OS_ANDROID)
- if (local_condattr_setclock)
- local_condattr_setclock(&condattr, CLOCK_MONOTONIC);
-#else
pthread_condattr_setclock(&condattr, CLOCK_MONOTONIC);
#endif
-#endif
report_error(pthread_cond_init(cond, attrp), where, "cv init");
}
@@ -91,14 +75,6 @@ public:
int wait_relative(QDeadlineTimer deadline)
{
timespec ti;
-#ifdef Q_OS_ANDROID
- if (!local_condattr_setclock && local_cond_timedwait_relative) {
- qint64 nsec = deadline.remainingTimeNSecs();
- ti.tv_sec = nsec / (1000 * 1000 * 1000);
- ti.tv_nsec = nsec - ti.tv_sec * 1000 * 1000 * 1000;
- return local_cond_timedwait_relative(&cond, &mutex, &ti);
- }
-#endif
qt_abstime_for_timeout(&ti, deadline);
return pthread_cond_timedwait(&cond, &mutex, &ti);
}