Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 2 additions & 9 deletions Zend/zend_hrtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Zend/zend_hrtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
Loading