git-merge-changelog: Simplify installation instructions.
[gnulib.git] / m4 / pthread_mutex_timedlock.m4
blob46b59d793ce1b48a6275530db32a8c2a07187f4a
1 # pthread_mutex_timedlock.m4
2 # serial 5
3 dnl Copyright (C) 2019-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK],
10   AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
12   AC_CHECK_DECL([pthread_mutex_timedlock],
13     [dnl Test whether the gnulib module 'threadlib' is in use.
14      dnl Some packages like Emacs use --avoid=threadlib.
15      dnl Write the symbol in such a way that it does not cause 'aclocal' to pick
16      dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/.
17      m4_ifdef([gl_][THREADLIB], [
18        AC_REQUIRE([gl_][THREADLIB])
19        dnl Test whether the function actually exists.
20        dnl FreeBSD 5.2.1 declares it but does not define it.
21        AC_CACHE_CHECK([for pthread_mutex_timedlock],
22          [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD],
23          [gl_saved_LIBS="$LIBS"
24           LIBS="$LIBS $LIBMULTITHREAD"
25           AC_LINK_IFELSE(
26             [AC_LANG_PROGRAM(
27                [[#include <pthread.h>
28                  #include <time.h>
29                ]],
30                [[pthread_mutex_t lock;
31                  return pthread_mutex_timedlock (&lock, (struct timespec *) 0);
32                ]])
33             ],
34             [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=yes],
35             [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=no])
36           LIBS="$gl_saved_LIBS"
37          ])
38        if test $gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD != yes; then
39          HAVE_PTHREAD_MUTEX_TIMEDLOCK=0
40        fi
41      ], [
42        :
43      ])
44     ],
45     [HAVE_PTHREAD_MUTEX_TIMEDLOCK=0],
46     [[#include <pthread.h>]])