Opened 8 years ago
Closed 8 years ago
#11035 closed Bugs (fixed)
BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE not defined for Android
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.58.0 | Component: | thread |
Version: | Boost 1.57.0 | Severity: | Problem |
Keywords: | android recursive_mutex | Cc: |
Description
I'm using boost::recursive_mutex under Android and I noticed they don't work as expected, they are working like standard mutex.
After further investigation, I noticed BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE and BOOST_PTHREAD_HAS_TIMEDLOCK were not defined for Android because Android NDK don't declare _POSIX_TIMEOUTS neither _XOPEN_SOURCE that are checked in boost. So boost::recursive_mutex are not recursive at all under Android :(
Also pthread_mutex_timedlock signature changed since Android 5.0 (API 21), the version with the const struct is used from API 21 while previous versions were using the same without the const.
from API 3 to 20: int pthread_mutex_timedlock(pthread_mutex_t *mutex, struct timespec* ts);
from API 21: int pthread_mutex_timedlock(pthread_mutex_t*, const struct timespec*) nonnull((1, 2));
I have some patches to fix these issues :)
Attachments (3)
Change History (13)
by , 8 years ago
Attachment: | boost_recursive_mutex.patch added |
---|
by , 8 years ago
Attachment: | boost_recursive_mutex.3.patch added |
---|
comment:2 by , 8 years ago
Summary: | BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE and BOOST_PTHREAD_HAS_TIMEDLOCK not defined for Android → BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE not defined for Android |
---|
I'm sorry, I didn't notice pthread_mutex_timedlock wasn't implemented in bionic before Android API 21, although it was defined in oldest ARM headers (a Google bug in this case).
So I updated my patch for a 3rd time :)
comment:3 by , 8 years ago
Owner: | changed from | to
---|
Since which version of Android the 3rd patch is valid?
comment:4 by , 8 years ago
Thanks for your reply :)
It's valid since Android API 3 (Android 1.5).
I checked all pthread.h header from all Android versions supported by NDK.
comment:5 by , 8 years ago
Just for the record, I don't think Boost should support Android before v2. But thanks for the patch, this stuff is exactly why my client funded getting a regular CI going for Android.
comment:7 by , 8 years ago
@Niall: if V2 is the minimal version, could this restriction be encoded on the config.hpp file.
comment:8 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
You should create a ticket and a patch for Boost Config (boost/config/posix_features.hpp).
I will fix this soon.
comment:9 by , 8 years ago
Milestone: | To Be Determined → Boost 1.58.0 |
---|
comment:10 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
boost::recursive_mutex fix for Android