aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-06 21:28:03 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-06 21:28:03 +0000
commit3b1beff96388e10e4023b45b7d8e63c511572e50 (patch)
tree1bfe48076f0ad508e233233d614d9dab318058d3 /include
parentf8f520ca7c67553275806bfe6ad8c9b5809b74a3 (diff)
ensure that mutex locks inside list heads are initialized properly on platforms that require constructor initialization (issue #8029, patch from timrobbins)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@44631 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/linkedlists.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index d7447d12f..3264b9e1a 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -145,12 +145,30 @@ struct name { \
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.