Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clock_gettime is not used on Android, even though available (1.6.0+) #1866

Closed
hungrycat opened this issue Sep 4, 2024 · 2 comments
Closed
Labels

Comments

@hungrycat
Copy link

hungrycat commented Sep 4, 2024

Describe the bug
Android has its own implementation of the system libraries: https://android.googlesource.com/platform/bionic.
clock_gettime is made available in libc, not in librt like on some other POSIX platforms. Yet, the check in the build system assumes clock_gettime is in librt:

From src/platform/posix/CMakeLists.txt:

nng_check_lib(rt clock_gettime NNG_HAVE_CLOCK_GETTIME)

As a consequence, on Android NNG_HAVE_CLOCK_GETTIME is never set, and fallback to nni_clock is used instead of clock_gettime. As documented in the file, this severely hinders stability of nng on that platform

To Reproduce
Build for Android, assert in posix_clock.c on which implementation is used. Expectation: clock_gettime.

Environment Details

@hungrycat
Copy link
Author

Possible solution:
clock_gettime.patch

hungrycat added a commit to hungrycat/nng that referenced this issue Sep 5, 2024
hungrycat added a commit to hungrycat/nng that referenced this issue Sep 5, 2024
hungrycat added a commit to hungrycat/nng that referenced this issue Sep 5, 2024
On Android's bionic implemementation of the system libraries, clock_gettime
is available in libc.
hungrycat added a commit to hungrycat/nng that referenced this issue Sep 5, 2024
On Android's bionic implementation of the system libraries, clock_gettime
is available in libc.
@gdamore
Copy link
Contributor

gdamore commented Sep 7, 2024

A better solution IMO is to look first in libc, and only look in librt if we didn't find it in libc.

@gdamore gdamore added the linux label Sep 7, 2024
@gdamore gdamore closed this as completed in 29aff2b Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants