[vlc-devel] [PATCH] Fix FreeBSD threading

Rafaël Carré funman at videolan.org
Wed Jan 4 20:07:52 CET 2012


pthread_condattr_setclock() works and supports MONOTONIC_CLOCK
pthread_cond_timedwait() can thus use MONOTONIC_CLOCK
---
 src/posix/thread.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/posix/thread.c b/src/posix/thread.c
index 122e201..02a3f23 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)))
@@ -457,7 +457,7 @@ void vlc_cond_wait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex)
 int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
                         mtime_t deadline)
 {
-#if (_POSIX_MONOTONIC_CLOCK > 0) && (_POSIX_CLOCK_SELECTION < 0)
+#if (_POSIX_MONOTONIC_CLOCK > 0) && (_POSIX_CLOCK_SELECTION < 0) && !defined(__FreeBSD__)
     /* 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()
-- 
1.7.7.3



More information about the vlc-devel mailing list