1 # pthread-rwlock.m4 serial 2
2 dnl Copyright (C) 2019-2020 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.
7 AC_DEFUN([gl_PTHREAD_RWLOCK],
9 AC_REQUIRE([gl_PTHREAD_H])
10 AC_REQUIRE([AC_CANONICAL_HOST])
12 if { case "$host_os" in mingw*) true;; *) false;; esac; } \
13 && test $gl_threads_api = windows; then
14 dnl Choose function names that don't conflict with the mingw-w64 winpthreads
16 REPLACE_PTHREAD_RWLOCK_INIT=1
17 REPLACE_PTHREAD_RWLOCKATTR_INIT=1
18 REPLACE_PTHREAD_RWLOCKATTR_DESTROY=1
19 REPLACE_PTHREAD_RWLOCK_RDLOCK=1
20 REPLACE_PTHREAD_RWLOCK_WRLOCK=1
21 REPLACE_PTHREAD_RWLOCK_TRYRDLOCK=1
22 REPLACE_PTHREAD_RWLOCK_TRYWRLOCK=1
23 REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK=1
24 REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK=1
25 REPLACE_PTHREAD_RWLOCK_UNLOCK=1
26 REPLACE_PTHREAD_RWLOCK_DESTROY=1
28 if test $HAVE_PTHREAD_H = 0; then
29 HAVE_PTHREAD_RWLOCK_INIT=0
30 HAVE_PTHREAD_RWLOCKATTR_INIT=0
31 HAVE_PTHREAD_RWLOCKATTR_DESTROY=0
32 HAVE_PTHREAD_RWLOCK_RDLOCK=0
33 HAVE_PTHREAD_RWLOCK_WRLOCK=0
34 HAVE_PTHREAD_RWLOCK_TRYRDLOCK=0
35 HAVE_PTHREAD_RWLOCK_TRYWRLOCK=0
36 HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK=0
37 HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK=0
38 HAVE_PTHREAD_RWLOCK_UNLOCK=0
39 HAVE_PTHREAD_RWLOCK_DESTROY=0
41 dnl On Android 4.3, the pthread_rwlock_* functions are declared in
42 dnl <pthread.h> but don't exist in libc.
43 AC_CACHE_CHECK([for pthread_rwlock_init],
44 [gl_cv_func_pthread_rwlock_init],
46 LIBS="$LIBS $LIBPMULTITHREAD"
53 int pthread_rwlock_init (void);
56 return pthread_rwlock_init ();
59 [gl_cv_func_pthread_rwlock_init=yes],
60 [gl_cv_func_pthread_rwlock_init=no])
63 if test $gl_cv_func_pthread_rwlock_init = no; then
64 REPLACE_PTHREAD_RWLOCK_INIT=1
65 REPLACE_PTHREAD_RWLOCKATTR_INIT=1
66 REPLACE_PTHREAD_RWLOCKATTR_DESTROY=1
67 REPLACE_PTHREAD_RWLOCK_RDLOCK=1
68 REPLACE_PTHREAD_RWLOCK_WRLOCK=1
69 REPLACE_PTHREAD_RWLOCK_TRYRDLOCK=1
70 REPLACE_PTHREAD_RWLOCK_TRYWRLOCK=1
71 REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK=1
72 REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK=1
73 REPLACE_PTHREAD_RWLOCK_UNLOCK=1
74 REPLACE_PTHREAD_RWLOCK_DESTROY=1
75 AC_DEFINE([PTHREAD_RWLOCK_UNIMPLEMENTED], [1],
76 [Define if all pthread_rwlock* functions don't exist.])
78 dnl On Mac OS X 10.5, FreeBSD 5.2.1, OpenBSD 3.8, AIX 5.1, HP-UX 11,
79 dnl IRIX 6.5, Solaris 9, Cygwin, the pthread_rwlock_timed*lock functions
80 dnl don't exist, although the other pthread_rwlock* functions exist.
81 AC_CHECK_DECL([pthread_rwlock_timedrdlock], ,
82 [HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK=0
83 HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK=0
84 AC_DEFINE([PTHREAD_RWLOCK_LACKS_TIMEOUT], [1],
85 [Define if the functions pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock don't exist.])
87 [[#include <pthread.h>]])