Commit 03dfe9f871871921c03c3c65ff69c68759186994

Authored by Riku Voipio
Committed by malc
1 parent 5d928867

linux-user: strace now handles guest stringscorrectly [v2]

On Tue, Jun 16, 2009 at 08:19:23PM -0500, Anthony Liguori wrote:
> malc wrote:
>>
>> On my system the above line causes gcc to emit:
>>
>> In file included from /home/malc/x/rcs/git/qemu/linux-user/strace.c:12:
>> /usr/include/linux/futex.h:48: error: field `__user' has incomplete type
>> /usr/include/linux/futex.h:48: error: syntax error before '*' token
>> /usr/include/linux/futex.h:63: error: field `list' has incomplete type
>> /usr/include/linux/futex.h:83: error: field `__user' has incomplete type
>> /usr/include/linux/futex.h:83: error: syntax error before '*' token
>> make[1]: *** [strace.o] Error 1

> We had the same problem with usb-linux.c.  It's broken system headers,
> the __user stuff is supposed to get removed as part of the headers
> installation.

> It builds fine on my system (Fedora 10).

Howabout something like this:

commit eb8387cb0eda32a18880664eb5f0ca5c8bf05b45
Author: Riku Voipio <riku.voipio@iki.fi>
Date:   Thu Jun 18 22:44:31 2009 +0300
Subject: linux-user: include futex defines directly

Since some common distributions have broken linux/futex.h, stop
including it. Instead add the defines directly.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user/strace.c
... ... @@ -8,7 +8,6 @@
8 8 #include <sys/types.h>
9 9 #include <sys/mount.h>
10 10 #include <sys/mman.h>
11   -#include <linux/futex.h>
12 11 #include <unistd.h>
13 12 #include "qemu.h"
14 13  
... ...
linux-user/syscall.c
... ... @@ -85,7 +85,6 @@
85 85 #include "qemu-common.h"
86 86  
87 87 #if defined(USE_NPTL)
88   -#include <linux/futex.h>
89 88 #define CLONE_NPTL_FLAGS2 (CLONE_SETTLS | \
90 89 CLONE_PARENT_SETTID | CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)
91 90 #else
... ...
linux-user/syscall_defs.h
... ... @@ -2120,3 +2120,20 @@ struct target_mq_attr {
2120 2120 #include "socket.h"
2121 2121  
2122 2122 #include "errno_defs.h"
  2123 +
  2124 +#define FUTEX_WAIT 0
  2125 +#define FUTEX_WAKE 1
  2126 +#define FUTEX_FD 2
  2127 +#define FUTEX_REQUEUE 3
  2128 +#define FUTEX_CMP_REQUEUE 4
  2129 +#define FUTEX_WAKE_OP 5
  2130 +#define FUTEX_LOCK_PI 6
  2131 +#define FUTEX_UNLOCK_PI 7
  2132 +#define FUTEX_TRYLOCK_PI 8
  2133 +#define FUTEX_WAIT_BITSET 9
  2134 +#define FUTEX_WAKE_BITSET 10
  2135 +
  2136 +#define FUTEX_PRIVATE_FLAG 128
  2137 +#define FUTEX_CLOCK_REALTIME 256
  2138 +#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
  2139 +
... ...