Debian Codegraph @

m4/pthread_mutex_timedlock.m4

raw
1 # pthread_mutex_timedlock.m4
2 # serial 6
3 dnl Copyright (C) 2019-2025 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.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN([gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK],
10 [
11 AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
12
13 AC_CHECK_DECL([pthread_mutex_timedlock],
14 [dnl Test whether the gnulib module 'threadlib' is in use.
15 dnl Some packages like Emacs use --avoid=threadlib.
16 dnl Write the symbol in such a way that it does not cause 'aclocal' to pick
17 dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/.
18 m4_ifdef([gl_][THREADLIB], [
19 AC_REQUIRE([gl_][THREADLIB])
20 dnl Test whether the function actually exists.
21 dnl FreeBSD 5.2.1 declares it but does not define it.
22 AC_CACHE_CHECK([for pthread_mutex_timedlock],
23 [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD],
24 [gl_saved_LIBS="$LIBS"
25 LIBS="$LIBS $LIBMULTITHREAD"
26 AC_LINK_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <pthread.h>
29 #include <time.h>
30 ]],
31 [[pthread_mutex_t lock;
32 struct timespec ts = { 0 };
33 return pthread_mutex_timedlock (&lock, &ts);
34 ]])
35 ],
36 [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=yes],
37 [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=no])
38 LIBS="$gl_saved_LIBS"
39 ])
40 if test $gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD != yes; then
41 HAVE_PTHREAD_MUTEX_TIMEDLOCK=0
42 fi
43 ], [
44 :
45 ])
46 ],
47 [HAVE_PTHREAD_MUTEX_TIMEDLOCK=0],
48 [[#include <pthread.h>]])
49 ])