From: Julian Seward Date: Mon, 11 Jul 2011 22:11:58 +0000 (+0000) Subject: The pthread.h on Android has no definition for pthread_rwlock_t, which X-Git-Tag: svn/VALGRIND_3_7_0~362 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eea9337891b991c27c0557b8cdb2cbb7373c8bd1;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/configure.in b/configure.in index 8f2242319d..1bcff1ec77 100644 --- a/configure.in +++ b/configure.in @@ -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_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 ac648e9988..1cbaa99612 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -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) */ diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 798ee6cd81..20b368c622 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -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 ---*/