]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make drd/drd_pthread_intercepts.c compile again on Linux systems without usable ...
authorBart Van Assche <bvanassche@acm.org>
Sat, 17 Sep 2011 06:24:49 +0000 (06:24 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 17 Sep 2011 06:24:49 +0000 (06:24 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12035

configure.in
drd/drd_pthread_intercepts.c

index eaaf21beac91b491c39ea3bc87579c38689be7ed..334e3f469fe6a4befad46b7d57f3bb3031e2f1d3 100644 (file)
@@ -1629,6 +1629,22 @@ AC_CHECK_HEADERS([       \
         sys/types.h      \
         ])
 
+# Verify whether the <linux/futex.h> header is usable.
+AC_MSG_CHECKING([if <linux/futex.h> is usable])
+
+AC_TRY_COMPILE([
+#include <linux/futex.h>
+], [
+  return FUTEX_WAIT;
+],
+[
+AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
+          [Define to 1 if you have a usable <linux/futex.h> header file.])
+AC_MSG_RESULT([yes])
+], [
+AC_MSG_RESULT([no])
+])
+
 #----------------------------------------------------------------------------
 # Checks for typedefs, structures, and compiler characteristics.
 #----------------------------------------------------------------------------
index 5b13bb30b673968ac96d174db8e7e510162100d0..4dc631c6932f3212cb6d754961a1f4a9a2872bae 100644 (file)
 #include <stdio.h>          /* fprintf() */
 #include <stdlib.h>         /* malloc(), free() */
 #include <unistd.h>         /* confstr() */
-#ifdef __linux__
+#include "config.h"         /* HAVE_PTHREAD_MUTEX_ADAPTIVE_NP etc. */
+#ifdef HAVE_USABLE_LINUX_FUTEX_H
 #include <asm/unistd.h>     /* __NR_futex */
 #include <linux/futex.h>    /* 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