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. Change-Id: Ieec322d73c1e40ad95c8fffd174689c4fcff40ae Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 2a997942dbcc34ff1c9078edd2faff458da84081)
This commit is contained in:
parent
e53911842a
commit
01566b5d66
@ -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)
|
||||
@ -44,14 +33,9 @@ void qt_initialize_pthread_cond(pthread_cond_t *cond, const char *where)
|
||||
pthread_condattr_t condattr;
|
||||
|
||||
pthread_condattr_init(&condattr);
|
||||
#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)
|
||||
#if defined(CLOCK_MONOTONIC) && !defined(Q_OS_DARWIN)
|
||||
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);
|
||||
@ -89,14 +73,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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user