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.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...