PageRenderTime 9ms CodeModel.GetById 6ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/m4/ac_rwlock.m4

http://cmockery.googlecode.com/
m4 | 31 lines | 16 code | 2 blank | 13 comment | 0 complexity | 234519c0265896c9c6601719140acd05 MD5 | raw file
 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
15AC_DEFUN([AC_RWLOCK],
16[AC_CACHE_CHECK(support for pthread_rwlock_* functions,
17ac_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_rwlock=yes, ac_rwlock=no)
26 AC_LANG_RESTORE
27])
28if test "$ac_rwlock" = yes; then
29  AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
30fi
31])