[vlc-devel] [PATCH] Fix FreeBSD threading

Rafaël Carré funman at videolan.org
Wed Jan 4 00:09:18 CET 2012


pthread_condattr_setclock() works and supports MONOTONIC_CLOCK
pthread_cond_timedwait() can thus use MONOTONIC_CLOCK

FreeBSD defines  _POSIX_CLOCK_SELECTION to -1, because clock_nanosleep() is missing
---
 src/posix/thread.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/posix/thread.c b/src/posix/thread.c
index 122e201..265a929 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -352,7 +352,7 @@ void vlc_cond_init (vlc_cond_t *p_condvar)
     vlc_clock_setup ();
     if (unlikely(pthread_condattr_init (&attr)))
         abort ();
-#if (_POSIX_CLOCK_SELECTION > 0)
+#if (_POSIX_CLOCK_SELECTION > 0) || defined(__FreeBSD__)
     pthread_condattr_setclock (&attr, vlc_clock_id);
 #endif
     if (unlikely(pthread_cond_init (p_condvar, &attr)))
@@ -460,7 +460,9 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
 #if (_POSIX_MONOTONIC_CLOCK > 0) && (_POSIX_CLOCK_SELECTION < 0)
     /* Without clock selection, the real-time clock is used for the absolute
      * timeout in pthread_cond_timedwait(). We may need to adjust. */
-# error FIXME: breaks vlc_cond_init_daytime()
+# ifndef __FreeBSD__
+#  error FIXME: breaks vlc_cond_init_daytime()
+# endif
     if (vlc_clock_id != CLOCK_REALTIME)
     {
         struct timeval tv;
-- 
1.7.7.3



More information about the vlc-devel mailing list