+
+ if test -z "$THREADS_OBJ" ; then
+ wxUSE_THREADS=no
+ AC_MSG_WARN([No thread support on this system... disabled])
+ fi
+ fi
+
+ dnl do other tests only if we are using threads
+ if test "$wxUSE_THREADS" = "yes" ; then
+ AC_CHECK_FUNCS(thr_setconcurrency)
+
+ dnl define autoconf macro to check for given function in both pthread and
+ dnl posix4 libraries
+ dnl usage: AC_FUNC_THREAD(FUNCTION_NAME)
+ dnl VZ: TODO
+ dnl AC_DEFUN(AC_FUNC_THREAD,
+ dnl [
+ dnl AC_CHECK_LIB($THREADS_LINK, $1,
+ dnl AC_DEFINE(HAVE_`'translit($1, `A-Z', 'a-z'),
+ dnl [AC_CHECK_LIB([posix4], $1,
+ dnl [AC_DEFINE(HAVE_`'translit($1, `A-Z', 'a-z'))
+ dnl POSIX4_LINK=" -lposix4"
+ dnl ])
+ dnl ])
+ dnl ])
+
+ AC_CHECK_HEADERS(sched.h)
+
+ AC_CHECK_LIB($THREADS_LINK, sched_yield,
+ AC_DEFINE(HAVE_SCHED_YIELD),
+ [AC_CHECK_LIB([posix4], sched_yield,
+ [AC_DEFINE(HAVE_SCHED_YIELD) POSIX4_LINK=" -lposix4"],
+ AC_MSG_WARN(wxThread::Yield will not work properly)
+ )]
+ )
+
+ dnl to be able to set the thread priority, we need to have all of the
+ dnl following functions:
+ dnl 1. pthread_attr_getschedpolicy
+ dnl 2. sched_get_priority_min and sched_get_priority_max
+ dnl (this one can be in either libpthread or libposix4 (under Solaris))
+ dnl 3. pthread_attr_getschedparam and pthread_attr_setschedparam
+ HAVE_PRIOR_FUNCS=0
+ AC_CHECK_LIB($THREADS_LINK, pthread_attr_getschedpolicy,
+ AC_CHECK_LIB($THREADS_LINK, pthread_attr_setschedparam,
+ AC_CHECK_LIB($THREADS_LINK, sched_get_priority_max,
+ HAVE_PRIOR_FUNCS=1,
+ AC_CHECK_LIB([posix4], sched_get_priority_max,
+ [
+ HAVE_PRIOR_FUNCS=1
+ POSIX4_LINK=" -lposix4"
+ ],
+ )
+ )
+ )
+ )
+
+ if test "$HAVE_PRIOR_FUNCS" = 1; then
+ AC_DEFINE(HAVE_THREAD_PRIORITY_FUNCTIONS)
+ else
+ AC_MSG_WARN(Setting thread priority will not work)
+ fi
+
+ AC_CHECK_LIB($THREADS_LINK, pthread_cancel,
+ AC_DEFINE(HAVE_PTHREAD_CANCEL),
+ AC_MSG_WARN([wxThread::Kill() will not work properly]))
+
+ AC_CACHE_CHECK([for pthread_cleanup_push/pop], wx_cv_func_pthread_cleanup_push,
+ [
+ AC_TRY_COMPILE([#include <pthread.h>],
+ [
+ pthread_cleanup_push(NULL, NULL);
+ pthread_cleanup_pop(0);
+ ], [
+ wx_cv_func_pthread_cleanup_push=yes
+ ], [
+ wx_cv_func_pthread_cleanup_push=no
+ ])
+ ])
+
+ if test "$wx_cv_func_pthread_cleanup_push" = "yes"; then
+ AC_DEFINE(HAVE_THREAD_CLEANUP_FUNCTIONS)
+ fi
+
+ dnl mutexattr_t initialization is done in quite different ways on different
+ dnl platforms, so check for a few things:
+ dnl
+ dnl HAVE_MUTEX_RECURSIVE means that we can create recursive mutexes
+ dnl HAVE_MUTEXATTR_SETTYPE means that we do it using
+ dnl pthread_mutexattr_settype(PTHREAD_MUTEX_RECURSIVE) and if it is not
+ dnl defined, we do it by directly assigned
+ dnl PTHREAD_MUTEX_RECURSIVE_MUTEX_INITIALIZER_NP to attr
+
+ dnl we need _GNU_SOURCE to get PTHREAD_MUTEX_RECURSIVE with glibc 2.1+
+ dnl (strictly speaking we only need _XOPEN_SOURCE=500 but just defining
+ dnl this disables _BSD_SOURCE which breaks libtiff compilation, so it is
+ dnl simpler to just define _GNU_SOURCE to get everything)
+ if test "x$wx_lib_glibc21" = "xyes"; then
+ CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+ fi
+
+ AC_CACHE_CHECK([for pthread_mutexattr_t], wx_cv_type_pthread_mutexattr_t,
+ [
+ AC_TRY_COMPILE([#include <pthread.h>],
+ [
+ pthread_mutexattr_t attr;
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ ], [
+ wx_cv_type_pthread_mutexattr_t=yes
+ ], [
+ wx_cv_type_pthread_mutexattr_t=no
+ ]
+ )
+ ])
+
+ if test "$wx_cv_type_pthread_mutexattr_t" = "yes"; then
+ AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_T)
+ else
+ dnl don't despair, there may be another way to do it
+ AC_CACHE_CHECK([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER],
+ wx_cv_type_pthread_rec_mutex_init,
+ [
+ AC_TRY_COMPILE([#include <pthread.h>],
+ [
+ pthread_mutex_t attr = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+ ], [
+ wx_cv_type_pthread_rec_mutex_init=yes
+ ], [
+ wx_cv_type_pthread_rec_mutex_init=no
+ ]
+ )