Commit df0cb344 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

src/misc/mtime.c:

 - Don't use TIMER_ABSTIME which sucks (at least on Linux with HZ=1000)
 - Cosmetic
configure.ac:
 - Check for clock_nanosleep() rather than clock_gettime(), as it is more
   recent and we need both.
parent bd475b06
...@@ -720,9 +720,9 @@ VLC_ADD_LDFLAGS([vlc plugin],[${THREAD_LIB}]) ...@@ -720,9 +720,9 @@ VLC_ADD_LDFLAGS([vlc plugin],[${THREAD_LIB}])
dnl Don't link with rt when using GNU-pth dnl Don't link with rt when using GNU-pth
if test "${THREAD_LIB}" != "-lpth" && test "${THREAD_LIB}" != "-lst"; then if test "${THREAD_LIB}" != "-lpth" && test "${THREAD_LIB}" != "-lst"; then
AC_CHECK_LIB(rt, clock_gettime, [ AC_CHECK_LIB(rt, clock_nanosleep, [
VLC_ADD_LDFLAGS([vlc],[-lrt]) VLC_ADD_LDFLAGS([vlc],[-lrt])
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define to 1 if you have clock_gettime.]) AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define to 1 if you have clock_nanosleep.])
], [ ], [
dnl HP/UX port dnl HP/UX port
AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LDFLAGS([vlc],[-lrt])]) AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LDFLAGS([vlc],[-lrt])])
......
...@@ -187,7 +187,7 @@ mtime_t mdate( void ) ...@@ -187,7 +187,7 @@ mtime_t mdate( void )
return usec_time; return usec_time;
} }
#elif defined (HAVE_CLOCK_GETTIME) #elif defined (HAVE_CLOCK_NANOSLEEP)
struct timespec ts; struct timespec ts;
# if (_POSIX_MONOTONIC_CLOCK - 0 >= 0) # if (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
...@@ -239,14 +239,21 @@ void mwait( mtime_t date ) ...@@ -239,14 +239,21 @@ void mwait( mtime_t date )
} }
msleep( delay ); msleep( delay );
#elif defined (HAVE_CLOCK_GETTIME) #elif defined (HAVE_CLOCK_NANOSLEEP)
# if defined (HAVE_TIMER_ABSTIME_THAT_ACTUALLY_WORKS_WELL)
lldiv_t d = lldiv( date, 1000000 ); lldiv_t d = lldiv( date, 1000000 );
struct timespec ts = { d.quot, d.rem }; struct timespec ts = { d.quot, d.rem };
# if (_POSIX_MONOTONIC_CLOCK - 0 >= 0) # if (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
if( clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL ) ) if( clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL ) )
# endif # endif
clock_nanosleep( CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL ); clock_nanosleep( CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL );
# else
date -= mdate ();
if( date <= 0)
return;
msleep( date );
# endif
#else #else
struct timeval tv_date; struct timeval tv_date;
...@@ -316,11 +323,12 @@ void msleep( mtime_t delay ) ...@@ -316,11 +323,12 @@ void msleep( mtime_t delay )
#elif defined( WIN32 ) || defined( UNDER_CE ) #elif defined( WIN32 ) || defined( UNDER_CE )
Sleep( (int) (delay / 1000) ); Sleep( (int) (delay / 1000) );
#elif defined( HAVE_CLOCK_GETTIME ) #elif defined( HAVE_CLOCK_NANOSLEEP )
lldiv_t d = lldiv( delay, 1000000 ); lldiv_t d = lldiv( delay, 1000000 );
struct timespec ts = { d.quot, d.rem * 1000 }; struct timespec ts = { d.quot, d.rem * 1000 };
# if (_POSIX_CLOCK_MONOTONIC - 0 >= 0) # if (_POSIX_CLOCK_MONOTONIC - 0 >= 0)
if (clock_nanosleep( CLOCK_MONOTONIC, 0, &ts, NULL ) ) if( clock_nanosleep( CLOCK_MONOTONIC, 0, &ts, NULL ) )
# endif # endif
clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL ); clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL );
......
Supports Markdown
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