[vlc-commits] threads: export vlc_mutex_assert()

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


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 20 23:28:40 2018 +0300| [558648c43119eff8497f9abe2a8a36f9bb30fd6e] | committer: Rémi Denis-Courmont

threads: export vlc_mutex_assert()

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

 include/vlc_threads.h | 22 ++++++++++++++++++++++
 src/libvlc.h          | 10 ----------
 src/libvlccore.sym    |  1 +
 src/misc/threads.c    |  5 +++++
 4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 04e8941afb..dcc9f3b5b0 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -439,6 +439,28 @@ VLC_API int vlc_mutex_trylock( vlc_mutex_t * ) VLC_USED;
 VLC_API void vlc_mutex_unlock(vlc_mutex_t *);
 
 /**
+ * Checks if a mutex is locked.
+ *
+ * Do not use this function directly. Use vlc_mutex_assert() instead.
+ *
+ * @note
+ * This function has no effects.
+ * It is only meant to be use in run-time assertions.
+ *
+ * @retval false in debug builds of LibVLC,
+ *               if the mutex is not locked by the calling thread;
+ * @retval true in debug builds of LibVLC,
+ *              if the mutex is locked by the calling thread;
+ * @retval true in release builds of LibVLC.
+ */
+VLC_API bool vlc_mutex_marked(const vlc_mutex_t *) VLC_USED;
+
+/**
+ * Asserts that a mutex is locked by the calling thread.
+ */
+#define vlc_mutex_assert(m) assert(vlc_mutex_marked(m))
+
+/**
  * Initializes a condition variable.
  */
 VLC_API void vlc_cond_init(vlc_cond_t *);
diff --git a/src/libvlc.h b/src/libvlc.h
index d30dd95de2..afe075d62c 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -68,21 +68,11 @@ void vlc_mutex_mark(const vlc_mutex_t *);
  * Unmarks a mutex.
  */
 void vlc_mutex_unmark(const vlc_mutex_t *);
-
-/**
- * Checks if a mutex is marked.
- */
-bool vlc_mutex_marked(const vlc_mutex_t *);
 #else
 # define vlc_mutex_mark(m) ((void)(m))
 # define vlc_mutex_unmark(m) ((void)(m))
 #endif
 
-/**
- * Asserts that a mutex is locked by the calling thread.
- */
-#define vlc_mutex_assert(m) assert(vlc_mutex_marked(m))
-
 /*
  * Logging
  */
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a4ba469b14..d9ffbd1b11 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -658,6 +658,7 @@ vlc_mutex_init_recursive
 vlc_mutex_lock
 vlc_mutex_trylock
 vlc_mutex_unlock
+vlc_mutex_marked
 vlc_global_mutex
 vlc_object_create
 vlc_object_find_name
diff --git a/src/misc/threads.c b/src/misc/threads.c
index e0d95e53aa..e66b21a408 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -131,6 +131,11 @@ bool vlc_mutex_marked(const vlc_mutex_t *mutex)
 {
     return vlc_lock_marked(mutex, &vlc_mutex_marks);
 }
+#else
+bool vlc_mutex_marked(const vlc_mutex_t *mutex)
+{
+    return true;
+}
 #endif
 
 #if defined (_WIN32) && (_WIN32_WINNT < _WIN32_WINNT_WIN8)



More information about the vlc-commits mailing list