macro: add some macros for debug 85/172285/2
authorBoram Park <boram1288.park@samsung.com>
Tue, 13 Mar 2018 04:56:32 +0000 (13:56 +0900)
committerBoram Park <boram1288.park@samsung.com>
Tue, 13 Mar 2018 07:00:07 +0000 (16:00 +0900)
Change-Id: I0f9c9738ff849d13877b0b383da5578848f4f860

src/tdm.c
src/tdm_macro.h

index 5146f7e..effa0f3 100644 (file)
--- a/src/tdm.c
+++ b/src/tdm.c
@@ -46,6 +46,10 @@ int tdm_mutex_lock_line;
 const char *tdm_mutex_unlock_func;
 int tdm_mutex_unlock_line;
 
+pthread_mutex_t tdm_debug_mutex_check_lock = PTHREAD_MUTEX_INITIALIZER;
+const char *tdm_debug_mutex_lock_func;
+int tdm_debug_mutex_lock_line;
+
 /* LCOV_EXCL_START */
 static tdm_private_layer *
 _tdm_display_find_private_layer(tdm_private_output *private_output,
index 80be131..acdc9f3 100644 (file)
@@ -461,6 +461,29 @@ static inline int TDM_MUTEX_IS_LOCKED(void)
 #define tdm_display_unlock(dpy)   _pthread_mutex_unlock(&((tdm_private_display *)dpy)->lock)
 
 
+/* debugging mutex ************************************************************/
+extern pthread_mutex_t tdm_debug_mutex_check_lock;
+extern const char *tdm_debug_mutex_lock_func;
+extern int tdm_debug_mutex_lock_line;
+
+#define _debug_pthread_mutex_lock(l) \
+       do { \
+               pthread_mutex_lock(l); \
+               pthread_mutex_lock(&tdm_debug_mutex_check_lock); \
+               tdm_debug_mutex_lock_func = __FUNCTION__; \
+               tdm_debug_mutex_lock_line = __LINE__; \
+               pthread_mutex_unlock(&tdm_debug_mutex_check_lock); \
+       } while (0)
+
+#define _debug_pthread_mutex_unlock(l) \
+       do { \
+               pthread_mutex_lock(&tdm_debug_mutex_check_lock); \
+               tdm_debug_mutex_lock_func = NULL; \
+               tdm_debug_mutex_lock_line = 0; \
+               pthread_mutex_unlock(&tdm_debug_mutex_check_lock); \
+               pthread_mutex_unlock(l); \
+       } while (0)
+
 #ifdef __cplusplus
 }
 #endif