[asterisk-commits] kpfleming: branch 1.4 r44631 - /branches/1.4/include/asterisk/linkedlists.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Oct 6 14:28:04 MST 2006


Author: kpfleming
Date: Fri Oct  6 16:28:03 2006
New Revision: 44631

URL: http://svn.digium.com/view/asterisk?rev=44631&view=rev
Log:
ensure that mutex locks inside list heads are initialized properly on platforms that require constructor initialization

Modified:
    branches/1.4/include/asterisk/linkedlists.h

Modified: branches/1.4/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/linkedlists.h?rev=44631&r1=44630&r2=44631&view=diff
==============================================================================
--- branches/1.4/include/asterisk/linkedlists.h (original)
+++ branches/1.4/include/asterisk/linkedlists.h Fri Oct  6 16:28:03 2006
@@ -145,12 +145,30 @@
   This would define \c struct \c entry_list, intended to hold a list of
   type \c struct \c entry.
 */
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+#define AST_LIST_HEAD_STATIC(name, type)				\
+struct name {								\
+	struct type *first;						\
+	struct type *last;						\
+	ast_mutex_t lock;						\
+} name;									\
+static void  __attribute__ ((constructor)) init_##name(void)		\
+{									\
+        AST_LIST_HEAD_INIT(&name);					\
+}									\
+static void  __attribute__ ((destructor)) fini_##name(void)		\
+{									\
+        AST_LIST_HEAD_DESTROY(&name);					\
+}									\
+struct __dummy_##name
+#else
 #define AST_LIST_HEAD_STATIC(name, type)				\
 struct name {								\
 	struct type *first;						\
 	struct type *last;						\
 	ast_mutex_t lock;						\
 } name = AST_LIST_HEAD_INIT_VALUE
+#endif
 
 /*!
   \brief Defines a structure to be used to hold a list of specified type, statically initialized.



More information about the asterisk-commits mailing list