[asterisk-commits] trunk r29727 - in /trunk/include/asterisk:
linkedlists.h lock.h
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue May 23 10:04:08 MST 2006
Author: kpfleming
Date: Tue May 23 12:04:07 2006
New Revision: 29727
URL: http://svn.digium.com/view/asterisk?rev=29727&view=rev
Log:
restore AST_LIST_HEAD_INIT (with no users in the tree right now)
update ast_mutex_init to allow mutexes that are all zero bytes to be initialized (in the case of a dynamically-allocated structure containing a mutex)
Modified:
trunk/include/asterisk/linkedlists.h
trunk/include/asterisk/lock.h
Modified: trunk/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/linkedlists.h?rev=29727&r1=29726&r2=29727&view=diff
==============================================================================
--- trunk/include/asterisk/linkedlists.h (original)
+++ trunk/include/asterisk/linkedlists.h Tue May 23 12:04:07 2006
@@ -360,6 +360,19 @@
#define AST_LIST_TRAVERSE_SAFE_END }
/*!
+ \brief Initializes a list head structure.
+ \param head This is a pointer to the list head structure
+
+ This macro initializes a list head structure by setting the head
+ entry to \a NULL (empty list) and recreating the embedded lock.
+*/
+#define AST_LIST_HEAD_INIT(head) { \
+ (head)->first = NULL; \
+ (head)->last = NULL; \
+ ast_mutex_init(&(head)->lock); \
+}
+
+/*!
\brief Destroys a list head structure.
\param head This is a pointer to the list head structure
Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?rev=29727&r1=29726&r2=29727&view=diff
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Tue May 23 12:04:07 2006
@@ -149,6 +149,13 @@
typedef pthread_cond_t ast_cond_t;
+static pthread_mutex_t empty_mutex;
+
+static void __attribute__((constructor)) init_empty_mutex(void)
+{
+ memset(&empty_mutex, 0, sizeof(empty_mutex));
+}
+
static inline int __ast_pthread_mutex_init_attr(const char *filename, int lineno, const char *func,
const char *mutex_name, ast_mutex_t *t,
pthread_mutexattr_t *attr)
@@ -157,14 +164,16 @@
int canlog = strcmp(filename, "logger.c");
if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
- __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
- filename, lineno, func, mutex_name);
- __ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
- t->file[0], t->lineno[0], t->func[0], mutex_name);
-#ifdef THREAD_CRASH
- DO_THREAD_CRASH;
-#endif
- return 0;
+ if ((t->mutex) != (empty_mutex)) {
+ __ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
+ filename, lineno, func, mutex_name);
+ __ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
+ t->file[0], t->lineno[0], t->func[0], mutex_name);
+#ifdef THREAD_CRASH
+ DO_THREAD_CRASH;
+#endif
+ return 0;
+ }
}
#endif
More information about the asterisk-commits
mailing list