Skip to content

Commit d2f40b9

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: zend_hrtime: use CLOCK_MONOTONIC instead of CLOCK_MONOTONIC_RAW (#23790)
2 parents 0198078 + 06f4640 commit d2f40b9

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

‎Zend/zend_hrtime.c‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,12 @@ void zend_startup_hrtime(void)
7070

7171
struct timespec ts;
7272

73-
#ifdef CLOCK_MONOTONIC_RAW
74-
if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) {
75-
zend_hrtime_posix_clock_id = CLOCK_MONOTONIC_RAW;
76-
return;
77-
}
78-
#endif
79-
80-
if (EXPECTED(0 == clock_gettime(zend_hrtime_posix_clock_id, &ts))) {
73+
if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC, &ts))) {
8174
return;
8275
}
8376

8477
// zend_error mechanism is not initialized at that point
85-
fprintf(stderr, "No working CLOCK_MONOTONIC* found, this should never happen\n");
78+
fprintf(stderr, "No working CLOCK_MONOTONIC found, this should never happen\n");
8679
abort();
8780

8881
#endif

‎Zend/zend_hrtime.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ ZEND_API extern mach_timebase_info_data_t zend_hrtime_timerlib_info;
7272

7373
#elif ZEND_HRTIME_PLATFORM_POSIX
7474

75+
/* Not read anymore, kept for ABI compatibility */
7576
ZEND_API extern clockid_t zend_hrtime_posix_clock_id;
7677

7778
#endif
@@ -94,7 +95,7 @@ static zend_always_inline zend_hrtime_t zend_hrtime(void)
9495
return (zend_hrtime_t)mach_absolute_time() * zend_hrtime_timerlib_info.numer / zend_hrtime_timerlib_info.denom;
9596
#elif ZEND_HRTIME_PLATFORM_POSIX
9697
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
97-
clock_gettime(zend_hrtime_posix_clock_id, &ts);
98+
clock_gettime(CLOCK_MONOTONIC, &ts);
9899
return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec;
99100
#elif ZEND_HRTIME_PLATFORM_HPUX
100101
return (zend_hrtime_t) gethrtime();

0 commit comments

Comments
 (0)