news: Update for SMMUv3 IOMMU support
[libvirt/ericb.git] / m4 / virt-pthread.m4
blob5b3750e8e9d34607c3093bf339fcbae1b3fae38e
1 dnl The libpthread.so library
2 dnl
3 dnl Copyright (C) 2016 Red Hat, Inc.
4 dnl
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.
9 dnl
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.
14 dnl
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/>.
18 dnl
20 AC_DEFUN([LIBVIRT_CHECK_PTHREAD], [
21   old_LIBS="$LIBS"
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"
27   pthread_found=yes
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"
32   then
33     AC_MSG_ERROR([A pthreads impl is required for building libvirt])
34   fi
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>
43       #include <signal.h>
44     ]], [[
45       #ifdef pthread_sigmask
46       int (*foo)(int, const sigset_t *, sigset_t *) = &pthread_sigmask;
47       return !foo;
48       #endif
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])
53   fi
55   LIBS="$old_LIBS"