Commit 0e8b68a2 authored by Wang Bin's avatar Wang Bin Committed by Steven Liu

avutil/tile: check clock_gettime at runtime for apple platforms

clock_gettime is avalible since macOS 10.12 and iOS 10.0. Because of
weak linking, clock_gettime can be build without error with new
macOS/iOS sdk, but the symbol may not exist on the target system.
Explicitly checking the symbol is required.
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.htmlSigned-off-by: 's avatarWang Bin <wbsecg1@gmail.com>
Signed-off-by: 's avatarSteven Liu <lq@chinaffmpeg.org>
parent b53b3a4f
...@@ -56,17 +56,25 @@ int64_t av_gettime(void) ...@@ -56,17 +56,25 @@ int64_t av_gettime(void)
int64_t av_gettime_relative(void) int64_t av_gettime_relative(void)
{ {
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC) #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
#ifdef __APPLE__
if (clock_gettime)
#endif
{
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000; return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
#else }
return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
#endif #endif
return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
} }
int av_gettime_relative_is_monotonic(void) int av_gettime_relative_is_monotonic(void)
{ {
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC) #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
#ifdef __APPLE__
if (!clock_gettime)
return 0;
#endif
return 1; return 1;
#else #else
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment