ac_rwlock.m4 1.1 KB

12345678910111213141516171819202122232425262728293031
  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. # Check for support for pthread_rwlock_init() etc.
  5. # These aren't posix, but are widely supported. To get them on linux,
  6. # you need to define _XOPEN_SOURCE first, so this check assumes your
  7. # application does that.
  8. #
  9. # Note: OS X (as of 6/1/06) seems to support pthread_rwlock, but
  10. # doesn't define PTHREAD_RWLOCK_INITIALIZER. Therefore, we don't test
  11. # that particularly macro. It's probably best if you don't use that
  12. # macro in your code either.
  13. AC_DEFUN([AC_RWLOCK],
  14. [AC_CACHE_CHECK(support for pthread_rwlock_* functions,
  15. ac_cv_rwlock,
  16. [AC_LANG_SAVE
  17. AC_LANG_C
  18. AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
  19. #include <pthread.h>],
  20. [pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
  21. pthread_rwlock_rdlock(&l);
  22. return 0;],
  23. ac_cv_rwlock=yes, ac_cv_rwlock=no)
  24. AC_LANG_RESTORE
  25. ])
  26. if test "$ac_cv_rwlock" = yes; then
  27. AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
  28. fi
  29. ])