[php-src] PR #21370: Introduce new time retrieval Zend-API
| From: | marc-mabe | Date: | Sat, 07 Mar 2026 07:16:14 +0000 |
| Subject: | [php-src] PR #21370: Introduce new time retrieval Zend-API | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-35118@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/21370
Author: marc-mabe
This is split out from #19202 to first introduce the new time retrieval API. Later PRs will follow
to refactor time retrieval usages.
**Key Changes**
- **Introduced
zend_time.h**
A new internal header that abstracts system time functions, replacing direct usage of
<time.h> and related platform-specific APIs.
- **Added zend_time_real_spec**
A unified wrapper around clock_gettime(), timespec_get(),
gettimeofday(), and time() using the real/wall clock.
Returns a timespec structure with up-to nanosecond precision.
- **Added zend_time_real_sec**
A lightweight wrapper around time(NULL) for simple, low-resolution time retrieval in
seconds.
- **Added zend_time_mono_fallback_nsec**
A wrapper for zend_hrtime or falls back to zend_time_real_spec.
Useful for time measurements (e.g. timeout handling) where monotonic time is preferred, but wall
time is an acceptable fallback.
- **Added helper functions**
Added utilities to simplify usage of timeval and timespec structures.
The time retrieval functions are not inlined to make it possible to be mocked in unit tests.