diff --git a/aclocal.m4 b/aclocal.m4 index c401d447..d70ca7cf 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -17,8 +17,6 @@ AC_DEFUN([BIRD_CHECK_PTHREADS], [ pthread_t pt; pthread_create(&pt, NULL, NULL, NULL); - pthread_spinlock_t lock; - pthread_spin_lock(&lock); ] ) ], @@ -31,6 +29,30 @@ AC_DEFUN([BIRD_CHECK_PTHREADS], CFLAGS="$bird_tmp_cflags" ]) +dnl ** Android API before version 24 doesn't implement spinlocks. +AC_DEFUN([BIRD_CHECK_PTHREAD_SPINLOCK], +[ + AC_CACHE_CHECK( + [whether POSIX threads provide spinlocks], + [bird_cv_lib_pthread_spinlock], + [ + AC_LINK_IFELSE( + [ + AC_LANG_PROGRAM( + [ #include ], + [ + pthread_spinlock_t lock; + pthread_spin_lock(&lock); + ] + ) + ], + [bird_cv_lib_pthread_spinlock=yes], + [bird_cv_lib_pthread_spinlock=no] + ) + ] + ) +]) + AC_DEFUN([BIRD_CHECK_MPLS_KERNEL], [ AC_CACHE_CHECK( diff --git a/configure.ac b/configure.ac index 943d3a7b..cfda4c7f 100644 --- a/configure.ac +++ b/configure.ac @@ -120,7 +120,13 @@ if test "$enable_pthreads" != no ; then AC_DEFINE([USE_PTHREADS], [1], [Define to 1 if pthreads are enabled]) CFLAGS="$CFLAGS -pthread" LDFLAGS="$LDFLAGS -pthread" - proto_bfd=bfd + + BIRD_CHECK_PTHREAD_SPINLOCK + if test "$bird_cv_lib_pthread_spinlock" = yes ; then + AC_DEFINE([USE_PTHREAD_SPINLOCK], [1], [Define to 1 if pthreads provide spinlocks]) + proto_bfd=bfd + fi + elif test "$enable_pthreads" = yes ; then AC_MSG_ERROR([POSIX threads not available.]) fi diff --git a/doc/bird.sgml b/doc/bird.sgml index 0057d2c5..fdfae2a6 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -653,7 +653,7 @@ agreement").