]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added configure test for QMutex::tryLock(int).
authorBart Van Assche <bvanassche@acm.org>
Mon, 28 Jul 2008 11:35:10 +0000 (11:35 +0000)
committerBart Van Assche <bvanassche@acm.org>
Mon, 28 Jul 2008 11:35:10 +0000 (11:35 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8462

configure.in
drd/tests/qt4_mutex.cpp

index db418503fc99b366f46247bd0e0db035bda82a85..a6827a90e18baf25f14bc6d6fb1ed8984d36bbab 100644 (file)
@@ -1234,7 +1234,7 @@ AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
 fi
 
 
-# Checks for header files.
+# Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([       \
         endian.h         \
@@ -1251,6 +1251,7 @@ AC_CHECK_HEADERS([       \
         sys/types.h      \
         ])
 
+# Checks for C++ header files.
 AC_LANG(C++)
 AC_CHECK_HEADERS([         \
         QtCore/QMutex      \
@@ -1425,6 +1426,31 @@ AC_TRY_COMPILE([ ],
 AM_CONDITIONAL([HAVE_QTCORE], [test x$ac_have_qtcore = xyes])
 
 
+# Test for QMutex::tryLock(int), which has been introduced in Qt 4.3.
+# See also http://doc.trolltech.com/4.3/qmutex.html.
+if test x$ac_have_qtcore = xyes; then
+  AC_MSG_CHECKING([for Qt4 QMutex::tryLock(int)])
+  AC_LANG(C++)
+  AC_TRY_COMPILE([
+    #include <QtCore/QMutex>
+  ],
+  [
+    QMutex M;
+    M.tryLock(1);
+    M.unlock();
+    return 0;
+  ],
+  [
+    AC_MSG_RESULT([yes])
+    AC_DEFINE([HAVE_QTCORE_QMUTEX_TRYLOCK_INT], [1], [Define to 1 if the installed version of Qt4 provides QMutex::tryLock(int).])
+  ],
+  [
+    AC_MSG_RESULT([no])
+  ])
+  AC_LANG(C)
+fi
+
+
 # -------------------- ok.  We're done. --------------------
 
 AC_OUTPUT(
index 36ee5cc4e306f8eb23a848b902a8da325797e3c4..beb5a09627521cdae481895ae51b2592882acd95 100644 (file)
@@ -4,6 +4,7 @@
 #define _GNU_SOURCE
 #endif
 
+#include "config.h"
 #include <QtCore/QMutex>  // class QMutex
 #include <QtCore/QThread> // class QThread
 #include <cassert>
@@ -56,12 +57,14 @@ int main(int argc, char** argv)
     M.unlock();
     M.unlock();
   }
+#if defined(HAVE_QTCORE_QMUTEX_TRYLOCK_INT)
   {
     QMutex M(QMutex::NonRecursive);
     assert(M.tryLock(1));
     assert(! M.tryLock(1));
     M.unlock();
   }
+#endif
 
   pthread_barrier_init(&s_barrier, 0, n_threads);
   s_pMutex = new QMutex();