| 1 |
# pthread-mutex.m4 |
| 2 |
# serial 4 |
| 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_PTHREAD_MUTEX], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_PTHREAD_H]) |
| 12 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 13 |
|
| 14 |
if { case "$host_os" in mingw* | windows*) true;; *) false;; esac; } \ |
| 15 |
&& test $gl_threads_api = windows; then |
| 16 |
dnl Choose function names that don't conflict with the mingw-w64 winpthreads |
| 17 |
dnl library. |
| 18 |
REPLACE_PTHREAD_MUTEX_INIT=1 |
| 19 |
REPLACE_PTHREAD_MUTEXATTR_INIT=1 |
| 20 |
REPLACE_PTHREAD_MUTEXATTR_GETTYPE=1 |
| 21 |
REPLACE_PTHREAD_MUTEXATTR_SETTYPE=1 |
| 22 |
REPLACE_PTHREAD_MUTEXATTR_GETROBUST=1 |
| 23 |
REPLACE_PTHREAD_MUTEXATTR_SETROBUST=1 |
| 24 |
REPLACE_PTHREAD_MUTEXATTR_DESTROY=1 |
| 25 |
REPLACE_PTHREAD_MUTEX_LOCK=1 |
| 26 |
REPLACE_PTHREAD_MUTEX_TRYLOCK=1 |
| 27 |
REPLACE_PTHREAD_MUTEX_TIMEDLOCK=1 |
| 28 |
REPLACE_PTHREAD_MUTEX_UNLOCK=1 |
| 29 |
REPLACE_PTHREAD_MUTEX_DESTROY=1 |
| 30 |
else |
| 31 |
if test $HAVE_PTHREAD_H = 0; then |
| 32 |
HAVE_PTHREAD_MUTEX_INIT=0 |
| 33 |
HAVE_PTHREAD_MUTEXATTR_INIT=0 |
| 34 |
HAVE_PTHREAD_MUTEXATTR_GETTYPE=0 |
| 35 |
HAVE_PTHREAD_MUTEXATTR_SETTYPE=0 |
| 36 |
HAVE_PTHREAD_MUTEXATTR_GETROBUST=0 |
| 37 |
HAVE_PTHREAD_MUTEXATTR_SETROBUST=0 |
| 38 |
HAVE_PTHREAD_MUTEXATTR_DESTROY=0 |
| 39 |
HAVE_PTHREAD_MUTEX_LOCK=0 |
| 40 |
HAVE_PTHREAD_MUTEX_TRYLOCK=0 |
| 41 |
dnl HAVE_PTHREAD_MUTEX_TIMEDLOCK is set in pthread_mutex_timedlock.m4. |
| 42 |
HAVE_PTHREAD_MUTEX_UNLOCK=0 |
| 43 |
HAVE_PTHREAD_MUTEX_DESTROY=0 |
| 44 |
else |
| 45 |
AC_CACHE_CHECK([for pthread_mutexattr_getrobust], |
| 46 |
[gl_cv_func_pthread_mutexattr_getrobust], |
| 47 |
[saved_LIBS="$LIBS" |
| 48 |
LIBS="$LIBS $LIBPMULTITHREAD" |
| 49 |
AC_LINK_IFELSE( |
| 50 |
[AC_LANG_SOURCE( |
| 51 |
[[extern |
| 52 |
#ifdef __cplusplus |
| 53 |
"C" |
| 54 |
#endif |
| 55 |
int pthread_mutexattr_getrobust (void); |
| 56 |
int main () |
| 57 |
{ |
| 58 |
return pthread_mutexattr_getrobust (); |
| 59 |
} |
| 60 |
]])], |
| 61 |
[gl_cv_func_pthread_mutexattr_getrobust=yes], |
| 62 |
[gl_cv_func_pthread_mutexattr_getrobust=no]) |
| 63 |
LIBS="$saved_LIBS" |
| 64 |
]) |
| 65 |
if test $gl_cv_func_pthread_mutexattr_getrobust = no; then |
| 66 |
HAVE_PTHREAD_MUTEXATTR_GETROBUST=0 |
| 67 |
HAVE_PTHREAD_MUTEXATTR_SETROBUST=0 |
| 68 |
AC_DEFINE([PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED], [1], |
| 69 |
[Define if the 'robust' attribute of pthread_mutex* doesn't exist.]) |
| 70 |
fi |
| 71 |
fi |
| 72 |
fi |
| 73 |
]) |