From: Paul Floyd Date: Mon, 11 Apr 2022 20:32:45 +0000 (+0200) Subject: Fix building on macOS X-Git-Tag: VALGRIND_3_20_0~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68ac5ca0ea91e0591c94083486ffd77ef112b447;p=thirdparty%2Fvalgrind.git Fix building on macOS Adds a feature check for clockid_t Also fix a typo in a macro affecting pthread_mutex_clocklock on Linux. --- diff --git a/configure.ac b/configure.ac index e02dd0bcba..7fd7ff18c6 100755 --- a/configure.ac +++ b/configure.ac @@ -1527,6 +1527,21 @@ AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1, AC_MSG_RESULT([no]) ]) +# Check for CLOCKID_T + +AC_MSG_CHECKING([for clockid_t]) + +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + clockid_t c; +]])], [ +AC_MSG_RESULT([yes]) +AC_DEFINE([HAVE_CLOCKID_T], 1, + [Define to 1 if you have the `clockid_t' type.]) +], [ +AC_MSG_RESULT([no]) +]) # Check for PTHREAD_MUTEX_ADAPTIVE_NP diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index c18e888678..ecbf0f731b 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -1016,6 +1016,7 @@ PTH_FUNCS(int, (mutex, timeout)); #endif /* VGO_solaris */ +#if defined(HAVE_CLOCKID_T) static __always_inline int pthread_mutex_clocklock_intercept(pthread_mutex_t *mutex, clockid_t clockid, @@ -1035,6 +1036,7 @@ int pthread_mutex_clocklock_intercept(pthread_mutex_t *mutex, PTH_FUNCS(int, pthreadZumutexZuclocklock, pthread_mutex_clocklock_intercept, (pthread_mutex_t *mutex, clockid_t clockid, const struct timespec *abs_timeout), (mutex, clockid, abs_timeout)); +#endif static __always_inline int pthread_mutex_unlock_intercept(pthread_mutex_t *mutex) @@ -1196,6 +1198,7 @@ PTH_FUNCS(int, condZureltimedwait, pthread_cond_timedwait_intercept, #endif /* VGO_solaris */ +#if defined(HAVE_CLOCKID_T) static __always_inline int pthread_cond_clockwait_intercept(pthread_cond_t *cond, pthread_mutex_t *mutex, @@ -1217,6 +1220,7 @@ PTH_FUNCS(int, pthreadZucondZuclockwait, pthread_cond_clockwait_intercept, (pthread_cond_t *cond, pthread_mutex_t *mutex, clockid_t clockid, const struct timespec* abstime), (cond, mutex, clockid, abstime)); +#endif // NOTE: be careful to intercept only pthread_cond_signal() and not Darwin's @@ -1814,6 +1818,8 @@ PTH_FUNCS(int, pthreadZurwlockZureltimedrdlockZunp, (rwlock, timeout)); #endif /* VGO_solaris */ + +#if defined(HAVE_CLOCKID_T) static __always_inline int pthread_rwlock_clockrdlock_intercept(pthread_rwlock_t* rwlock, clockid_t clockid, @@ -1834,6 +1840,7 @@ PTH_FUNCS(int, pthreadZurwlockZuclockrdlock, pthread_rwlock_clockrdlock_intercept, (pthread_rwlock_t* rwlock, clockid_t clockid, const struct timespec *timeout), (rwlock, clockid, timeout)); +#endif static __always_inline int pthread_rwlock_timedwrlock_intercept(pthread_rwlock_t* rwlock, @@ -1861,6 +1868,8 @@ PTH_FUNCS(int, pthreadZurwlockZureltimedwrlockZunp, (rwlock, timeout)); #endif /* VGO_solaris */ + +#if defined(HAVE_CLOCKID_T) static __always_inline int pthread_rwlock_clockwrlock_intercept(pthread_rwlock_t* rwlock, clockid_t clockid, @@ -1881,6 +1890,7 @@ PTH_FUNCS(int, pthreadZurwlockZuclockwrlock, pthread_rwlock_clockwrlock_intercept, (pthread_rwlock_t* rwlock, clockid_t clockid, const struct timespec *timeout), (rwlock, clockid, timeout)); +#endif static __always_inline diff --git a/helgrind/hg_intercepts.c b/helgrind/hg_intercepts.c index 7260c89aa0..0d29cb3bfa 100644 --- a/helgrind/hg_intercepts.c +++ b/helgrind/hg_intercepts.c @@ -1110,7 +1110,7 @@ PTH_FUNC(int, pthreadZumutexZureltimedlock, // pthread_mutex_reltimedlock } #endif -#if defined(VGP_linux) +#if defined(VGO_linux) //----------------------------------------------------------- // glibc: pthread_mutex_clocklock //