diff --git a/NEWS b/NEWS index cd01751fc78b..6e325f3df810 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,8 @@ PHP NEWS constant, and as an alias in class_alias() and use declarations. (Girgias) . Deprecated using "_" as a constant name and as an alias for a class or constant in use declarations. (Girgias) + . Switch the POSIX high resolution timer back to CLOCK_MONOTONIC from + CLOCK_MONOTONIC_RAW. (nicolas-grekas) - FFI: . Fixed crashes with FFI callbacks created from __call() trampolines diff --git a/Zend/zend_hrtime.c b/Zend/zend_hrtime.c index 819f95c47662..b471ee335e1d 100644 --- a/Zend/zend_hrtime.c +++ b/Zend/zend_hrtime.c @@ -70,19 +70,12 @@ void zend_startup_hrtime(void) struct timespec ts; -#ifdef CLOCK_MONOTONIC_RAW - if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) { - zend_hrtime_posix_clock_id = CLOCK_MONOTONIC_RAW; - return; - } -#endif - - if (EXPECTED(0 == clock_gettime(zend_hrtime_posix_clock_id, &ts))) { + if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC, &ts))) { return; } // zend_error mechanism is not initialized at that point - fprintf(stderr, "No working CLOCK_MONOTONIC* found, this should never happen\n"); + fprintf(stderr, "No working CLOCK_MONOTONIC found, this should never happen\n"); abort(); #endif diff --git a/Zend/zend_hrtime.h b/Zend/zend_hrtime.h index 6d802caacfe0..f7d69d19f80b 100644 --- a/Zend/zend_hrtime.h +++ b/Zend/zend_hrtime.h @@ -72,6 +72,7 @@ ZEND_API extern mach_timebase_info_data_t zend_hrtime_timerlib_info; #elif ZEND_HRTIME_PLATFORM_POSIX +/* Not read anymore, kept for ABI compatibility */ ZEND_API extern clockid_t zend_hrtime_posix_clock_id; #endif @@ -94,7 +95,7 @@ static zend_always_inline zend_hrtime_t zend_hrtime(void) return (zend_hrtime_t)mach_absolute_time() * zend_hrtime_timerlib_info.numer / zend_hrtime_timerlib_info.denom; #elif ZEND_HRTIME_PLATFORM_POSIX struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 }; - clock_gettime(zend_hrtime_posix_clock_id, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec; #elif ZEND_HRTIME_PLATFORM_HPUX return (zend_hrtime_t) gethrtime();