[asterisk-commits] qwell: branch qwell/compiler-flag-abi r249756 - in /team/qwell/compiler-flag-...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 1 16:52:29 CST 2010
Author: qwell
Date: Mon Mar 1 16:52:24 2010
New Revision: 249756
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=249756
Log:
Remove some EOL whitespace.
Remove DEBUG_THREADS -specific ast_mutex_info structure. It can be the same in all cases.
Also move the declaration up to avoid requiring a comment of why it was declared below.
(it was only so far below, so I could keep a single DEBUG_THREADS block)
Modified:
team/qwell/compiler-flag-abi/include/asterisk/lock.h
team/qwell/compiler-flag-abi/main/lock.c
Modified: team/qwell/compiler-flag-abi/include/asterisk/lock.h
URL: http://svnview.digium.com/svn/asterisk/team/qwell/compiler-flag-abi/include/asterisk/lock.h?view=diff&rev=249756&r1=249755&r2=249756
==============================================================================
--- team/qwell/compiler-flag-abi/include/asterisk/lock.h (original)
+++ team/qwell/compiler-flag-abi/include/asterisk/lock.h Mon Mar 1 16:52:24 2010
@@ -73,11 +73,36 @@
#define AST_MUTEX_KIND PTHREAD_MUTEX_RECURSIVE
#endif /* PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */
+#define AST_MAX_REENTRANCY 10
+
+/*! \brief Structure for mutex and tracking information.
+ *
+ * We have tracking information in this structure regardless of DEBUG_THREADS being enabled.
+ * The information will just be ignored in the core if a module does not request it..
+ */
+struct ast_mutex_info {
+ pthread_mutex_t mutex;
+ /*! Track which thread holds this lock */
+ unsigned int track:1;
+ const char *file[AST_MAX_REENTRANCY];
+ int lineno[AST_MAX_REENTRANCY];
+ int reentrancy;
+ const char *func[AST_MAX_REENTRANCY];
+ pthread_t thread[AST_MAX_REENTRANCY];
+ pthread_mutex_t reentr_mutex;
+};
+
typedef struct ast_mutex_info ast_mutex_t;
typedef pthread_cond_t ast_cond_t;
typedef pthread_rwlock_t ast_rwlock_t;
+
+int __ast_pthread_mutex_init(int track, const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t);
+int __ast_pthread_mutex_destroy(const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t);
+int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func, const char* mutex_name, ast_mutex_t *t);
+int __ast_pthread_mutex_trylock(const char *filename, int lineno, const char *func, const char* mutex_name, ast_mutex_t *t);
+int __ast_pthread_mutex_unlock(const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t);
#define ast_mutex_init(pmutex) __ast_pthread_mutex_init(1, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
#define ast_mutex_init_notracking(pmutex) __ast_pthread_mutex_init(0, __FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
@@ -86,11 +111,12 @@
#define ast_mutex_trylock(a) __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
#define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
-int __ast_pthread_mutex_init(int track, const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t);
-int __ast_pthread_mutex_destroy(const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t);
-int __ast_pthread_mutex_lock(const char *filename, int lineno, const char *func, const char* mutex_name, ast_mutex_t *t);
-int __ast_pthread_mutex_trylock(const char *filename, int lineno, const char *func, const char* mutex_name, ast_mutex_t *t);
-int __ast_pthread_mutex_unlock(const char *filename, int lineno, const char *func, const char *mutex_name, ast_mutex_t *t);
+int __ast_cond_init(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond, pthread_condattr_t *cond_attr);
+int __ast_cond_destroy(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond);
+int __ast_cond_signal(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond);
+int __ast_cond_broadcast(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond);
+int __ast_cond_wait(const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t);
+int __ast_cond_timedwait(const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t, const struct timespec *abstime);
#define ast_cond_init(cond, attr) __ast_cond_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond, attr)
#define ast_cond_destroy(cond) __ast_cond_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)
@@ -99,12 +125,15 @@
#define ast_cond_wait(cond, mutex) __ast_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex)
#define ast_cond_timedwait(cond, mutex, time) __ast_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex, time)
-int __ast_cond_init(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond, pthread_condattr_t *cond_attr);
-int __ast_cond_destroy(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond);
-int __ast_cond_signal(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond);
-int __ast_cond_broadcast(const char *filename, int lineno, const char *func, const char *cond_name, ast_cond_t *cond);
-int __ast_cond_wait(const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t);
-int __ast_cond_timedwait(const char *filename, int lineno, const char *func, const char *cond_name, const char *mutex_name, ast_cond_t *cond, ast_mutex_t *t, const struct timespec *abstime);
+int __ast_rwlock_init(const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *prwlock);
+int __ast_rwlock_destroy(const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *prwlock);
+int __ast_rwlock_tryrdlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
+int __ast_rwlock_trywrlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
+int __ast_rwlock_rdlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
+int __ast_rwlock_wrlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
+int __ast_rwlock_unlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
+int __ast_rwlock_timedrdlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock, const struct timespec *abs_timeout);
+int __ast_rwlock_timedwrlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock, const struct timespec *abs_timeout);
#define ast_rwlock_init(rwlock) __ast_rwlock_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock)
#define ast_rwlock_destroy(rwlock) __ast_rwlock_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #rwlock, rwlock)
@@ -116,16 +145,6 @@
#define ast_rwlock_timedrdlock(a, b) __ast_rwlock_timedrdlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a, b)
#define ast_rwlock_timedwrlock(a, b) __ast_rwlock_timedwrlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a, b)
-int __ast_rwlock_init(const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *prwlock);
-int __ast_rwlock_destroy(const char *filename, int lineno, const char *func, const char *rwlock_name, ast_rwlock_t *prwlock);
-int __ast_rwlock_tryrdlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
-int __ast_rwlock_trywrlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
-int __ast_rwlock_rdlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
-int __ast_rwlock_wrlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
-int __ast_rwlock_unlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock);
-int __ast_rwlock_timedrdlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock, const struct timespec *abs_timeout);
-int __ast_rwlock_timedwrlock(const char *file, int line, const char *func, const char *name, ast_rwlock_t *lock, const struct timespec *abs_timeout);
-
#ifdef DEBUG_THREADS
#define __ast_mutex_logger(...) do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)
@@ -139,8 +158,6 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
-
-#define AST_MAX_REENTRANCY 10
/*!
* \brief Unlock a lock briefly
@@ -166,18 +183,6 @@
#define AST_MUTEX_INIT_VALUE_NOTRACKING \
{ PTHREAD_MUTEX_INIT_VALUE, 0, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
-struct ast_mutex_info {
- pthread_mutex_t mutex;
- /*! Track which thread holds this lock */
- unsigned int track:1;
- const char *file[AST_MAX_REENTRANCY];
- int lineno[AST_MAX_REENTRANCY];
- int reentrancy;
- const char *func[AST_MAX_REENTRANCY];
- pthread_t thread[AST_MAX_REENTRANCY];
- pthread_mutex_t reentr_mutex;
-};
-
static pthread_mutex_t empty_mutex;
enum ast_lock_type {
@@ -294,10 +299,6 @@
#define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE }
#define AST_MUTEX_INIT_VALUE_NOTRACKING \
{ PTHREAD_MUTEX_INIT_VALUE }
-
-struct ast_mutex_info {
- pthread_mutex_t mutex;
-};
#endif /* !DEBUG_THREADS */
@@ -464,19 +465,19 @@
struct ast_channel;
-#define ast_channel_lock(a) __ast_channel_lock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*! \brief Lock AST channel (and print debugging output)
\note You need to enable DEBUG_CHANNEL_LOCKS for debugging output */
int __ast_channel_lock(struct ast_channel *chan, const char *file, int lineno, const char *func);
-
-#define ast_channel_unlock(a) __ast_channel_unlock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_channel_lock(a) __ast_channel_lock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
/*! \brief Unlock AST channel (and print debugging output)
\note You need to enable DEBUG_CHANNEL_LOCKS for debugging output */
int __ast_channel_unlock(struct ast_channel *chan, const char *file, int lineno, const char *func);
-
-#define ast_channel_trylock(a) __ast_channel_trylock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_channel_unlock(a) __ast_channel_unlock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
/*! \brief Lock AST channel (and print debugging output)
\note You need to enable DEBUG_CHANNEL_LOCKS for debugging output */
int __ast_channel_trylock(struct ast_channel *chan, const char *file, int lineno, const char *func);
+#define ast_channel_trylock(a) __ast_channel_trylock(a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
#endif /* _ASTERISK_LOCK_H */
Modified: team/qwell/compiler-flag-abi/main/lock.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/compiler-flag-abi/main/lock.c?view=diff&rev=249756&r1=249755&r2=249756
==============================================================================
--- team/qwell/compiler-flag-abi/main/lock.c (original)
+++ team/qwell/compiler-flag-abi/main/lock.c Mon Mar 1 16:52:24 2010
@@ -18,7 +18,7 @@
/*! \file
*
- * \brief General Asterisk channel locking.
+ * \brief General Asterisk locking.
*/
#include "asterisk.h"
@@ -43,7 +43,7 @@
#undef pthread_cond_timedwait
int __ast_pthread_mutex_init(int track, const char *filename, int lineno, const char *func,
- const char *mutex_name, ast_mutex_t *t)
+ const char *mutex_name, ast_mutex_t *t)
{
int res;
pthread_mutexattr_t attr;
@@ -85,7 +85,7 @@
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
/* Don't try to uninitialize non initialized mutex
* This may no effect on linux
- * And always ganerate core on *BSD with
+ * And always ganerate core on *BSD with
* linked libpthread
* This not error condition if the mutex created on the fly.
*/
@@ -155,7 +155,7 @@
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
filename, lineno, func, mutex_name);
return res;
- }
+ }
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
@@ -248,7 +248,7 @@
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized and unable to initialize.\n",
filename, lineno, func, mutex_name);
return res;
- }
+ }
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
@@ -332,7 +332,7 @@
#ifdef DEBUG_THREADS
if (res) {
- __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
+ __ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
filename, lineno, func, strerror(res));
DO_THREAD_CRASH;
}
@@ -416,7 +416,7 @@
#ifdef DEBUG_THREADS
if (res) {
- __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
+ __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
filename, lineno, func, strerror(res));
DO_THREAD_CRASH;
} else {
@@ -492,7 +492,7 @@
#ifdef DEBUG_THREADS
if (res && (res != ETIMEDOUT)) {
- __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
+ __ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
filename, lineno, func, strerror(res));
DO_THREAD_CRASH;
} else {
@@ -577,7 +577,7 @@
#ifdef DEBUG_THREADS
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(file, "logger.c");
-
+
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
/* Don't warn abount uninitialized lock.
* Simple try to initialize it.
@@ -591,7 +591,7 @@
}
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-
+
ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
#endif /* DEBUG_THREADS */
@@ -612,7 +612,7 @@
#ifdef DEBUG_THREADS
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(file, "logger.c");
-
+
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
/* Don't warn abount uninitialized lock.
* Simple try to initialize it.
@@ -648,7 +648,7 @@
#ifdef DEBUG_THREADS
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(file, "logger.c");
-
+
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
/* Don't warn abount uninitialized lock.
* Simple try to initialize it.
@@ -684,7 +684,7 @@
#ifdef DEBUG_THREADS
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(file, "logger.c");
-
+
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
/* Don't warn abount uninitialized lock.
* Simple try to initialize it.
@@ -733,7 +733,7 @@
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
#endif /* DEBUG_THREADS */
-
+
res = pthread_rwlock_unlock(lock);
#ifdef DEBUG_THREADS
@@ -748,7 +748,7 @@
#ifdef DEBUG_THREADS
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(file, "logger.c");
-
+
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
/* Don't warn abount uninitialized lock.
* Simple try to initialize it.
@@ -762,7 +762,7 @@
}
}
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-
+
ast_store_lock_info(AST_RDLOCK, file, line, func, name, lock);
#endif /* DEBUG_THREADS */
@@ -800,7 +800,7 @@
#ifdef DEBUG_THREADS
#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
int canlog = strcmp(file, "logger.c");
-
+
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
/* Don't warn abount uninitialized lock.
* Simple try to initialize it.
More information about the asterisk-commits
mailing list