From 3eb56f9bbc51886d61bd8b47ba63594e90313ab6 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Thu, 28 Jul 2011 05:59:02 +0200 Subject: [PATCH] Allow to use clock_gettime() even if clock_nanosleep() isn't available It's often cheaper than gettimeofday() and the precision seems to be sufficient. --- configure.ac | 4 ++++ src/misc/mtime.c | 2 +- 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 86a7eac..a1efda4 100644 --- a/configure.ac +++ b/configure.ac @@ -808,6 +808,10 @@ AC_CHECK_LIB(rt, clock_nanosleep, [ AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LIBS([libvlccore],[-lrt])]) ]) +AC_CHECK_LIB(rt, clock_gettime, [ + AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define to 1 if you have clock_gettime.]) +]) + have_nanosleep=false AC_CHECK_FUNCS(nanosleep,have_nanosleep=:,[ AC_CHECK_LIB(rt,nanosleep, diff --git a/src/misc/mtime.c b/src/misc/mtime.c index 1cc787d..f8d69dc 100644 --- a/src/misc/mtime.c +++ b/src/misc/mtime.c @@ -197,7 +197,7 @@ mtime_t mdate( void ) { mtime_t res; -#if defined (HAVE_CLOCK_NANOSLEEP) +#if defined (HAVE_CLOCK_GETTIME) struct timespec ts; /* Try to use POSIX monotonic clock if available */ -- 1.7.6