summaryrefslogtreecommitdiff
path: root/m4/pthread-rwlock.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/pthread-rwlock.m4')
-rw-r--r--m4/pthread-rwlock.m491
1 files changed, 91 insertions, 0 deletions
diff --git a/m4/pthread-rwlock.m4 b/m4/pthread-rwlock.m4
new file mode 100644
index 0000000000..ee5953c74b
--- /dev/null
+++ b/m4/pthread-rwlock.m4
@@ -0,0 +1,91 @@
+# pthread-rwlock.m4 serial 1
+dnl Copyright (C) 2019 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_PTHREAD_RWLOCK],
+[
+ AC_REQUIRE([gl_PTHREAD_H])
+ AC_REQUIRE([AC_CANONICAL_HOST])
+
+ if { case "$host_os" in mingw*) true;; *) false;; esac; } \
+ && test $gl_threads_api = windows; then
+ dnl Choose function names that don't conflict with the mingw-w64 winpthreads
+ dnl library.
+ REPLACE_PTHREAD_RWLOCK_INIT=1
+ REPLACE_PTHREAD_RWLOCKATTR_INIT=1
+ REPLACE_PTHREAD_RWLOCKATTR_DESTROY=1
+ REPLACE_PTHREAD_RWLOCK_RDLOCK=1
+ REPLACE_PTHREAD_RWLOCK_WRLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TRYRDLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TRYWRLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK=1
+ REPLACE_PTHREAD_RWLOCK_UNLOCK=1
+ REPLACE_PTHREAD_RWLOCK_DESTROY=1
+ else
+ if test $HAVE_PTHREAD_H = 0; then
+ HAVE_PTHREAD_RWLOCK_INIT=0
+ HAVE_PTHREAD_RWLOCKATTR_INIT=0
+ HAVE_PTHREAD_RWLOCKATTR_DESTROY=0
+ HAVE_PTHREAD_RWLOCK_RDLOCK=0
+ HAVE_PTHREAD_RWLOCK_WRLOCK=0
+ HAVE_PTHREAD_RWLOCK_TRYRDLOCK=0
+ HAVE_PTHREAD_RWLOCK_TRYWRLOCK=0
+ HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK=0
+ HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK=0
+ HAVE_PTHREAD_RWLOCK_UNLOCK=0
+ HAVE_PTHREAD_RWLOCK_DESTROY=0
+ else
+ dnl On Android 4.3, the pthread_rwlock_* functions are declared in
+ dnl <pthread.h> but don't exist in libc.
+ AC_CACHE_CHECK([for pthread_rwlock_init],
+ [gl_cv_func_pthread_rwlock_init],
+ [saved_LIBS="$LIBS"
+ LIBS="$LIBS $LIBMULTITHREAD"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(
+ [[extern
+ #ifdef __cplusplus
+ "C"
+ #endif
+ int pthread_rwlock_init (void);
+ int main ()
+ {
+ return pthread_rwlock_init ();
+ }
+ ]])],
+ [gl_cv_func_pthread_rwlock_init=yes],
+ [gl_cv_func_pthread_rwlock_init=no])
+ LIBS="$saved_LIBS"
+ ])
+ if test $gl_cv_func_pthread_rwlock_init = no; then
+ REPLACE_PTHREAD_RWLOCK_INIT=1
+ REPLACE_PTHREAD_RWLOCKATTR_INIT=1
+ REPLACE_PTHREAD_RWLOCKATTR_DESTROY=1
+ REPLACE_PTHREAD_RWLOCK_RDLOCK=1
+ REPLACE_PTHREAD_RWLOCK_WRLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TRYRDLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TRYWRLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TIMEDRDLOCK=1
+ REPLACE_PTHREAD_RWLOCK_TIMEDWRLOCK=1
+ REPLACE_PTHREAD_RWLOCK_UNLOCK=1
+ REPLACE_PTHREAD_RWLOCK_DESTROY=1
+ AC_DEFINE([PTHREAD_RWLOCK_UNIMPLEMENTED], [1],
+ [Define if all pthread_rwlock* functions don't exist.])
+ else
+ dnl On Mac OS X 10.5, FreeBSD 5.2.1, OpenBSD 3.8, AIX 5.1, HP-UX 11,
+ dnl IRIX 6.5, Solaris 9, Cygwin, the pthread_rwlock_timed*lock functions
+ dnl don't exist, although the other pthread_rwlock* functions exist.
+ AC_CHECK_DECL([pthread_rwlock_timedrdlock], ,
+ [HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK=0
+ HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK=0
+ AC_DEFINE([PTHREAD_RWLOCK_LACKS_TIMEOUT], [1],
+ [Define if the functions pthread_rwlock_timedrdlock and pthread_rwlock_timedwrlock don't exist.])
+ ],
+ [[#include <pthread.h>]])
+ fi
+ fi
+ fi
+])