Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pthread_cancel not found compiling with android toolchain

I'm compiling a program that is configured using the Android Toolchain. I'm using ndk r10c. I made a standalone toolchain using

$./make-standalone-toolchain.sh --ndk-dir=/home/justin/bin/android-ndk-r10c/ --install-dir=/home/justin/android-toolchain/

and was able to configure my project, but when I make I get

error: 'pthread_cancel' was not declared in this scope

The header has #include <pthread.h> and this answer seems to indicate that I should be able to use pthreads as I normally would.

Am I missing something?

like image 620
JuJoDi Avatar asked Dec 10 '25 07:12

JuJoDi


1 Answers

Bionic (Android's libc) does not have pthread_cancel. IIRC, when we discussed adding this we chose not to because implementation of it is error prone and harmful to performance (of all code).

As far as we could tell, no implementation of pthreads implements a fully correct pthread_cancel. It would also impose a cost on all code, even if you're not using pthread_cancel (because so many sections of code need to be guarded from interruption by pthread_cancel).

like image 69
Dan Albert Avatar answered Dec 11 '25 22:12

Dan Albert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!