[libbluray-devel] Win32 mutex: use static inline instead of macros

Jean-Baptiste Kempf git at videolan.org
Wed May 21 12:58:53 CEST 2014


libbluray | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed May 21 12:58:30 2014 +0200| [792d034475d786a59de62998c3f0138930f2a527] | committer: Jean-Baptiste Kempf

Win32 mutex: use static inline instead of macros

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=792d034475d786a59de62998c3f0138930f2a527
---

 src/util/mutex.h |   31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/util/mutex.h b/src/util/mutex.h
index cd230d9..98f79b2 100644
--- a/src/util/mutex.h
+++ b/src/util/mutex.h
@@ -39,20 +39,31 @@
 
 typedef CRITICAL_SECTION BD_MUTEX;
 
-#define bd_mutex_lock(m) \
-  (EnterCriticalSection(m), 0)
+static inline int bd_mutex_lock(BD_MUTEX *p) {
+    EnterCriticalSection(p);
+    return 0;
+}
 
-#define bd_mutex_unlock(m) \
-  (LeaveCriticalSection(m), 0)
+static inline int bd_mutex_unlock(BD_MUTEX *p) {
+    LeaveCriticalSection(p);
+    return 0;
+}
 
-#define bd_mutex_trylock(m) \
-  (TryEnterCriticalSection(m) ? 0 : EBUSY)
+#if 0
+static int bd_mutex_trylock(BD_MUTEX *p) {
+    return TryEnterCriticalSection(p) ? 0 : EBUSY;
+}
+#endif
 
-#define bd_mutex_init(m) \
-  (InitializeCriticalSection(m), 0)
+static inline int bd_mutex_init(BD_MUTEX *p) {
+    InitializeCriticalSection(p);
+    return 0;
+}
 
-#define bd_mutex_destroy(m) \
-  (DeleteCriticalSection(m), 0)
+static inline int bd_mutex_destroy(BD_MUTEX *p) {
+    DeleteCriticalSection(p);
+    return 0;
+}
 
 
 #elif defined(HAVE_PTHREAD_H)



More information about the libbluray-devel mailing list