android - NDK builder r15 finds neither HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC nor pthread_condattr_setclock for some build targets; Build fails -


i have native code in project. use pthread monotonic time. i'm not in ndk development.

c code initialise , use condition monotonic clock:

int initmonotoniccond(pthread_cond_t *cond) {     int result = 0; #ifdef have_pthread_cond_timedwait_monotonic     result = pthread_cond_init(cond, null); #else     pthread_condattr_t cond1attr;     result |= pthread_condattr_init(&cond1attr);     result |= pthread_condattr_setclock(&cond1attr, clock_monotonic);     result |= pthread_cond_init(cond, &cond1attr);     pthread_condattr_destroy(&cond1attr); #endif     return result; }  void monothonicwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *ts) { #ifdef have_pthread_cond_timedwait_monotonic     pthread_cond_timedwait_monotonic_np(cond, mutex, ts); #else     pthread_cond_timedwait(cond, mutex, ts); #endif } 

gradle builds ndk project with

android {     compilesdkversion 25     buildtoolsversion "25.0.2"      defaultconfig {         minsdkversion 16         targetsdkversion 24     }      buildtypes {         release {             minifyenabled false             proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro'              externalnativebuild {                 cmake {                     cppflags "-fexceptions -frtti -fpie -fpic"                     abifilters "armeabi-v7a", "armeabi", "arm64-v8a", "x86", "x86_64", "mips", "mips64"                 }             }         }         debug {             externalnativebuild {                 cmake {                     cppflags "-fexceptions -frtti -fpie -funwind-tables -ddebug -fpic"                     abifilters "armeabi"                 }             }         }     } ..... } 

recently i've updated android studio , sdk stuff newer version. , ndk build r15, guess. , i'm getting , error when building:

error:(155, 15) error: use of undeclared identifier 'pthread_condattr_setclock'; did mean 'pthread_condattr_setpshared'?

after research i've fount have_pthread_cond_timedwait_monotonic (and pthread_cond_timedwait_monotonic_np) should defined non-x64 targets ("armeabi-v7a", "armeabi", "x86", "mips"). , defined. not defined now.

so, "armeabi-v7a", "x86", "mips" not have defined nither have_pthread_cond_timedwait_monotonic nor pthread_condattr_setclock defined, project can't built theese targets.

so, what's reason , options have?

should not use monothonic wait targets way?

should not build targets?

should revert older ndk?

or should write google groups that?

pthread_condattr_setclock added in android-21: https://android.googlesource.com/platform/bionic/+/master/libc/libc.map.txt#780, that's why can't access on older releases.

have_pthread_cond_timedwait_monotonic apparently defined in old headers. shouldn't have been (not name, anyway). names convention used autoconf generated things, , shouldn't overlapping because can cause amcro redefinition warnings. better way write check is:

#if defined(__android_api__) && __android_api__ >= 21 

that's still not quite enough building again though, since declaration pthread_cond_timedwait_monotonic_np disappeared headers when actual posix apis got added. i've uploaded change declaration re-added sake of compatibility: https://android-review.googlesource.com/420945

unfortunately it's late make r15b. in meantime add own declaration function:

extern "c" int pthread_cond_timedwait_monotonic_np(     pthread_cond_t*, pthread_mutex_t*, const struct timespec*); 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -