blob: 5065bcc1c5c2a192110d998b7ae251d0993f9e75 [file] [log] [blame]
Austin Schuh906616c2019-01-21 20:25:11 -08001# 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
15AC_DEFUN([AC_RWLOCK],
16[AC_CACHE_CHECK(support for pthread_rwlock_* functions,
17ac_cv_rwlock,
18[AC_LANG_SAVE
19 AC_LANG_C
20 AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
21 #include <pthread.h>],
22 [pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
23 pthread_rwlock_rdlock(&l);
24 return 0;],
25 ac_cv_rwlock=yes, ac_cv_rwlock=no)
26 AC_LANG_RESTORE
27])
28if test "$ac_cv_rwlock" = yes; then
29 AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
30fi
31])