| 1 |
# TODO(csilvers): it would be better to actually try to link against |
| 2 |
# -pthreads, to make sure it defines these methods, but that may be |
| 3 |
# too hard, since pthread support is really tricky. |
| 4 |
|
| 5 |
# Check for support for pthread_rwlock_init() etc. |
| 6 |
# These aren't posix, but are widely supported. To get them on linux, |
| 7 |
# you need to define _XOPEN_SOURCE first, so this check assumes your |
| 8 |
# application does that. |
| 9 |
# |
| 10 |
# Note: OS X (as of 6/1/06) seems to support pthread_rwlock, but |
| 11 |
# doesn't define PTHREAD_RWLOCK_INITIALIZER. Therefore, we don't test |
| 12 |
# that particularly macro. It's probably best if you don't use that |
| 13 |
# macro in your code either. |
| 14 |
# |
| 15 |
# Note: Cygwin (as of 12/1/08) has a bug in pthread_rwlock, where |
| 16 |
# if you try to acquire a read-lock twice, you get EDEADLCK, where |
| 17 |
# it should succeed. It would be nice to test for that, but we |
| 18 |
# can't do runtime checks here. So we just manually fail for CYGWIN. |
| 19 |
# TODO(csilvers): do better. |
| 20 |
|
| 21 |
AC_DEFUN([AC_RWLOCK], |
| 22 |
[AC_CACHE_CHECK(support for pthread_rwlock_* functions, |
| 23 |
ac_cv_rwlock, |
| 24 |
[AC_LANG_SAVE |
| 25 |
AC_LANG_C |
| 26 |
AC_TRY_COMPILE([#define _XOPEN_SOURCE 500 |
| 27 |
#include <pthread.h> |
| 28 |
#ifdef __CYGWIN32__ |
| 29 |
# error Cygwin has a bug in pthread_rwlock; disabling |
| 30 |
#endif], |
| 31 |
[pthread_rwlock_t l; pthread_rwlock_init(&l, NULL); |
| 32 |
pthread_rwlock_rdlock(&l); |
| 33 |
return 0;], |
| 34 |
ac_cv_rwlock=yes, ac_cv_rwlock=no) |
| 35 |
AC_LANG_RESTORE |
| 36 |
]) |
| 37 |
if test "$ac_cv_rwlock" = yes; then |
| 38 |
AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*]) |
| 39 |
fi |
| 40 |
]) |