Modify

Opened 3 years ago

Closed 3 years ago

#11035 closed Bugs (fixed)

BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE not defined for Android

Reported by: kervala@… 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)

boost_recursive_mutex.patch (2.6 KB) - added by kervala@… 3 years ago.
boost::recursive_mutex fix for Android
boost_recursive_mutex.2.patch (2.6 KB) - added by Cédric OCHS <kervala@…> 3 years ago.
Fix of the patch
boost_recursive_mutex.3.patch (1.9 KB) - added by Cédric OCHS <kervala@…> 3 years ago.

Download all attachments as: .zip

Change History (13)

Changed 3 years ago by kervala@…

Attachment: boost_recursive_mutex.patch added

boost::recursive_mutex fix for Android

Changed 3 years ago by Cédric OCHS <kervala@…>

Fix of the patch

comment:1 Changed 3 years ago by Cédric OCHS <kervala@…>

Please ignore the first patch, I forgot to remove a #endif

Changed 3 years ago by Cédric OCHS <kervala@…>

comment:2 Changed 3 years ago by Cédric OCHS <kervala@…>

Summary: BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE and BOOST_PTHREAD_HAS_TIMEDLOCK not defined for AndroidBOOST_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 Changed 3 years ago by viboes

Owner: changed from Anthony Williams to Niall Douglas

Since which version of Android the 3rd patch is valid?

comment:4 Changed 3 years ago by Cédric OCHS <kervala@…>

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 Changed 3 years ago by Niall Douglas

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:6 Changed 3 years ago by Cédric OCHS <kervala@…>

You're welcome :)

comment:7 Changed 3 years ago by viboes

@Niall: if V2 is the minimal version, could this restriction be encoded on the config.hpp file.

comment:8 Changed 3 years ago by viboes

Owner: changed from Niall Douglas to viboes
Status: newassigned

You should create a ticket and a patch for Boost Config (boost/config/posix_features.hpp).

I will fix this soon.

comment:10 Changed 3 years ago by viboes

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.