Commit ab38ddc0 authored by Jan Maria Matejka's avatar Jan Maria Matejka Committed by Maria Matejka
Browse files

Autoconf: check whether pthread spinlock is implemented

This check is needed to build with pthreads on Android
parent 64857de3
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ AC_DEFUN([BIRD_CHECK_PTHREADS],
	    [
	      pthread_t pt;
	      pthread_create(&pt, NULL, NULL, NULL);
	      pthread_spinlock_t lock;
	      pthread_spin_lock(&lock);
	    ]
	  )
	],
@@ -50,6 +48,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.h> ],
	    [
	      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(
+7 −1
Original line number Diff line number Diff line
@@ -127,7 +127,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"

    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