1 # pthread_mutex_timedlock.m4
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"
27 [[#include <pthread.h>
30 [[pthread_mutex_t lock;
31 return pthread_mutex_timedlock (&lock, (struct timespec *) 0);
34 [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=yes],
35 [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=no])
38 if test $gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD != yes; then
39 HAVE_PTHREAD_MUTEX_TIMEDLOCK=0
45 [HAVE_PTHREAD_MUTEX_TIMEDLOCK=0],
46 [[#include <pthread.h>]])