Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add monotonic time support with np pthread_cond_timedwait for Android and Apple#412

Open
vvydria wants to merge 1 commit intoboostorg:developboostorg/thread:developfrom
vvydria:improvement/pthread_cond_timedwait_android_apple_npvvydria/thread:improvement/pthread_cond_timedwait_android_apple_npCopy head branch name to clipboard
Open

Add monotonic time support with np pthread_cond_timedwait for Android and Apple#412
vvydria wants to merge 1 commit intoboostorg:developboostorg/thread:developfrom
vvydria:improvement/pthread_cond_timedwait_android_apple_npvvydria/thread:improvement/pthread_cond_timedwait_android_apple_npCopy head branch name to clipboard

Conversation

@vvydria
Copy link

@vvydria vvydria commented Feb 17, 2025

Improvements.

Android and Apple support none-portable functions for monotonic pthread cond wait.

Apple supports pthread_cond_timedwait_relative_np since macos(10.4) and ios(2.0): https://github.com/apple/darwin-libpthread/blob/main/include/pthread/pthread.h#L532

Android up to __ANDROID_API__ < 21 supports pthread_cond_timedwait_monotonic_np and pthread_cond_timedwait_relative_np.

Note that in some versions of the NDK, these symbols were removed from the header file(https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r13-release/libc/include/pthread.h) although they were present in the libc.map( https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r13-release/libc/libc.map.txt#779) and cpp(https://android.googlesource.com/platform/bionic/+/refs/heads/ndk-r13-release/libc/bionic/pthread_cond.cpp#221).

A workaround is to declare these functions as follows:
extern "C" int pthread_cond_timedwait_[monotonic|relative]_np(pthread_cond_t*, pthread_mutex_t*, const struct timespec*);

See related comments on this: https://android.googlesource.com/platform/bionic.git/+/refs/heads/ndk-release-r16/libc/include/pthread.h#162

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.