On Friday 12 June 2015 16:16:57 Lenahan, Charlie wrote:
> This was covered in an earlier thread ~5/21/15 , that symbol was for
> android-21, which is what the build is set for.
>
> To run it on an older device you will have to change what it is targeting.
For older devices, Bionic doesn't provide a way to set the clock type, but you
can sleep for an interval using __pthread_cond_timedwait_relative.
This is code I wrote for qwaitcondition_unix.cpp:
#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
On initialisation:
#ifdef Q_OS_ANDROID
if (local_condattr_setclock)
local_condattr_setclock(&condattr, CLOCK_MONOTONIC);
#endif
On use:
#ifdef Q_OS_ANDROID
if (local_cond_timedwait_relative)
return local_cond_timedwait_relative(&cond, &mutex, &ti);
#endif
ti = calculate_abstime(ti);
return pthread_cond_timedwait(&cond, &mutex, &ti);
GCC is pending an optimisation to avoid both a GOT and a PLT entry for weakref
functions, but this works.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center