[asterisk-commits] trunk r19614 - /trunk/include/asterisk/lock.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Apr 12 16:33:48 MST 2006


Author: kpfleming
Date: Wed Apr 12 18:33:47 2006
New Revision: 19614

URL: http://svn.digium.com/view/asterisk?rev=19614&view=rev
Log:
simplify macro usage

Modified:
    trunk/include/asterisk/lock.h

Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?rev=19614&r1=19613&r2=19614&view=diff
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Wed Apr 12 18:33:47 2006
@@ -60,17 +60,19 @@
  * non-blocking calls.
  */
 #ifndef	HAVE_MTX_PROFILE
-#define	__MTX_PROF	/* nothing */
+#define	__MTX_PROF(a)	return pthread_mutex_lock((a))
 #else
-#define	__MTX_PROF	{			\
+#define	__MTX_PROF(a)	do {			\
 	int i;					\
 	/* profile only non-blocking events */	\
 	ast_mark(mtx_prof, 1);			\
-	i = pthread_mutex_trylock(pmutex);	\
+	i = pthread_mutex_trylock((a));		\
 	ast_mark(mtx_prof, 0);			\
 	if (!i)					\
 		return i;			\
-	}
+	else					\
+		return pthread_mutex_lock((a)); \
+	} while (0)
 #endif	/* HAVE_MTX_PROFILE */
 
 #include <pthread.h>
@@ -610,8 +612,7 @@
 
 static inline int ast_mutex_lock(ast_mutex_t *pmutex)
 {
-	__MTX_PROF
-	return pthread_mutex_lock(pmutex);
+	__MTX_PROF(pmutex);
 }
 
 static inline int ast_mutex_trylock(ast_mutex_t *pmutex)
@@ -631,8 +632,7 @@
 {
 	if (*pmutex == (ast_mutex_t)AST_MUTEX_KIND)
 		ast_mutex_init(pmutex);
-	__MTX_PROF
-	return pthread_mutex_lock(pmutex);
+	__MTX_PROF(pmutex);
 }
 
 static inline int ast_mutex_trylock(ast_mutex_t *pmutex)
@@ -648,8 +648,7 @@
 
 static inline int ast_mutex_lock(ast_mutex_t *pmutex)
 {
-	__MTX_PROF
-	return pthread_mutex_lock(pmutex);
+	__MTX_PROF(pmutex);
 }
 
 static inline int ast_mutex_trylock(ast_mutex_t *pmutex)



More information about the asterisk-commits mailing list