Android NDK和pthread

前端之家收集整理的这篇文章主要介绍了Android NDK和pthread前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 android NDK独立工具链编译Qt / C项目.我用make-standalone-toolchain.sh创建了独立工具链–arch = arm –toolchain = arm-linux-androideabi-4.9 –platform = android-21命令. NDK版本是android-ndk-r10e.目标项目使用pthread库中的一些函数.在编译时,我收到以下错误
error: 'pthread_getaffinity_np' was not declared in this scope
const int err = pthread_getaffinity_np(_pthreadId,sizeof(cpu_set_t),&cpuSetMask);
compilation terminated due to -Wfatal-errors.

我已经检查了ndk工具链中包含的pthread的标题,我没有找到pthread_getaffinity_np函数的声明.

Android的pthread功能是否有限?如何正确使用pthread与Android NDK?

解决方法

Android的pthread功能是否有限?

AFAIK,是的.

http://mobilepearls.com/labs/native-android-api/#pthreads

POSIX threads (pthreads)
The android libc,bionic,provides built-in support for pthreads,so no
additional linking (-lpthreads) is necessary. It does not implement full
POSIX threads functionality and leaves out support for read/write locks,pthread_cancel(),process-shared mutexes and condition variables as well as
other more advanced features. Read the bionic OVERVIEW.txt for more
information.

TLS,thread-local storage,is limited to 59 pthread_key_t slots available
to applications,lower than the posix minimum of 128.
原文链接:https://www.f2er.com/android/315550.html

猜你在找的Android相关文章