Commit d1a53926 authored by Henrik Gramner's avatar Henrik Gramner

Prefer a monotonic clock source if available

parent 1d18f0e0
......@@ -51,6 +51,10 @@ int64_t x264_mdate( void )
struct timeb tb;
ftime( &tb );
return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000;
#elif HAVE_CLOCK_GETTIME
struct timespec ts;
clock_gettime( CLOCK_MONOTONIC, &ts );
return (int64_t)ts.tv_sec * 1000000 + (int64_t)ts.tv_nsec / 1000;
#else
struct timeval tv_date;
gettimeofday( &tv_date, NULL );
......
......@@ -396,7 +396,7 @@ NL="
# list of all preprocessor HAVE values we can define
CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC INTEL_DISPATCHER \
MSA MMAP WINRT VSX ARM_INLINE_ASM STRTOK_R BITDEPTH8 BITDEPTH10"
MSA MMAP WINRT VSX ARM_INLINE_ASM STRTOK_R CLOCK_GETTIME BITDEPTH8 BITDEPTH10"
# parse options
......@@ -1075,6 +1075,13 @@ if cc_check 'string.h' '' 'strtok_r(0, 0, 0);' ; then
define HAVE_STRTOK_R
fi
if cc_check 'time.h' '' 'clock_gettime(CLOCK_MONOTONIC, 0);' ; then
define HAVE_CLOCK_GETTIME
elif cc_check 'time.h' '-lrt' 'clock_gettime(CLOCK_MONOTONIC, 0);' ; then
define HAVE_CLOCK_GETTIME
LDFLAGS="$LDFLAGS -lrt"
fi
if [ "$SYS" != "WINDOWS" ] && cpp_check "sys/mman.h unistd.h" "" "defined(MAP_PRIVATE)"; then
define HAVE_MMAP
fi
......
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