|
From: Florian K. <br...@ac...> - 2011-09-15 03:11:03
Attachments:
futex.h
|
Hello Bart, a colleague of mine at the IBM labs (who runs the BEAM checker every once in a while) noticed that he can no longer compile valgrind. The error occurs when compiling drd_pthread_intercepts.c: In file included from drd_pthread_intercepts.c:61: /usr/include/linux/futex.h:96: error: expected ‘)’ before ‘*’ token /usr/include/linux/futex.h:100: error: expected ‘)’ before ‘*’ token I'm including his futex.h. It's quite clear that the error is related to the type u32 not being defined. He has the following setup: $ uname -a Linux whatever.watson.ibm.com 2.6.18-92.1.13.el5PAE #1 SMP Thu Sep 4 4:05:54 EDT 2008 i686 i686 i386 GNU/Linux $ gcc --version gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42) $ /lib/libc*so GNU C Library stable release version 2.5, by Roland McGrath et al. Possible solutions are #ifndef u32 #define unsigned u32 #endif or throwing ouy futex.h and #ifndef FUTEX_WAIT #define FUTEX_WAIT 0 #endif which may be suitable if FUTEX_WAIT is not something internal (and so not likely to change). Yeah, I know, neither is particular pretty. But futex.h is broken to begin with. Florian |
|
From: Bart V. A. <bva...@ac...> - 2011-09-15 16:12:12
|
On Thu, Sep 15, 2011 at 5:10 AM, Florian Krohm <br...@ac...> wrote: > > a colleague of mine at the IBM labs (who runs the BEAM checker every > once in a while) noticed that he can no longer compile valgrind. > The error occurs when compiling drd_pthread_intercepts.c: > > In file included from drd_pthread_intercepts.c:61: > /usr/include/linux/futex.h:96: error: expected ‘)’ before ‘*’ token > /usr/include/linux/futex.h:100: error: expected ‘)’ before ‘*’ token > > I'm including his futex.h. It's quite clear that the error is related to > the type u32 not being defined. As you probably know that's a bug in the futex.h header. Does the patch below help ? Bart. Index: drd/drd_pthread_intercepts.c =================================================================== --- drd/drd_pthread_intercepts.c (revision 12034) +++ drd/drd_pthread_intercepts.c (working copy) @@ -58,6 +58,7 @@ #include <unistd.h> /* confstr() */ #ifdef __linux__ #include <asm/unistd.h> /* __NR_futex */ +#include <linux/types.h> #include <linux/futex.h> /* FUTEX_WAIT */ #ifndef FUTEX_PRIVATE_FLAG #define FUTEX_PRIVATE_FLAG 0 |
|
From: Florian K. <br...@ac...> - 2011-09-15 16:35:40
|
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.
Florian
> Bart.
>
> Index: drd/drd_pthread_intercepts.c
> ===================================================================
> --- drd/drd_pthread_intercepts.c (revision 12034)
> +++ drd/drd_pthread_intercepts.c (working copy)
> @@ -58,6 +58,7 @@
> #include <unistd.h> /* confstr() */
> #ifdef __linux__
> #include <asm/unistd.h> /* __NR_futex */
> +#include <linux/types.h>
> #include <linux/futex.h> /* FUTEX_WAIT */
> #ifndef FUTEX_PRIVATE_FLAG
> #define FUTEX_PRIVATE_FLAG 0
>
|
|
From: Bart V. A. <bva...@ac...> - 2011-09-16 15:01:51
Attachments:
futex-header.patch
|
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
|
|
From: Florian K. <br...@ac...> - 2011-09-17 00:09:01
|
On 09/16/2011 11:01 AM, Bart Van Assche wrote:
>
> Second try ... does the attached patch help (also included below) ?
>
Yes, it does. configure, make and make check run through cleanly.
Thanks for fixing.
Florian
|