1 dnl The libpthread.so library
3 dnl Copyright (C) 2016 Red Hat, Inc.
5 dnl This library is free software; you can redistribute it and/or
6 dnl modify it under the terms of the GNU Lesser General Public
7 dnl License as published by the Free Software Foundation; either
8 dnl version 2.1 of the License, or (at your option) any later version.
10 dnl This library is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 dnl Lesser General Public License for more details.
15 dnl You should have received a copy of the GNU Lesser General Public
16 dnl License along with this library. If not, see
17 dnl <http://www.gnu.org/licenses/>.
20 AC_DEFUN([LIBVIRT_CHECK_PTHREAD], [
23 dnl Availability of pthread functions. Because of $LIB_PTHREAD, we
24 dnl cannot use AC_CHECK_FUNCS_ONCE. LIB_PTHREAD and LIBMULTITHREAD
25 dnl were set during gl_INIT by gnulib.
26 LIBS="$LIBS $LIB_PTHREAD $LIBMULTITHREAD"
28 AC_CHECK_FUNCS([pthread_mutexattr_init])
29 AC_CHECK_HEADER([pthread.h],,[pthread_found=no])
31 if test "$ac_cv_func_pthread_mutexattr_init:$pthread_found" != "yes:yes"
33 AC_MSG_ERROR([A pthreads impl is required for building libvirt])
36 dnl At least mingw64-winpthreads #defines pthread_sigmask to 0,
37 dnl which in turn causes compilation to complain about unused variables.
38 dnl Expose this broken implementation, so we can work around it.
39 AC_CACHE_CHECK([whether pthread_sigmask does anything],
40 [lv_cv_pthread_sigmask_works],
41 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
42 #include <sys/types.h>
45 #ifdef pthread_sigmask
46 int (*foo)(int, const sigset_t *, sigset_t *) = &pthread_sigmask;
49 ]])], [lv_cv_pthread_sigmask_works=yes], [lv_cv_pthread_sigmask_works=no])])
50 if test "x$lv_cv_pthread_sigmask_works" != xyes; then
51 AC_DEFINE([FUNC_PTHREAD_SIGMASK_BROKEN], [1],
52 [Define to 1 if pthread_sigmask is not a real function])