[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Test for pthread_rwlock_init() always passes, regardless
From: |
Bruno Haible |
Subject: |
Re: Test for pthread_rwlock_init() always passes, regardless |
Date: |
Thu, 09 Nov 2023 03:36:50 +0100 |
Sevan Janiyan wrote:
> I get a Bus Error when I try to run the program.
This is normal. pthread_rwlock_init expects two arguments, and the test program
- being a link test - doesn't pass any.
> The patch passes that error and then fails in compiling test-lock.c
> because _PTHREAD_RWLOCK_SIG_init is not defined.
The lack of PTHREAD_RWLOCK_INITIALIZER is the only problem we have identified
so far. But it is severe enough that gnulib better overrides all
pthread_rwlock_* functions. Done through this patch:
2023-11-08 Bruno Haible <bruno@clisp.org>
pthread-rwlock: Port to Mac OS X 10.4.
Reported by Sevan Janiyan <venture37@geeklan.co.uk>.
* m4/pthread-rwlock.m4 (gl_PTHREAD_RWLOCK): On macOS, test for the
presence of PTHREAD_RWLOCK_INITIALIZER. If it is not defined, don't
attempt to use pthread_rwlock_init.
diff --git a/m4/pthread-rwlock.m4 b/m4/pthread-rwlock.m4
index 681655a523..8ab694103c 100644
--- a/m4/pthread-rwlock.m4
+++ b/m4/pthread-rwlock.m4
@@ -1,4 +1,4 @@
-# pthread-rwlock.m4 serial 3
+# pthread-rwlock.m4 serial 4
dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -38,27 +38,42 @@ AC_DEFUN([gl_PTHREAD_RWLOCK]
HAVE_PTHREAD_RWLOCK_UNLOCK=0
HAVE_PTHREAD_RWLOCK_DESTROY=0
else
+ dnl On Mac OS X 10.4, the pthread_rwlock_* functions exist but are not
+ dnl usable because PTHREAD_RWLOCK_INITIALIZER is not defined.
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 $LIBPMULTITHREAD"
- 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"
+ [case "$host_os" in
+ darwin*)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE(
+ [[#include <pthread.h>
+ pthread_rwlock_t l = PTHREAD_RWLOCK_INITIALIZER;
+ ]])],
+ [gl_cv_func_pthread_rwlock_init=yes],
+ [gl_cv_func_pthread_rwlock_init=no])
+ ;;
+ *)
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $LIBPMULTITHREAD"
+ 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"
+ ;;
+ esac
])
if test $gl_cv_func_pthread_rwlock_init = no; then
REPLACE_PTHREAD_RWLOCK_INIT=1
- Test for pthread_rwlock_init() always passes, regardless, Sevan Janiyan, 2023/11/08
- Re: Test for pthread_rwlock_init() always passes, regardless, Bruno Haible, 2023/11/08
- Re: Test for pthread_rwlock_init() always passes, regardless, Sevan Janiyan, 2023/11/08
- Re: Test for pthread_rwlock_init() always passes, regardless, Bruno Haible, 2023/11/08
- Re: Test for pthread_rwlock_init() always passes, regardless,
Bruno Haible <=
- Re: Test for pthread_rwlock_init() always passes, regardless, Sevan Janiyan, 2023/11/09
- Re: Test for pthread_rwlock_init() always passes, regardless, Bruno Haible, 2023/11/09
- Re: Test for pthread_rwlock_init() always passes, regardless, Sevan Janiyan, 2023/11/16
- Re: Test for pthread_rwlock_init() always passes, regardless, Sevan Janiyan, 2023/11/17
- Re: Test for pthread_rwlock_init() always passes, regardless, Sevan Janiyan, 2023/11/30
- Re: generic configure tests, Bruno Haible, 2023/11/09
- Re: generic configure tests, Sevan Janiyan, 2023/11/09