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

Commit

Permalink
Expose pthread_mutex_lock_timeout_np to the NDK.
Browse files Browse the repository at this point in the history
The proper API for this isn't available until L, so expose this for
API levels earlier than that.

Test: make checkbuild
Bug: android/ndk#420
Change-Id: I382b8f557be9530f3e13aaae353b4a6e7f9301ab
  • Loading branch information
DanAlbert committed Jun 12, 2017
1 parent 4f61181 commit 8c67f1e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libc/include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ int pthread_mutex_timedlock(pthread_mutex_t* _Nonnull, const struct timespec* _N
int pthread_mutex_trylock(pthread_mutex_t* _Nonnull);
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.
*
* https://github.com/android-ndk/ndk/issues/420
*/
int pthread_mutex_lock_timeout_np(pthread_mutex_t* mutex, unsigned msecs);
#endif

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

int pthread_rwlockattr_init(pthread_rwlockattr_t* _Nonnull);
Expand Down

1 comment on commit 8c67f1e

@alexcohn
Copy link

Choose a reason for hiding this comment

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

As I showed in android/ndk#423, this patch is not enough. Please supply all defines and functions that were declared in pthread.h before android-21.

Please sign in to comment.