Skip to content

Simplify clock_gettime Autoconf check #13537

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

Merged
merged 1 commit into from
Feb 28, 2024
Merged

Conversation

petk
Copy link
Member

@petk petk commented Feb 27, 2024

The clock_gettime() is found in libc on modern systems, except on Solaris <= 10 and possible similar systems, it is in the rt library.

This checks if clock_gettime() exists in the libc, then it checks if rt library has clock_gettime, prepends it to LIBS and defines the HAVE_CLOCK_GETTIME symbol with the template from the AC_CHECK_FUNCS.

The ac_cv_func_clock_gettime is a cache variable set by AC_CHECK_FUNCS.

The clock_gettime() is found in libc on modern systems, except on
Solaris <= 10 and possible similar systems, it is in the rt library.

This checks if clock_gettime() exists in the libc, then it checks if rt
library has clock_gettime, prepends it to LIBS and defines the
HAVE_CLOCK_GETTIME symbol with the template from the AC_CHECK_FUNCS.

The ac_cv_func_clock_gettime is a cache variable set by AC_CHECK_FUNCS.
@bukka
Copy link
Member

bukka commented Feb 27, 2024

Do all systems have CLOCK_MONOTONIC?

@petk
Copy link
Member Author

petk commented Feb 27, 2024

Do all systems have CLOCK_MONOTONIC?

Not necessary. Modern systems have it if they have clock_gettime, yes. I think some older glibc versions don't have it (happened on some older macOS versions). The CLOCK_MONOTONIC is checked in the C code together with the HAVE_CLOCK_GETTIME:

#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)

Otherwise, it can be considered to be present everywhere today, yes. Theoretically not, but in practice it is.

And the ext/opcache/jit/ir uses it unconditionally, for now. I think that's ok until we run into issues.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

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

Ok, makes sense

@petk petk merged commit 98bd66f into php:master Feb 28, 2024
@petk petk deleted the patch-fpm-clock-gettime branch February 28, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants