Blame m4/ac_rwlock.m4

Packit 18d29c
# TODO(csilvers): it would be better to actually try to link against
Packit 18d29c
# -pthreads, to make sure it defines these methods, but that may be
Packit 18d29c
# too hard, since pthread support is really tricky.
Packit 18d29c
Packit 18d29c
# Check for support for pthread_rwlock_init() etc.
Packit 18d29c
# These aren't posix, but are widely supported.  To get them on linux,
Packit 18d29c
# you need to define _XOPEN_SOURCE first, so this check assumes your
Packit 18d29c
# application does that.
Packit 18d29c
#
Packit 18d29c
# Note: OS X (as of 6/1/06) seems to support pthread_rwlock, but
Packit 18d29c
# doesn't define PTHREAD_RWLOCK_INITIALIZER.  Therefore, we don't test
Packit 18d29c
# that particularly macro.  It's probably best if you don't use that
Packit 18d29c
# macro in your code either.
Packit 18d29c
Packit 18d29c
AC_DEFUN([AC_RWLOCK],
Packit 18d29c
[AC_CACHE_CHECK(support for pthread_rwlock_* functions,
Packit 18d29c
ac_cv_rwlock,
Packit 18d29c
[AC_LANG_SAVE
Packit 18d29c
 AC_LANG_C
Packit 18d29c
 AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
Packit 18d29c
                 #include <pthread.h>],
Packit 18d29c
		[pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
Packit 18d29c
                 pthread_rwlock_rdlock(&l); 
Packit 18d29c
                 return 0;],
Packit 18d29c
                ac_cv_rwlock=yes, ac_cv_rwlock=no)
Packit 18d29c
 AC_LANG_RESTORE
Packit 18d29c
])
Packit 18d29c
if test "$ac_cv_rwlock" = yes; then
Packit 18d29c
  AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
Packit 18d29c
fi
Packit 18d29c
])