[vlc-commits] darwin: use the new mutex checks

Rémi Denis-Courmont git at videolan.org
Sun Oct 21 13:01:27 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 20 22:36:49 2018 +0300| [ef86d2329a408e8895a9722ca667e590106fdda0] | committer: Rémi Denis-Courmont

darwin: use the new mutex checks

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ef86d2329a408e8895a9722ca667e590106fdda0
---

 src/darwin/thread.c | 21 +++++----------------
 src/libvlc.h        |  4 +---
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/src/darwin/thread.c b/src/darwin/thread.c
index a96334cd4e..9dcffad28d 100644
--- a/src/darwin/thread.c
+++ b/src/darwin/thread.c
@@ -151,33 +151,21 @@ void vlc_mutex_destroy (vlc_mutex_t *p_mutex)
     VLC_THREAD_ASSERT ("destroying mutex");
 }
 
-#ifndef NDEBUG
-# ifdef HAVE_VALGRIND_VALGRIND_H
-#  include <valgrind/valgrind.h>
-# else
-#  define RUNNING_ON_VALGRIND (0)
-# endif
-
-void vlc_assert_locked (vlc_mutex_t *p_mutex)
-{
-    if (RUNNING_ON_VALGRIND > 0)
-        return;
-    assert (pthread_mutex_lock (p_mutex) == EDEADLK);
-}
-#endif
-
 void vlc_mutex_lock (vlc_mutex_t *p_mutex)
 {
     int val = pthread_mutex_lock( p_mutex );
     VLC_THREAD_ASSERT ("locking mutex");
+    vlc_mutex_mark(p_mutex);
 }
 
 int vlc_mutex_trylock (vlc_mutex_t *p_mutex)
 {
     int val = pthread_mutex_trylock( p_mutex );
 
-    if (val != EBUSY)
+    if (val != EBUSY) {
         VLC_THREAD_ASSERT ("locking mutex");
+        vlc_mutex_mark(p_mutex);
+    }
     return val;
 }
 
@@ -185,6 +173,7 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
 {
     int val = pthread_mutex_unlock( p_mutex );
     VLC_THREAD_ASSERT ("unlocking mutex");
+    vlc_mutex_unmark(p_mutex);
 }
 
 void vlc_cond_init (vlc_cond_t *p_condvar)
diff --git a/src/libvlc.h b/src/libvlc.h
index cbe598ad6f..e36c135304 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -83,10 +83,8 @@ bool vlc_mutex_marked(const vlc_mutex_t *);
  */
 #define vlc_mutex_assert(m) assert(vlc_mutex_marked(m))
 
-#if (defined (LIBVLC_USE_PTHREAD) || defined (__ANDROID__))
+#if !(defined (_WIN32) || defined (__OS2__))
 #define vlc_assert_locked(m) vlc_mutex_assert(m)
-#elif defined (__APPLE__) && !defined (NDEBUG)
-void vlc_assert_locked (vlc_mutex_t *);
 #else
 # define vlc_assert_locked( m ) (void)m
 #endif



More information about the vlc-commits mailing list