diff options
author | Bruno Haible <bruno@clisp.org> | 2019-11-21 11:44:01 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2019-11-21 11:44:01 +0100 |
commit | 6dbeba577f4d54255895956b510f937ec9cd4228 (patch) | |
tree | 7fad2a078492e87933e0b2a99c9708848a2d8918 /m4/pthread-mutex.m4 | |
parent | a948afdbc503f885d368725e340afd78718e77f8 (diff) | |
download | gnulib-6dbeba577f4d54255895956b510f937ec9cd4228.tar.gz |
pthread-mutex: Fix errors in C++ mode.
* m4/pthread-mutex.m4 (gl_PTHREAD_MUTEX): Test whether
pthread_mutexattr_getrobust exists. If not, define
PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED.
* lib/pthread-mutex.c (pthread_mutexattr_getrobust,
pthread_mutexattr_setrobust): Define also if <pthread.h> exists but
PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED.
* modules/pthread-mutex (configure.ac): Compile pthread-mutex.c also
when <pthread.h> exists but pthread_mutexattr_getrobust needs a gnulib
definition.
Diffstat (limited to 'm4/pthread-mutex.m4')
-rw-r--r-- | m4/pthread-mutex.m4 | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/m4/pthread-mutex.m4 b/m4/pthread-mutex.m4 index c7d74f96e5..abe5f2ffd8 100644 --- a/m4/pthread-mutex.m4 +++ b/m4/pthread-mutex.m4 @@ -1,4 +1,4 @@ -# pthread-mutex.m4 serial 1 +# pthread-mutex.m4 serial 2 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, @@ -39,6 +39,33 @@ AC_DEFUN([gl_PTHREAD_MUTEX], dnl HAVE_PTHREAD_MUTEX_TIMEDLOCK is set in pthread_mutex_timedlock.m4. HAVE_PTHREAD_MUTEX_UNLOCK=0 HAVE_PTHREAD_MUTEX_DESTROY=0 + else + AC_CACHE_CHECK([for pthread_mutexattr_getrobust], + [gl_cv_func_pthread_mutexattr_getrobust], + [saved_LIBS="$LIBS" + LIBS="$LIBS $LIBMULTITHREAD" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [[extern + #ifdef __cplusplus + "C" + #endif + int pthread_mutexattr_getrobust (void); + int main () + { + return pthread_mutexattr_getrobust (); + } + ]])], + [gl_cv_func_pthread_mutexattr_getrobust=yes], + [gl_cv_func_pthread_mutexattr_getrobust=no]) + LIBS="$saved_LIBS" + ]) + if test $gl_cv_func_pthread_mutexattr_getrobust = no; then + HAVE_PTHREAD_MUTEXATTR_GETROBUST=0 + HAVE_PTHREAD_MUTEXATTR_SETROBUST=0 + AC_DEFINE([PTHREAD_MUTEXATTR_ROBUST_UNIMPLEMENTED], [1], + [Define if the 'robust' attribute of pthread_mutex* doesn't exist.]) + fi fi fi ]) |