Merge branch 'PHP-8.2' into PHP-8.3

This commit is contained in:
David Carlier 2024-07-06 20:44:20 +01:00
commit 0b28914a26
No known key found for this signature in database
GPG key ID: D308BD11AB42D054
3 changed files with 30 additions and 0 deletions

View file

@ -1220,6 +1220,7 @@ PHP_FUNCTION(time_sleep_until)
struct timespec php_req, php_rem;
uint64_t current_ns, target_ns, diff_ns;
const uint64_t ns_per_sec = 1000000000;
const double top_target_sec = (double)(UINT64_MAX / ns_per_sec);
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_DOUBLE(target_secs)
@ -1229,6 +1230,11 @@ PHP_FUNCTION(time_sleep_until)
RETURN_FALSE;
}
if (UNEXPECTED(!(target_secs >= 0 && target_secs <= top_target_sec))) {
zend_argument_value_error(1, "must be between 0 and %" PRIu64, (uint64_t)top_target_sec);
RETURN_THROWS();
}
target_ns = (uint64_t) (target_secs * ns_per_sec);
current_ns = ((uint64_t) tm.tv_sec) * ns_per_sec + ((uint64_t) tm.tv_usec) * 1000;
if (target_ns < current_ns) {