From: Bart Van Assche Date: Sat, 17 Sep 2011 06:24:49 +0000 (+0000) Subject: Make drd/drd_pthread_intercepts.c compile again on Linux systems without usable ... X-Git-Tag: svn/VALGRIND_3_7_0~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83f6f0137fe7d57ec2a1222d4718a5b3fd859b7c;p=thirdparty%2Fvalgrind.git Make drd/drd_pthread_intercepts.c compile again on Linux systems without usable header git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12035 --- diff --git a/configure.in b/configure.in index eaaf21beac..334e3f469f 100644 --- a/configure.in +++ b/configure.in @@ -1629,6 +1629,22 @@ AC_CHECK_HEADERS([ \ sys/types.h \ ]) +# Verify whether the header is usable. +AC_MSG_CHECKING([if is usable]) + +AC_TRY_COMPILE([ +#include +], [ + return FUTEX_WAIT; +], +[ +AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1, + [Define to 1 if you have a usable header file.]) +AC_MSG_RESULT([yes]) +], [ +AC_MSG_RESULT([no]) +]) + #---------------------------------------------------------------------------- # Checks for typedefs, structures, and compiler characteristics. #---------------------------------------------------------------------------- diff --git a/drd/drd_pthread_intercepts.c b/drd/drd_pthread_intercepts.c index 5b13bb30b6..4dc631c693 100644 --- a/drd/drd_pthread_intercepts.c +++ b/drd/drd_pthread_intercepts.c @@ -56,14 +56,14 @@ #include /* fprintf() */ #include /* malloc(), free() */ #include /* confstr() */ -#ifdef __linux__ +#include "config.h" /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP etc. */ +#ifdef HAVE_USABLE_LINUX_FUTEX_H #include /* __NR_futex */ #include /* FUTEX_WAIT */ #ifndef FUTEX_PRIVATE_FLAG #define FUTEX_PRIVATE_FLAG 0 #endif #endif -#include "config.h" /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP etc. */ #include "drd_basics.h" /* DRD_() */ #include "drd_clientreq.h" #include "pub_tool_redir.h" /* VG_WRAP_FUNCTION_ZZ() */ @@ -194,7 +194,7 @@ static void DRD_(sema_down)(DrdSema* sema) int res = ENOSYS; while (sema->counter == 0) { -#if defined(__linux__) && defined(__NR_futex) +#ifdef HAVE_USABLE_LINUX_FUTEX_H if (syscall(__NR_futex, (UWord)&sema->counter, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0) == 0) res = 0; @@ -216,7 +216,7 @@ static void DRD_(sema_down)(DrdSema* sema) static void DRD_(sema_up)(DrdSema* sema) { sema->counter++; -#if defined(__linux__) && defined(__NR_futex) +#ifdef HAVE_USABLE_LINUX_FUTEX_H syscall(__NR_futex, (UWord)&sema->counter, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1); #endif