The pthread.h on Android has no definition for pthread_rwlock_t, which
makes the associated intercepts in Helgrind and DRD un-compilable.
Add a configure test for it, and use them to guard the aforementioned
intercepts.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11875 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/configure.in b/configure.in
index 8f22423..1bcff1e 100644
--- a/configure.in
+++ b/configure.in
@@ -846,6 +846,26 @@
 ])
 
 
+# Check for PTHREAD_RWLOCK_T
+
+AC_MSG_CHECKING([for pthread_rwlock_t])
+
+AC_TRY_COMPILE(
+[
+#define _GNU_SOURCE
+#include <pthread.h>
+], [
+  pthread_rwlock_t rwl;
+],
+[
+AC_MSG_RESULT([yes])
+AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
+          [Define to 1 if you have the `pthread_rwlock_t' type.])
+], [
+AC_MSG_RESULT([no])
+])
+
+
 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
 
 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c
index ac648e9..1cbaa99 100644
--- a/drd/drd_pthread_intercepts.c
+++ b/drd/drd_pthread_intercepts.c
@@ -999,6 +999,10 @@
 
 PTH_FUNCS(int, semZupost, sem_post_intercept, (sem_t *sem), (sem));
 
+/* Android's pthread.h doesn't say anything about rwlocks, hence these
+   functions have to be conditionally compiled. */
+#if defined(HAVE_PTHREAD_RWLOCK_T)
+
 static __always_inline
 int pthread_rwlock_init_intercept(pthread_rwlock_t* rwlock,
                                   const pthread_rwlockattr_t* attr)
@@ -1158,3 +1162,5 @@
 PTH_FUNCS(int,
           pthreadZurwlockZuunlock, pthread_rwlock_unlock_intercept,
           (pthread_rwlock_t* rwlock), (rwlock));
+
+#endif /* defined(HAVE_PTHREAD_RWLOCK_T) */
diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c
index 798ee6c..20b368c 100644
--- a/helgrind/hg_intercepts.c
+++ b/helgrind/hg_intercepts.c
@@ -1274,6 +1274,10 @@
 /*--- pthread_rwlock_t functions                               ---*/
 /*----------------------------------------------------------------*/
 
+/* Android's pthread.h doesn't say anything about rwlocks, hence these
+   functions have to be conditionally compiled. */
+#if defined(HAVE_PTHREAD_RWLOCK_T)
+
 /* Handled:   pthread_rwlock_init pthread_rwlock_destroy
               pthread_rwlock_rdlock 
               pthread_rwlock_wrlock
@@ -1618,6 +1622,8 @@
 #  error "Unsupported OS"
 #endif
 
+#endif /* defined(HAVE_PTHREAD_RWLOCK_T) */
+
 
 /*----------------------------------------------------------------*/
 /*--- POSIX semaphores                                         ---*/