]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 256370 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 6 Apr 2010 19:40:13 +0000 (19:40 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 6 Apr 2010 19:40:13 +0000 (19:40 +0000)
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: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@256372 65c4cc65-6c06-0410-ace0-fbb531ad65f3

configure
configure.ac
include/asterisk/autoconfig.h.in
include/asterisk/lock.h

index 4ead1baf11d1ec6fdd557ed088182b079b2d70df..e2e31f50e49cbf033172b1a7cd9a25464599d55a 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 242887 .
+# From configure.ac Revision: 242973 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.6.
 #
@@ -17543,6 +17543,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)
index 3d0c0ed3e168fa84a780e9caf0f53d2324e1a392..ef73d5f6745548463c63d9fbe86e39c5679b74ea 100644 (file)
@@ -542,6 +542,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)
index f58bb86f9d45a1effc3441de38d219d7271a2487..cf370af8b615281fe7e31affd116ea3aa5902194 100644 (file)
 /* 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
 
index e29de6116fbc01bb536f6f6322a6f669bff947b7..a000eca066fc25e464368e1cbd49135a4f20cf01 100644 (file)
@@ -82,7 +82,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 */
 
@@ -379,7 +379,7 @@ static inline int __ast_pthread_mutex_init(int tracking, const char *filename, i
        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)) {
 /*
@@ -416,7 +416,7 @@ static inline int __ast_pthread_mutex_destroy(const char *filename, int lineno,
        struct ast_lock_track *lt;
        int canlog = strcmp(filename, "logger.c") & t->tracking;
 
-#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
@@ -484,7 +484,7 @@ static inline int __ast_pthread_mutex_lock(const char *filename, int lineno, con
        struct ast_bt *bt = NULL;
 #endif
 
-#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.
@@ -608,7 +608,7 @@ static inline int __ast_pthread_mutex_trylock(const char *filename, int lineno,
        struct ast_bt *bt = NULL;
 #endif
 
-#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.
@@ -670,7 +670,7 @@ static inline int __ast_pthread_mutex_unlock(const char *filename, int lineno, c
        struct ast_bt *bt = NULL;
 #endif
 
-#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);
@@ -767,7 +767,7 @@ static inline int __ast_cond_wait(const char *filename, int lineno, const char *
        struct ast_bt *bt = NULL;
 #endif
 
-#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);
@@ -865,7 +865,7 @@ static inline int __ast_cond_timedwait(const char *filename, int lineno, const c
        struct ast_bt *bt = NULL;
 #endif
 
-#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);
@@ -1010,8 +1010,8 @@ static inline int __ast_rwlock_init(int tracking, const char *filename, int line
        struct ast_lock_track *lt= &t->track;
        pthread_rwlockattr_t attr;
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
-        int canlog = strcmp(filename, "logger.c") & t->tracking;
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
+       int canlog = strcmp(filename, "logger.c") & t->tracking;
 
        if (t->lock != ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
@@ -1039,7 +1039,7 @@ static inline int __ast_rwlock_destroy(const char *filename, int lineno, const c
        struct ast_lock_track *lt = &t->track;
        int canlog = strcmp(filename, "logger.c") & t->tracking;
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        if (t->lock == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
                                   filename, lineno, func, rwlock_name);
@@ -1078,7 +1078,7 @@ static inline int _ast_rwlock_unlock(ast_rwlock_t *t, const char *name,
        int lock_found = 0;
 
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                __ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
                                   filename, line, func, name);
@@ -1151,7 +1151,7 @@ static inline int _ast_rwlock_rdlock(ast_rwlock_t *t, const char *name,
        struct ast_bt *bt = NULL;
 #endif
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                 /* Don't warn abount uninitialized lock.
                  * Simple try to initialize it.
@@ -1259,7 +1259,7 @@ static inline int _ast_rwlock_wrlock(ast_rwlock_t *t, const char *name,
        struct ast_bt *bt = NULL;
 #endif
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                 /* Don't warn abount uninitialized lock.
                  * Simple try to initialize it.
@@ -1369,7 +1369,7 @@ static inline int _ast_rwlock_timedrdlock(ast_rwlock_t *t, const char *name,
        struct ast_bt *bt = NULL;
 #endif
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                 /* Don't warn abount uninitialized lock.
                  * Simple try to initialize it.
@@ -1464,7 +1464,7 @@ static inline int _ast_rwlock_timedwrlock(ast_rwlock_t *t, const char *name,
        struct ast_bt *bt = NULL;
 #endif
 
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
                 /* Don't warn abount uninitialized lock.
                  * Simple try to initialize it.
@@ -1554,7 +1554,7 @@ static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *t, const char *name,
 #ifdef HAVE_BKTR
        struct ast_bt *bt = NULL;
 #endif
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        int canlog = strcmp(filename, "logger.c") & t->tracking;
 
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
@@ -1612,7 +1612,7 @@ static inline int _ast_rwlock_trywrlock(ast_rwlock_t *t, const char *name,
 #ifdef HAVE_BKTR
        struct ast_bt *bt = NULL;
 #endif
-#ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+#if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
        int canlog = strcmp(filename, "logger.c") & t->tracking;
 
        if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {