mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
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) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@29727 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -359,6 +359,19 @@ struct { \
|
|||||||
*/
|
*/
|
||||||
#define AST_LIST_TRAVERSE_SAFE_END }
|
#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.
|
\brief Destroys a list head structure.
|
||||||
\param head This is a pointer to the list head structure
|
\param head This is a pointer to the list head structure
|
||||||
|
@@ -149,6 +149,13 @@ typedef struct ast_mutex_info ast_mutex_t;
|
|||||||
|
|
||||||
typedef pthread_cond_t ast_cond_t;
|
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,
|
static inline int __ast_pthread_mutex_init_attr(const char *filename, int lineno, const char *func,
|
||||||
const char *mutex_name, ast_mutex_t *t,
|
const char *mutex_name, ast_mutex_t *t,
|
||||||
pthread_mutexattr_t *attr)
|
pthread_mutexattr_t *attr)
|
||||||
@@ -157,14 +164,16 @@ static inline int __ast_pthread_mutex_init_attr(const char *filename, int lineno
|
|||||||
int canlog = strcmp(filename, "logger.c");
|
int canlog = strcmp(filename, "logger.c");
|
||||||
|
|
||||||
if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
|
if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
|
||||||
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
|
if ((t->mutex) != (empty_mutex)) {
|
||||||
filename, lineno, func, mutex_name);
|
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
|
||||||
__ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
|
filename, lineno, func, mutex_name);
|
||||||
t->file[0], t->lineno[0], t->func[0], 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
|
#ifdef THREAD_CRASH
|
||||||
DO_THREAD_CRASH;
|
DO_THREAD_CRASH;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user