Remove <pthread.h> cruft.

The next NDK to take these headers only supports API 21 and later.

Note that this change leaves the _implementation_ of these functions
behind, so that any old apps calling these APIs should continue to work,
you just can't (without declaring the functions yourself) write new ones
that do (and declaring the functions yourself would only work on LP32
anyway, so that's not going to get you very far in 2023).

Test: treehugger
Change-Id: Ie03514e4215b40f6e9feaa6e4bf5df5b16dc8d59
This commit is contained in:
Elliott Hughes 2023-02-25 00:22:25 +00:00
parent 20cd43a66d
commit 9108f258ad
3 changed files with 13 additions and 21 deletions

View file

@ -249,15 +249,18 @@ int pthread_cond_clockwait(pthread_cond_t* cond_interface, pthread_mutex_t* mute
}
#if !defined(__LP64__)
// TODO: this exists only for backward binary compatibility on 32 bit platforms.
// This exists only for backward binary compatibility on 32 bit platforms.
// (This is actually a _new_ function in API 28 that we could only implement for LP64.)
extern "C" int pthread_cond_timedwait_monotonic(pthread_cond_t* cond_interface,
pthread_mutex_t* mutex,
const timespec* abs_timeout) {
return pthread_cond_timedwait_monotonic_np(cond_interface, mutex, abs_timeout);
}
#endif
// Force this function using CLOCK_MONOTONIC because it was always using
// CLOCK_MONOTONIC in history.
#if !defined(__LP64__)
// This exists only for backward binary compatibility on 32 bit platforms.
// (This function never existed for LP64.)
extern "C" int pthread_cond_timedwait_relative_np(pthread_cond_t* cond_interface,
pthread_mutex_t* mutex,
const timespec* rel_timeout) {
@ -269,11 +272,15 @@ extern "C" int pthread_cond_timedwait_relative_np(pthread_cond_t* cond_interface
}
return __pthread_cond_timedwait(__get_internal_cond(cond_interface), mutex, false, abs_timeout);
}
#endif
#if !defined(__LP64__)
// This exists only for backward binary compatibility on 32 bit platforms.
// (This function never existed for LP64.)
extern "C" int pthread_cond_timeout_np(pthread_cond_t* cond_interface,
pthread_mutex_t* mutex, unsigned ms) {
timespec ts;
timespec_from_ms(ts, ms);
return pthread_cond_timedwait_relative_np(cond_interface, mutex, &ts);
}
#endif // !defined(__LP64__)
#endif

View file

@ -945,6 +945,8 @@ int pthread_mutex_trylock(pthread_mutex_t* mutex_interface) {
}
#if !defined(__LP64__)
// This exists only for backward binary compatibility on 32 bit platforms.
// (This function never existed for LP64.)
extern "C" int pthread_mutex_lock_timeout_np(pthread_mutex_t* mutex_interface, unsigned ms) {
timespec ts;
timespec_from_ms(ts, ms);

View file

@ -207,23 +207,6 @@ int pthread_mutex_timedlock_monotonic_np(pthread_mutex_t* __mutex, const struct
int pthread_mutex_trylock(pthread_mutex_t* __mutex);
int pthread_mutex_unlock(pthread_mutex_t* __mutex);
#if __ANDROID_API__ < 21
/*
* Cruft for supporting old API levels. Pre-L we didn't have the proper POSIX
* APIs for things, but instead had some locally grown, artisan equivalents.
* Keep exposing the old prototypes on old API levels so we don't regress
* functionality.
*
* See the following bugs:
* * https://github.com/android-ndk/ndk/issues/420
* * https://github.com/android-ndk/ndk/issues/423
* * https://stackoverflow.com/q/44580542/632035
*/
int pthread_mutex_lock_timeout_np(pthread_mutex_t* __mutex, unsigned __timeout_ms);
int pthread_cond_timeout_np(pthread_cond_t* __cond, pthread_mutex_t* __mutex, unsigned __timeout_ms);
int pthread_cond_timedwait_relative_np(pthread_cond_t* __cond, pthread_mutex_t* __mutex, const struct timespec* __relative_timeout);
#endif
int pthread_once(pthread_once_t* __once, void (*__init_routine)(void));
int pthread_rwlockattr_init(pthread_rwlockattr_t* __attr);