lock.m4 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # lock.m4 serial 14
  2. dnl Copyright (C) 2005-2021 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Bruno Haible.
  7. AC_DEFUN([gl_LOCK],
  8. [
  9. AC_REQUIRE([gl_THREADLIB])
  10. if test "$gl_threads_api" = posix; then
  11. # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
  12. # pthread_rwlock_* functions.
  13. has_rwlock=false
  14. AC_CHECK_TYPE([pthread_rwlock_t],
  15. [has_rwlock=true
  16. AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
  17. [Define if the POSIX multithreading library has read/write locks.])],
  18. [],
  19. [#include <pthread.h>])
  20. if $has_rwlock; then
  21. gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER
  22. fi
  23. # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
  24. AC_COMPILE_IFELSE([
  25. AC_LANG_PROGRAM(
  26. [[#include <pthread.h>]],
  27. [[
  28. #if __FreeBSD__ == 4
  29. error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
  30. #elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \
  31. && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
  32. error "No, in Mac OS X < 10.7 recursive mutexes actually don't work."
  33. #else
  34. int x = (int)PTHREAD_MUTEX_RECURSIVE;
  35. return !x;
  36. #endif
  37. ]])],
  38. [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
  39. [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
  40. fi
  41. gl_PREREQ_LOCK
  42. ])
  43. # Prerequisites of lib/glthread/lock.c.
  44. AC_DEFUN([gl_PREREQ_LOCK], [:])