Simplify Emacs part of pthread_sigmask support.
[bpt/emacs.git] / m4 / pthread_sigmask.m4
1 # pthread_sigmask.m4 serial 7
2 dnl Copyright (C) 2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK],
8 [
9 AC_CHECK_FUNCS_ONCE([pthread_sigmask])
10 LIB_PTHREAD_SIGMASK=
11 m4_ifdef([gl_THREADLIB], [
12 AC_REQUIRE([gl_THREADLIB])
13 if test "$gl_threads_api" = posix; then
14 if test $ac_cv_func_pthread_sigmask = yes; then
15 dnl pthread_sigmask is available without -lpthread.
16 :
17 else
18 if test -n "$LIBMULTITHREAD"; then
19 AC_CACHE_CHECK([for pthread_sigmask in $LIBMULTITHREAD],
20 [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD],
21 [gl_save_LIBS="$LIBS"
22 LIBS="$LIBS $LIBMULTITHREAD"
23 AC_LINK_IFELSE(
24 [AC_LANG_PROGRAM(
25 [[#include <pthread.h>
26 #include <signal.h>
27 ]],
28 [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 0);]])
29 ],
30 [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes],
31 [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no])
32 LIBS="$gl_save_LIBS"
33 ])
34 if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then
35 dnl pthread_sigmask is available with -lpthread.
36 LIB_PTHREAD_SIGMASK="$LIBMULTITHREAD"
37 else
38 dnl pthread_sigmask is not available at all.
39 HAVE_PTHREAD_SIGMASK=0
40 fi
41 else
42 dnl pthread_sigmask is not available at all.
43 HAVE_PTHREAD_SIGMASK=0
44 fi
45 fi
46 else
47 dnl pthread_sigmask may exist but does not interoperate with the chosen
48 dnl multithreading facility.
49 dnl If "$gl_threads_api" = pth, we could use the function pth_sigmask,
50 dnl but it is equivalent to sigprocmask, so we choose to emulate
51 dnl pthread_sigmask with sigprocmask also in this case. This yields fewer
52 dnl link dependencies.
53 if test $ac_cv_func_pthread_sigmask = yes; then
54 REPLACE_PTHREAD_SIGMASK=1
55 else
56 HAVE_PTHREAD_SIGMASK=0
57 fi
58 fi
59 ] ,[
60 dnl gl_THREADLIB is not in use. Assume the application wants
61 dnl POSIX semantics.
62 if test $ac_cv_func_pthread_sigmask != yes; then
63 gl_save_LIBS=$LIBS
64 AC_SEARCH_LIBS([pthread_sigmask], [pthread c_r])
65 LIBS=$gl_save_LIBS
66 if test "$ac_cv_search_pthread_sigmask" = no; then
67 HAVE_PTHREAD_SIGMASK=0
68 elif test "$ac_cv_search_pthread_sigmask" != 'none required'; then
69 LIB_PTHREAD_SIGMASK=$ac_cv_search_pthread_sigmask
70 fi
71 fi
72 ])
73 AC_SUBST([LIB_PTHREAD_SIGMASK])
74 dnl We don't need a variable LTLIB_PTHREAD_SIGMASK, because when
75 dnl "$gl_threads_api" = posix, $LTLIBMULTITHREAD and $LIBMULTITHREAD are the
76 dnl same: either both empty or both "-lpthread".
77 ])