ref: 2e5e05b767f0c61d16a6df8ae787791555ed2c42
parent: fc6c2578b63a97d827c04b452c0e772cdd62e882
author: Janne Grunau <janne-vlc@jannau.net>
date: Mon Nov 25 00:35:03 EST 2019
build: do not error out if clock_gettime is not found on darwin Also prefer clock_gettime over mach_absolute_time on darwin. clock_gettime is only available in darwin 10.12 and later. Hopefully fixes #283.
--- a/meson.build
+++ b/meson.build
@@ -122,7 +122,7 @@
rt_dependency = []
if cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args)
cdata.set('HAVE_CLOCK_GETTIME', 1)
- else
+ elif host_machine.system() != 'darwin'
rt_dependency = cc.find_library('rt', required: false)
if not cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args, dependencies : rt_dependency)
error('clock_gettime not found')
--- a/tools/dav1d.c
+++ b/tools/dav1d.c
@@ -64,14 +64,14 @@
LARGE_INTEGER t;
QueryPerformanceCounter(&t);
return 1000000000 * t.QuadPart / frequency.QuadPart;
-#elif defined(__APPLE__)
- mach_timebase_info_data_t info;
- mach_timebase_info(&info);
- return mach_absolute_time() * info.numer / info.denom;
#elif defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return 1000000000ULL * ts.tv_sec + ts.tv_nsec;
+#elif defined(__APPLE__)
+ mach_timebase_info_data_t info;
+ mach_timebase_info(&info);
+ return mach_absolute_time() * info.numer / info.denom;
#endif
}