From 9108f258adad329a537e10461fbd526d5b9ad8bf Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 25 Feb 2023 00:22:25 +0000 Subject: [PATCH] Remove 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 --- libc/bionic/pthread_cond.cpp | 15 +++++++++++---- libc/bionic/pthread_mutex.cpp | 2 ++ libc/include/pthread.h | 17 ----------------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/libc/bionic/pthread_cond.cpp b/libc/bionic/pthread_cond.cpp index 793dcd942..f444676c7 100644 --- a/libc/bionic/pthread_cond.cpp +++ b/libc/bionic/pthread_cond.cpp @@ -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 diff --git a/libc/bionic/pthread_mutex.cpp b/libc/bionic/pthread_mutex.cpp index a15e98149..9b3722584 100644 --- a/libc/bionic/pthread_mutex.cpp +++ b/libc/bionic/pthread_mutex.cpp @@ -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); diff --git a/libc/include/pthread.h b/libc/include/pthread.h index 130a72f8a..fd1ebc373 100644 --- a/libc/include/pthread.h +++ b/libc/include/pthread.h @@ -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);