]> git.sesse.net Git - vlc/commitdiff
Force fallback to realtime clock when clock selection is not supported...
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 17 Sep 2007 16:25:19 +0000 (16:25 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 17 Sep 2007 16:25:19 +0000 (16:25 +0000)
and restore the old broken behavior. It's high time people update to NPTL...

src/misc/mtime.c
src/misc/threads.c

index 094556289404b7b831b0ba793e36f8339bb6671b..9a6a276760894c5a89330490263b8bb347784fb9 100644 (file)
@@ -67,6 +67,19 @@ struct timespec
 int nanosleep(struct timespec *, struct timespec *);
 #endif
 
+#ifdef HAVE_CLOCK_NANOSLEEP
+#  if !defined _POSIX_CLOCK_SELECTION || (_POSIX_CLOCK_SELECTION - 0 <= 0)
+/*
+ * We cannot use the monotonic clock is clock selection is not available,
+ * as it would screw vlc_cond_timedwait() completely. Instead, we have to
+ * stick to the realtime clock. Nevermind it screws everything when ntpdate
+ * warps the wall clock.
+ */
+#    undef CLOCK_MONOTONIC
+#    define CLOCK_MONOTONIC CLOCK_REALTIME
+#  endif
+#endif
+
 /**
  * Return a date in a readable format
  *
@@ -127,11 +140,6 @@ static inline unsigned mprec( void )
 
 static unsigned prec = 0;
 static volatile mtime_t cached_time = 0;
-#if defined( HAVE_CLOCK_NANOSLEEP )
-#  if (_POSIX_MONOTONIC_CLOCK - 0 < 0)
-#    define CLOCK_MONOTONIC CLOCK_REALTIME
-#  endif
-#endif
 
 /**
  * Return high precision date
index 4c597082da521e775f711923ee10abf4d80a1cf5..780bef8f240c00d71ed28a00c8a5a3ae12f12193 100644 (file)
@@ -481,8 +481,8 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
     if (ret)
         return ret;
 
-# if defined (_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
-    /* This must be the same clock as the one in mtime.c */
+# if defined (_POSIX_CLOCK_SELECTION) && (_POSIX_CLOCK_SELECTION - 0 > 0)
+    /* NOTE: This must be the same clock as the one in mtime.c */
     pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
 # endif