Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Put back more legacy pthread APIs.
Browse files Browse the repository at this point in the history
Test: make checkbuild
Bug: android/ndk#423
Bug: https://stackoverflow.com/q/44580542/632035
Change-Id: Ibf52a969afffbfcdf6793a0bf8b0e10bbdd1f32c
  • Loading branch information
DanAlbert committed Jun 22, 2017
1 parent 814e3a2 commit c2ce120
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions libc/include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,22 @@ int pthread_mutex_unlock(pthread_mutex_t* _Nonnull);

#if defined(__LP32__) && __ANDROID_API__ < 21
/*
* Cruft for supporting old API levels. Pre-L we didn't have
* pthread_mutex_timedlock, instead we had pthread_mutex_lock_timeout_np. NDK
* users targeting pre-L still need this, but anyone targeting L or newer (or
* LP64 code) should just use pthread_mutex_timedlock.
* 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.
*
* https://github.com/android-ndk/ndk/issues/420
* 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 msecs);
int pthread_cond_timeout_np(pthread_cond_t* cond, pthread_mutex_t* mutex, unsigned msecs);
int pthread_cond_timedwait_monotonic_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);
int pthread_cond_timedwait_relative_np(pthread_cond_t* cond, pthread_mutex_t* mutex,
const struct timespec* reltime);
#endif

int pthread_once(pthread_once_t* _Nonnull, void (* _Nonnull init_routine)(void));
Expand Down

1 comment on commit c2ce120

@alexcohn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix missed

#define HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC 1

and thus WebRTC breaks for webrtc/system_wrappers/source/event_timer_posix.cc when built with ANDROID_API < 21.

Please # to comment.