]> git.sesse.net Git - vlc/blobdiff - include/threads.h
MacOS X compile fixes.
[vlc] / include / threads.h
index 706de705ed417a830435c8a1a23cb2a3214e22a5..54c262916dcb8a4a7b4cc346d64ac429b990baf6 100644 (file)
@@ -3,7 +3,7 @@
  * This header provides a portable threads implementation.
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: threads.h,v 1.35 2002/02/25 23:59:07 sam Exp $
+ * $Id: threads.h,v 1.37 2002/03/01 00:33:18 massiot Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
 
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )  /* pthreads (like Linux & BSD) */
 #   include <pthread.h>
+#   ifdef DEBUG
+/* Needed for pthread_cond_timedwait */
+#       include <errno.h>
+#   endif
 /* This is not prototyped under Linux, though it exists. */
 int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
 
@@ -44,8 +48,6 @@ int pthread_mutexattr_setkind_np( pthread_mutexattr_t *attr, int kind );
 #   include <cthreads.h>
 
 #elif defined( HAVE_KERNEL_SCHEDULER_H )                             /* BeOS */
-#   undef MAX
-#   undef MIN
 #   include <kernel/OS.h>
 #   include <kernel/scheduler.h>
 #   include <byteorder.h>
@@ -718,15 +720,21 @@ static __inline__ int _vlc_cond_wait( char * psz_file, int i_line,
         timeout.tv_sec = now.tv_sec + THREAD_COND_TIMEOUT;
         timeout.tv_nsec = now.tv_usec * 1000;
 
-        if( (i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout )) )
+        i_result = pthread_cond_timedwait( p_condvar, p_mutex, &timeout );
+
+        if( i_result == ETIMEDOUT )
         {
             intf_WarnMsg( 1, "thread %d warning: Possible deadlock detected in cond_wait at %s:%d (%s)",
                           pthread_self(), psz_file, i_line, strerror(i_result) );
+            continue;
         }
-        else
+
+        if( i_result )
         {
-            return i_result;
+            intf_ErrMsg( "thread %d error: cond_wait failed at %s:%d (%s)",
+                         pthread_self(), psz_file, i_line, strerror(i_result) );
         }
+        return( i_result );
     }
 #endif