summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2021-01-16 20:12:25 +0000
committerNikita Popov <nikita.ppv@gmail.com>2021-01-18 10:01:21 +0100
commita3e55286a676fdf4f5919d219e2a0df93f817211 (patch)
treee07e77310f2ba106c04950d59d319aaca449f1de
parent3dad63b5b25fc27604a38964b3bea885cbfbf1d3 (diff)
downloadphp-git-a3e55286a676fdf4f5919d219e2a0df93f817211.tar.gz
hrtime implementation update for Mac
Using a more modern and simpler api available since Sierra (2016). Closes GH-6609.
-rw-r--r--ext/standard/hrtime.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/ext/standard/hrtime.c b/ext/standard/hrtime.c
index 3bfd018597..20604baa1d 100644
--- a/ext/standard/hrtime.c
+++ b/ext/standard/hrtime.c
@@ -34,12 +34,6 @@
static double _timer_scale = .0;
-#elif PHP_HRTIME_PLATFORM_APPLE
-
-# include <mach/mach_time.h>
-# include <string.h>
-static mach_timebase_info_data_t _timerlib_info;
-
#elif PHP_HRTIME_PLATFORM_HPUX
# include <sys/time.h>
@@ -66,9 +60,7 @@ static int _timer_init()
#elif PHP_HRTIME_PLATFORM_APPLE
- if (mach_timebase_info(&_timerlib_info)) {
- return -1;
- }
+ /* pass */
#elif PHP_HRTIME_PLATFORM_POSIX
@@ -115,7 +107,8 @@ static zend_always_inline php_hrtime_t _timer_current(void)
QueryPerformanceCounter(&lt);
return (php_hrtime_t)((php_hrtime_t)lt.QuadPart * _timer_scale);
#elif PHP_HRTIME_PLATFORM_APPLE
- return (php_hrtime_t)mach_absolute_time() * _timerlib_info.numer / _timerlib_info.denom;
+ /* the value is of php_hrtime_t type already */
+ return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
#elif PHP_HRTIME_PLATFORM_POSIX
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 };
if (0 == clock_gettime(CLOCK_MONOTONIC, &ts)) {