From: Bart Van Assche Date: Mon, 28 Jul 2008 11:35:10 +0000 (+0000) Subject: Added configure test for QMutex::tryLock(int). X-Git-Tag: svn/VALGRIND_3_4_0~307 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ed795a56780973fe65b10be4ccc4935ae4be68f;p=thirdparty%2Fvalgrind.git Added configure test for QMutex::tryLock(int). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8462 --- diff --git a/configure.in b/configure.in index db418503fc..a6827a90e1 100644 --- a/configure.in +++ b/configure.in @@ -1234,7 +1234,7 @@ AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables]) fi -# Checks for header files. +# Checks for C 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 + ], + [ + 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( diff --git a/drd/tests/qt4_mutex.cpp b/drd/tests/qt4_mutex.cpp index 36ee5cc4e3..beb5a09627 100644 --- a/drd/tests/qt4_mutex.cpp +++ b/drd/tests/qt4_mutex.cpp @@ -4,6 +4,7 @@ #define _GNU_SOURCE #endif +#include "config.h" #include // class QMutex #include // class QThread #include @@ -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();