Sevan Janiyan wrote: > OS X 10.4 Tiger definitely lacks pthread_rwlock_init()
According to our function database https://git.savannah.gnu.org/gitweb/?p=gnulib/maint-tools.git;a=tree;f=platforms/various-symlists;h=959af7a410a8416f4b183793ac2dae7e1063024f;hb=HEAD the function does exist in Mac OS X 10.3, 10.4, and 10.5. In 10.5 they added an alias pthread_rwlock_init$UNIX2003, but that is not relevant for the autoconf test. > 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" > ]) > > Compiling the test case with 'cc -Wall -O2 -lpthread' by hand results in > Bus Error What do you mean? You get a Bus Error already at compile time, i.e. the compiler or linker crashes? Or do you get a Bus Error by running that test program? I.e. as if we had an AC_RUN_IFELSE instead of AC_LINK_IFELSE in the above test? > Otherwise things fail during compilation because it's > expecting an implementation from the host. > test-pthread.c:33: error: ‘PTHREAD_RWLOCK_INITIALIZER’ undeclared here > (not in a function). Ah, but that is a different problem. What you report here is that no macro PTHREAD_RWLOCK_INITIALIZER is defined in Mac OS X 10.4, while it exists in 10.5: #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}} It looks like lib/glthread/lock.h does better efforts at handling the lack of PTHREAD_RWLOCK_INITIALIZER than lib/pthread.in.h. What is the result if you change lib/pthread.in.h? diff --git a/lib/pthread.in.h b/lib/pthread.in.h index 48e0837478..fcba87dd9f 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -298,6 +298,9 @@ typedef unsigned int pthread_rwlockattr_t; { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 } #else # if @HAVE_PTHREAD_T@ +# if !defined PTHREAD_RWLOCK_INITIALIZER && (defined __APPLE__ && defined __MACH__) /* Mac OS X < 10.5 */ +# define PTHREAD_RWLOCK_INITIALIZER { _PTHREAD_RWLOCK_SIG_init, { 0 } } +# endif # if !defined PTHREAD_RWLOCK_INITIALIZER && defined PTHREAD_RWLOCK_INITIALIZER_NP /* z/OS */ # define PTHREAD_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER_NP # endif