|
From: Bart V. A. <bva...@ac...> - 2011-09-16 15:01:51
|
On Thu, Sep 15, 2011 at 6:35 PM, Florian Krohm <br...@ac...> wrote:
> On 09/15/2011 12:11 PM, Bart Van Assche wrote:
> > As you probably know that's a bug in the futex.h header. Does the
> > patch below help ?
>
> No. It does not. I'll be sending you the output of
>
> cd /usr/include
> find . -exec grep -H u32 {} \;
>
> off list. There is no usable definition of u32 to be found.
Second try ... does the attached patch help (also included below) ?
Bart.
Index: configure.in
===================================================================
--- configure.in (revision 12034)
+++ configure.in (working copy)
@@ -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: drd/drd_pthread_intercepts.c
===================================================================
--- drd/drd_pthread_intercepts.c (revision 12034)
+++ drd/drd_pthread_intercepts.c (working copy)
@@ -56,14 +56,14 @@
#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* sem
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* sem
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
|