Skip to content

zend_hrtime: Check posix clock once and prefer CLOCK_MONOTONIC_RAW #19221

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marc-mabe
Copy link
Contributor

Part of #19210.

This will test the support of the monotonic timer only once at startup.

Additionally it will prefer CLOCK_MONOTONiC_RAW (if available) to not be affected by the incremental adjustments performed by adjtime(3) and NTP.

return;
}

ZEND_ASSERT(0 && "No working CLOCK_MONOTONIC* found, this should never happen");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can I trigger a startup error here?

Copy link
Member

Choose a reason for hiding this comment

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

zend_error_noreturn

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mh 🤔 this ends up in a segfault at *filename = ZSTR_KNOWN(ZEND_STR_UNKNOWN_CAPITALIZED); I guess because zend_startup_hrtime gets called before initialization of the error mechanism.

Using zend_error_noreturn(E_CORE_ERROR, "No working CLOCK_MONOTONIC* found, this should never happen");

Copy link
Member

Choose a reason for hiding this comment

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

Sigh. That makes sense. In that case an fprintf(stderr, "message\n"); abort(); sequence may be better...

@marc-mabe marc-mabe force-pushed the hrtime_posix_check_once branch from dcd5a89 to bee086b Compare July 23, 2025 19:51
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