The pthread.h on Android has no definition for pthread_rwlock_t, which
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mon, 11 Jul 2011 22:11:58 +0000 (22:11 +0000)
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Mon, 11 Jul 2011 22:11:58 +0000 (22:11 +0000)
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

configure.in
drd/drd_pthread_intercepts.c
helgrind/hg_intercepts.c

index 8f2242319dcbf7a97b07a358b151c545fcaadbf0..1bcff1ec77cfee7cb04f7e565ff351bb9e926cd4 100644 (file)
@@ -846,6 +846,26 @@ AC_MSG_RESULT([no])
 ])
 
 
+# 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])
index ac648e99887f44a8557e8df1fc990cf01874b452..1cbaa99612353461088ae8519d608d301e62bbf7 100644 (file)
@@ -999,6 +999,10 @@ static __always_inline int sem_post_intercept(sem_t *sem)
 
 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 @@ int pthread_rwlock_unlock_intercept(pthread_rwlock_t* rwlock)
 PTH_FUNCS(int,
           pthreadZurwlockZuunlock, pthread_rwlock_unlock_intercept,
           (pthread_rwlock_t* rwlock), (rwlock));
+
+#endif /* defined(HAVE_PTHREAD_RWLOCK_T) */
index 798ee6cd81c86043d5e66568548a8a8975c2d306..20b368c622d7aeb01ca2fc5428115b89de6be810 100644 (file)
@@ -1274,6 +1274,10 @@ PTH_FUNC(int, pthreadZuspinZutrylock, // pthread_spin_trylock
 /*--- 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 @@ static int pthread_rwlock_unlock_WRK(pthread_rwlock_t* rwlock)
 #  error "Unsupported OS"
 #endif
 
+#endif /* defined(HAVE_PTHREAD_RWLOCK_T) */
+
 
 /*----------------------------------------------------------------*/
 /*--- POSIX semaphores                                         ---*/