aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-04-06 19:40:03 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2010-04-06 19:40:03 +0000
commit00ce6674093529de51f3ec7855a6892e5b5f1708 (patch)
treec7e06b747655cfb275abe4510fdadc7e078e5316
parent38fba1445d81fd9736dee10fac39e38ba6c3a25a (diff)
Merged revisions 256370 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r256370 | tilghman | 2010-04-06 14:28:42 -0500 (Tue, 06 Apr 2010) | 2 lines Mac OS X does not support comparing a mutex to its initializer. Create a test for this. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@256371 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xconfigure62
-rw-r--r--configure.ac14
-rw-r--r--include/asterisk/autoconfig.h.in4
-rw-r--r--include/asterisk/lock.h36
4 files changed, 97 insertions, 19 deletions
diff --git a/configure b/configure
index c71348be5..7d0a3b099 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.ac Revision: 242885 .
+# From configure.ac Revision: 242972 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for asterisk 1.6.
#
@@ -17555,6 +17555,66 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Can we compare a mutex to its initial value?
+# Generally yes on OpenBSD/FreeBSD and no on Mac OS X.
+{ echo "$as_me:$LINENO: checking whether we can compare a mutex to its initial value" >&5
+echo $ECHO_N "checking whether we can compare a mutex to its initial value... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_mutex_t lock;
+ if ((lock) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
+ return 0;
+ }
+ return 0
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define CAN_COMPARE_MUTEX_TO_INIT_VALUE 1
+_ACEOF
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+
#if test "${cross_compiling}" = "no";
#then
#AC_MSG_CHECKING(for working epoll support)
diff --git a/configure.ac b/configure.ac
index 0d16a86a7..fd21ce602 100644
--- a/configure.ac
+++ b/configure.ac
@@ -544,6 +544,20 @@ fi
AST_C_DEFINE_CHECK([PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], [pthread.h])
+# Can we compare a mutex to its initial value?
+# Generally yes on OpenBSD/FreeBSD and no on Mac OS X.
+AC_MSG_CHECKING(whether we can compare a mutex to its initial value)
+AC_LINK_IFELSE(
+ AC_LANG_PROGRAM([#include <pthread.h>], [pthread_mutex_t lock;
+ if ((lock) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
+ return 0;
+ }
+ return 0]),
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([CAN_COMPARE_MUTEX_TO_INIT_VALUE], 1, [Define to 1 if your system's implementation of mutexes supports comparison of a mutex to its initializer.]),
+ AC_MSG_RESULT(no)
+)
+
#if test "${cross_compiling}" = "no";
#then
#AC_MSG_CHECKING(for working epoll support)
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index ee05b8836..f6c65b34a 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -10,6 +10,10 @@
/* Define to 1 if internal poll should be used. */
#undef AST_POLL_COMPAT
+/* Define to 1 if your system's implementation of mutexes supports comparison
+ of a mutex to its initializer. */
+#undef CAN_COMPARE_MUTEX_TO_INIT_VALUE
+
/* Define to 1 if the `closedir' function returns void instead of `int'. */
#undef CLOSEDIR_VOID
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index cc71322e3..99a5517dc 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -80,7 +80,7 @@
#define AST_PTHREADT_NULL (pthread_t) -1
#define AST_PTHREADT_STOP (pthread_t) -2
-#if (defined(SOLARIS) || defined(BSD)) && !defined(__Darwin__)
+#if (defined(SOLARIS) || defined(BSD))
#define AST_MUTEX_INIT_W_CONSTRUCTORS
#endif /* SOLARIS || BSD */
@@ -283,7 +283,7 @@ static inline int __ast_pthread_mutex_init(int track, const char *filename, int
int res;
pthread_mutexattr_t attr;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
/*
@@ -319,7 +319,7 @@ static inline int __ast_pthread_mutex_destroy(const char *filename, int lineno,
int res;
int canlog = strcmp(filename, "logger.c") & t->track;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
/* Don't try to uninitialize non initialized mutex
* This may no effect on linux
@@ -373,7 +373,7 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con
int res;
int canlog = strcmp(filename, "logger.c") & t->track;
-#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
/* Don't warn abount uninitialized mutex.
* Simple try to initialize it.
@@ -461,7 +461,7 @@ static inline int __ast_pthread_mutex_trylock(const char *filename, int lineno,
int res;
int canlog = strcmp(filename, "logger.c") & t->track;
-#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
/* Don't warn abount uninitialized mutex.
* Simple try to initialize it.
@@ -507,7 +507,7 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c
int res;
int canlog = strcmp(filename, "logger.c") & t->track;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
@@ -586,7 +586,7 @@ static inline int __ast_cond_wait(const char *filename, int lineno, const char *
int res;
int canlog = strcmp(filename, "logger.c") & t->track;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
@@ -657,7 +657,7 @@ static inline int __ast_cond_timedwait(const char *filename, int lineno, const c
int res;
int canlog = strcmp(filename, "logger.c") & t->track;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
filename, lineno, func, mutex_name);
@@ -893,8 +893,8 @@ static inline int __ast_rwlock_init(const char *filename, int lineno, const char
{
int res;
pthread_rwlockattr_t attr;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
- int canlog = strcmp(filename, "logger.c");
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
+ int canlog = strcmp(filename, "logger.c");
if (*prwlock != ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
__ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
@@ -919,7 +919,7 @@ static inline int __ast_rwlock_destroy(const char *filename, int lineno, const c
int res;
int canlog = strcmp(filename, "logger.c");
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
if (*prwlock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
__ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
filename, lineno, func, rwlock_name);
@@ -939,7 +939,7 @@ static inline int _ast_rwlock_unlock(ast_rwlock_t *lock, const char *name,
const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
@@ -964,7 +964,7 @@ static inline int _ast_rwlock_rdlock(ast_rwlock_t *lock, const char *name,
const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
@@ -995,7 +995,7 @@ static inline int _ast_rwlock_wrlock(ast_rwlock_t *lock, const char *name,
const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
@@ -1025,7 +1025,7 @@ static inline int _ast_rwlock_timedrdlock(ast_rwlock_t *lock, const char *name,
struct timespec *abs_timeout, const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
@@ -1071,7 +1071,7 @@ static inline int _ast_rwlock_timedwrlock(ast_rwlock_t *lock, const char *name,
struct timespec *abs_timeout, const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
@@ -1117,7 +1117,7 @@ static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *lock, const char *name,
const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {
@@ -1148,7 +1148,7 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *lock, const char *name,
const char *file, int line, const char *func)
{
int res;
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
int canlog = strcmp(file, "logger.c");
if (*lock == ((ast_rwlock_t) AST_RWLOCK_INIT_VALUE)) {