Patchwork [2/3] Replace remaining gcc format attribute by macro GCC_FMT_ATTR (format checking)

login
register
mail settings
Submitter Stefan Weil
Date Sept. 23, 2010, 7:28 p.m.
Message ID <1285270085-11276-2-git-send-email-weil@mail.berlios.de>
Download mbox | patch
Permalink /patch/65574/
State New
Headers show

Comments

Stefan Weil - Sept. 23, 2010, 7:28 p.m.
Replace the remaining format attribute printf by macro
GCC_FMT_ATTR which uses gnu_printf (if supported).

This needs additional code changes:

* Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.

* Remove standard includes when qemu-common.h was added.
  qemu-common.h already provides these includes.

* Remove local definitions which now come from stdio.h.
  These definitions were needed before tcg was introduced.
  They raise conflicts when qemu-common.h is included.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 cpu-all.h                     |    2 +-
 cpu-exec.c                    |    2 ++
 dyngen-exec.h                 |    9 ---------
 target-alpha/op_helper.c      |    1 +
 target-arm/op_helper.c        |    2 ++
 target-cris/op_helper.c       |    1 +
 target-i386/op_helper.c       |    1 +
 target-m68k/op_helper.c       |    2 ++
 target-microblaze/op_helper.c |    2 +-
 target-mips/op_helper.c       |    3 ++-
 target-ppc/op_helper.c        |    3 ++-
 target-sh4/op_helper.c        |    4 ++--
 target-sparc/op_helper.c      |    1 +
 13 files changed, 18 insertions(+), 15 deletions(-)
Blue Swirl - Sept. 23, 2010, 8:33 p.m.
On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Replace the remaining format attribute printf by macro
> GCC_FMT_ATTR which uses gnu_printf (if supported).
>
> This needs additional code changes:
>
> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>
> * Remove standard includes when qemu-common.h was added.
>  qemu-common.h already provides these includes.
>
> * Remove local definitions which now come from stdio.h.
>  These definitions were needed before tcg was introduced.
>  They raise conflicts when qemu-common.h is included.

IIRC the problem was that some system headers were incompatible with
global asm variables. There is still one, AREG0.

But I'd rather not keep the hideous local definitions forever. Maybe
those systems which are broken by the patch are not interesting
anymore?
Stefan Weil - Sept. 23, 2010, 8:44 p.m.
Am 23.09.2010 22:33, schrieb Blue Swirl:
> On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil <weil@mail.berlios.de> wrote:
>> Replace the remaining format attribute printf by macro
>> GCC_FMT_ATTR which uses gnu_printf (if supported).
>>
>> This needs additional code changes:
>>
>> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>>
>> * Remove standard includes when qemu-common.h was added.
>>  qemu-common.h already provides these includes.
>>
>> * Remove local definitions which now come from stdio.h.
>>  These definitions were needed before tcg was introduced.
>>  They raise conflicts when qemu-common.h is included.
>
> IIRC the problem was that some system headers were incompatible with
> global asm variables. There is still one, AREG0.
>
> But I'd rather not keep the hideous local definitions forever. Maybe
> those systems which are broken by the patch are not interesting
> anymore?

Are there such systems? Or did the problems with earlier
versions arise from the fact that a lot of global asm variables
were reserved by qemu? How could a correctly defined AREG0
interfere with system headers?

For linux and win32, I did not notice problems caused by these changes.
Blue Swirl - Sept. 25, 2010, 7:46 a.m.
On Thu, Sep 23, 2010 at 8:44 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 23.09.2010 22:33, schrieb Blue Swirl:
>>
>> On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil <weil@mail.berlios.de> wrote:
>>>
>>> Replace the remaining format attribute printf by macro
>>> GCC_FMT_ATTR which uses gnu_printf (if supported).
>>>
>>> This needs additional code changes:
>>>
>>> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>>>
>>> * Remove standard includes when qemu-common.h was added.
>>>  qemu-common.h already provides these includes.
>>>
>>> * Remove local definitions which now come from stdio.h.
>>>  These definitions were needed before tcg was introduced.
>>>  They raise conflicts when qemu-common.h is included.
>>
>> IIRC the problem was that some system headers were incompatible with
>> global asm variables. There is still one, AREG0.
>>
>> But I'd rather not keep the hideous local definitions forever. Maybe
>> those systems which are broken by the patch are not interesting
>> anymore?
>
> Are there such systems? Or did the problems with earlier
> versions arise from the fact that a lot of global asm variables
> were reserved by qemu? How could a correctly defined AREG0
> interfere with system headers?

One explanation is that the code in target-*/op_helper.c may assume
that env/AREG0 is always available but since library functions may
clobber that, we want to hide them.

> For linux and win32, I did not notice problems caused by these changes.

It looks like that code has origins in one of the very first patches,
r16 or ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved from
exec-i386.h to dyngen-exec.h by r236 or
79638566e5b87058e92f537b989df0dbc23f8b41. R997 or
1e6cae953d6a37216359b79e05d23e1bf4dc6bbe added a warning about system
headers. The commits around that add OS X support, maybe the problem
was there?
Stefan Weil - Oct. 4, 2010, 7:29 p.m.
Am 25.09.2010 09:46, schrieb Blue Swirl:
> On Thu, Sep 23, 2010 at 8:44 PM, Stefan Weil <weil@mail.berlios.de> wrote:
>> Am 23.09.2010 22:33, schrieb Blue Swirl:
>>>
>>> On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil <weil@mail.berlios.de> 
>>> wrote:
>>>>
>>>> Replace the remaining format attribute printf by macro
>>>> GCC_FMT_ATTR which uses gnu_printf (if supported).
>>>>
>>>> This needs additional code changes:
>>>>
>>>> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>>>>
>>>> * Remove standard includes when qemu-common.h was added.
>>>>  qemu-common.h already provides these includes.
>>>>
>>>> * Remove local definitions which now come from stdio.h.
>>>>  These definitions were needed before tcg was introduced.
>>>>  They raise conflicts when qemu-common.h is included.
>>>
>>> IIRC the problem was that some system headers were incompatible with
>>> global asm variables. There is still one, AREG0.
>>>
>>> But I'd rather not keep the hideous local definitions forever. Maybe
>>> those systems which are broken by the patch are not interesting
>>> anymore?
>>
>> Are there such systems? Or did the problems with earlier
>> versions arise from the fact that a lot of global asm variables
>> were reserved by qemu? How could a correctly defined AREG0
>> interfere with system headers?
>
> One explanation is that the code in target-*/op_helper.c may assume
> that env/AREG0 is always available but since library functions may
> clobber that, we want to hide them.
>
>> For linux and win32, I did not notice problems caused by these changes.
>
> It looks like that code has origins in one of the very first patches,
> r16 or ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved from
> exec-i386.h to dyngen-exec.h by r236 or
> 79638566e5b87058e92f537b989df0dbc23f8b41. R997 or
> 1e6cae953d6a37216359b79e05d23e1bf4dc6bbe added a warning about system
> headers. The commits around that add OS X support, maybe the problem
> was there?


Current qemu code includes several locations where standard headers
like stdio.h are forbidden. See qemu-common.h (__DYNGEN_EXEC_H__),
dyngen-exec.h, cris-dis.h and perhaps more examples of this
restriction.

Who knows the reason for this restriction? Was it use of global registers
with dyngen? Was it needed only for certain hosts (maybe OSX) or old
versions of gcc?

Most important: Is this restriction still needed?

It would simplify things like common declarations and also allow
cleaner code (without private declarations for FILE etc.) if we could
remove this restriction.

In my personal test environment (gcc-4.x, linux on different hosts, win32)
the restriction was not needed.

Regards,
Stefan
Andreas Färber - Oct. 9, 2010, 10:46 p.m.
Am 04.10.2010 um 21:29 schrieb Stefan Weil:

> Am 25.09.2010 09:46, schrieb Blue Swirl:
>> On Thu, Sep 23, 2010 at 8:44 PM, Stefan Weil <weil@mail.berlios.de>  
>> wrote:
>>> Am 23.09.2010 22:33, schrieb Blue Swirl:
>>>>
>>>> On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil  
>>>> <weil@mail.berlios.de> wrote:
>>>>>
>>>>> Replace the remaining format attribute printf by macro
>>>>> GCC_FMT_ATTR which uses gnu_printf (if supported).
>>>>>
>>>>> This needs additional code changes:
>>>>>
>>>>> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>>>>>
>>>>> * Remove standard includes when qemu-common.h was added.
>>>>> qemu-common.h already provides these includes.
>>>>>
>>>>> * Remove local definitions which now come from stdio.h.
>>>>> These definitions were needed before tcg was introduced.
>>>>> They raise conflicts when qemu-common.h is included.
>>>>
>>>> IIRC the problem was that some system headers were incompatible  
>>>> with
>>>> global asm variables. There is still one, AREG0.
>>>>
>>>> But I'd rather not keep the hideous local definitions forever.  
>>>> Maybe
>>>> those systems which are broken by the patch are not interesting
>>>> anymore?
>>>
>>> Are there such systems? Or did the problems with earlier
>>> versions arise from the fact that a lot of global asm variables
>>> were reserved by qemu? How could a correctly defined AREG0
>>> interfere with system headers?
>>
>> One explanation is that the code in target-*/op_helper.c may assume
>> that env/AREG0 is always available but since library functions may
>> clobber that, we want to hide them.
>>
>>> For linux and win32, I did not notice problems caused by these  
>>> changes.
>>
>> It looks like that code has origins in one of the very first patches,
>> r16 or ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved from
>> exec-i386.h to dyngen-exec.h by r236 or
>> 79638566e5b87058e92f537b989df0dbc23f8b41. R997 or
>> 1e6cae953d6a37216359b79e05d23e1bf4dc6bbe added a warning about system
>> headers. The commits around that add OS X support, maybe the problem
>> was there?
>
>
> Current qemu code includes several locations where standard headers
> like stdio.h are forbidden. See qemu-common.h (__DYNGEN_EXEC_H__),
> dyngen-exec.h, cris-dis.h and perhaps more examples of this
> restriction.
>
> Who knows the reason for this restriction? Was it use of global  
> registers
> with dyngen? Was it needed only for certain hosts (maybe OSX) or old
> versions of gcc?
>
> Most important: Is this restriction still needed?
>
> It would simplify things like common declarations and also allow
> cleaner code (without private declarations for FILE etc.) if we could
> remove this restriction.
>
> In my personal test environment (gcc-4.x, linux on different hosts,  
> win32)
> the restriction was not needed.

Tested-by: Andreas Färber <andreas.faerber@web.de>

Patch 2/3 [1] compiles without warnings on Mac OS X v10.5 ppc64, using  
Apple's GCC 4.0.1.
As guests, AIX/ppc64, Haiku/ppc, Fedora/x64 and Haiku/i386 booted as  
before.

Andreas

[1] http://patchwork.ozlabs.org/patch/65574/
Stefan Weil - Oct. 11, 2010, 4:22 p.m.
Am 10.10.2010 00:46, schrieb Andreas Färber:
> Am 04.10.2010 um 21:29 schrieb Stefan Weil:
>
>> Am 25.09.2010 09:46, schrieb Blue Swirl:
>>> On Thu, Sep 23, 2010 at 8:44 PM, Stefan Weil <weil@mail.berlios.de> 
>>> wrote:
>>>> Am 23.09.2010 22:33, schrieb Blue Swirl:
>>>>>
>>>>> On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil 
>>>>> <weil@mail.berlios.de> wrote:
>>>>>>
>>>>>> Replace the remaining format attribute printf by macro
>>>>>> GCC_FMT_ATTR which uses gnu_printf (if supported).
>>>>>>
>>>>>> This needs additional code changes:
>>>>>>
>>>>>> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>>>>>>
>>>>>> * Remove standard includes when qemu-common.h was added.
>>>>>> qemu-common.h already provides these includes.
>>>>>>
>>>>>> * Remove local definitions which now come from stdio.h.
>>>>>> These definitions were needed before tcg was introduced.
>>>>>> They raise conflicts when qemu-common.h is included.
>>>>>
>>>>> IIRC the problem was that some system headers were incompatible with
>>>>> global asm variables. There is still one, AREG0.
>>>>>
>>>>> But I'd rather not keep the hideous local definitions forever. Maybe
>>>>> those systems which are broken by the patch are not interesting
>>>>> anymore?
>>>>
>>>> Are there such systems? Or did the problems with earlier
>>>> versions arise from the fact that a lot of global asm variables
>>>> were reserved by qemu? How could a correctly defined AREG0
>>>> interfere with system headers?
>>>
>>> One explanation is that the code in target-*/op_helper.c may assume
>>> that env/AREG0 is always available but since library functions may
>>> clobber that, we want to hide them.
>>>
>>>> For linux and win32, I did not notice problems caused by these 
>>>> changes.
>>>
>>> It looks like that code has origins in one of the very first patches,
>>> r16 or ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved from
>>> exec-i386.h to dyngen-exec.h by r236 or
>>> 79638566e5b87058e92f537b989df0dbc23f8b41. R997 or
>>> 1e6cae953d6a37216359b79e05d23e1bf4dc6bbe added a warning about system
>>> headers. The commits around that add OS X support, maybe the problem
>>> was there?
>>
>>
>> Current qemu code includes several locations where standard headers
>> like stdio.h are forbidden. See qemu-common.h (__DYNGEN_EXEC_H__),
>> dyngen-exec.h, cris-dis.h and perhaps more examples of this
>> restriction.
>>
>> Who knows the reason for this restriction? Was it use of global 
>> registers
>> with dyngen? Was it needed only for certain hosts (maybe OSX) or old
>> versions of gcc?
>>
>> Most important: Is this restriction still needed?
>>
>> It would simplify things like common declarations and also allow
>> cleaner code (without private declarations for FILE etc.) if we could
>> remove this restriction.
>>
>> In my personal test environment (gcc-4.x, linux on different hosts, 
>> win32)
>> the restriction was not needed.
>
> Tested-by: Andreas Färber <andreas.faerber@web.de>
>
> Patch 2/3 [1] compiles without warnings on Mac OS X v10.5 ppc64, using 
> Apple's GCC 4.0.1.
> As guests, AIX/ppc64, Haiku/ppc, Fedora/x64 and Haiku/i386 booted as 
> before.
>
> Andreas
>
> [1] http://patchwork.ozlabs.org/patch/65574/

Andreas, thank you for testing.

Blue Swirl, for the next steps towards getting full format checks
patch 2/3 or something equivalent is needed because GCC_FMT_ATTR
(which is defined in qemu-common.h) should be available
everywhere.

With Andreas test results, we now know that Linux, OSX and Win32
don't need the restriction regarding system include files like stdio.h.

Do you think more tests are needed, should we wait for more feedback
or can the patch be applied?
Blue Swirl - Oct. 12, 2010, 6:23 p.m.
On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Replace the remaining format attribute printf by macro
> GCC_FMT_ATTR which uses gnu_printf (if supported).
>
> This needs additional code changes:
>
> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>
> * Remove standard includes when qemu-common.h was added.
>  qemu-common.h already provides these includes.
>
> * Remove local definitions which now come from stdio.h.
>  These definitions were needed before tcg was introduced.
>  They raise conflicts when qemu-common.h is included.
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  cpu-all.h                     |    2 +-
>  cpu-exec.c                    |    2 ++
>  dyngen-exec.h                 |    9 ---------
>  target-alpha/op_helper.c      |    1 +
>  target-arm/op_helper.c        |    2 ++
>  target-cris/op_helper.c       |    1 +
>  target-i386/op_helper.c       |    1 +
>  target-m68k/op_helper.c       |    2 ++
>  target-microblaze/op_helper.c |    2 +-
>  target-mips/op_helper.c       |    3 ++-
>  target-ppc/op_helper.c        |    3 ++-
>  target-sh4/op_helper.c        |    4 ++--
>  target-sparc/op_helper.c      |    1 +
>  13 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/cpu-all.h b/cpu-all.h
> index 67a3266..11edddc 100644
> --- a/cpu-all.h
> +++ b/cpu-all.h
> @@ -773,7 +773,7 @@ void cpu_dump_statistics (CPUState *env, FILE *f,
>                           int flags);
>
>  void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...)
> -    __attribute__ ((__format__ (__printf__, 2, 3)));
> +    GCC_FMT_ATTR(2, 3);
>  extern CPUState *first_cpu;
>  extern CPUState *cpu_single_env;
>
> diff --git a/cpu-exec.c b/cpu-exec.c
> index dbdfdcc..1cb36e0 100644
> --- a/cpu-exec.c
> +++ b/cpu-exec.c
> @@ -16,6 +16,8 @@
>  * You should have received a copy of the GNU Lesser General Public
>  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
>  */
> +
> +#include "qemu-common.h"

This and other similar additions are not needed for GCC_FMT_ATTR,
qemu-common is already #included by exec-all.h (included by exec.h).
Only the macro definition needs to move up near QEMU_NORETURN etc so
that it's available to exec code.

>  #include "config.h"
>  #include "exec.h"
>  #include "disas.h"
> diff --git a/dyngen-exec.h b/dyngen-exec.h
> index 5bfef3f..97e2556 100644
> --- a/dyngen-exec.h
> +++ b/dyngen-exec.h
> @@ -40,15 +40,6 @@
>  /* XXX: This may be wrong for 64-bit ILP32 hosts.  */
>  typedef void * host_reg_t;
>
> -#ifdef CONFIG_BSD
> -typedef struct __sFILE FILE;
> -#else
> -typedef struct FILE FILE;
> -#endif
> -extern int fprintf(FILE *, const char *, ...);
> -extern int fputs(const char *, FILE *);
> -extern int printf(const char *, ...);
> -

This should be in a separate patch which removes __DYNGEN_EXEC_H.
Blue Swirl - Oct. 12, 2010, 6:33 p.m.
On Mon, Oct 11, 2010 at 4:22 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 10.10.2010 00:46, schrieb Andreas Färber:
>>
>> Am 04.10.2010 um 21:29 schrieb Stefan Weil:
>>
>>> Am 25.09.2010 09:46, schrieb Blue Swirl:
>>>>
>>>> On Thu, Sep 23, 2010 at 8:44 PM, Stefan Weil <weil@mail.berlios.de>
>>>> wrote:
>>>>>
>>>>> Am 23.09.2010 22:33, schrieb Blue Swirl:
>>>>>>
>>>>>> On Thu, Sep 23, 2010 at 7:28 PM, Stefan Weil <weil@mail.berlios.de>
>>>>>> wrote:
>>>>>>>
>>>>>>> Replace the remaining format attribute printf by macro
>>>>>>> GCC_FMT_ATTR which uses gnu_printf (if supported).
>>>>>>>
>>>>>>> This needs additional code changes:
>>>>>>>
>>>>>>> * Add qemu-common.h (which defined GCC_FMT_ATTR) were needed.
>>>>>>>
>>>>>>> * Remove standard includes when qemu-common.h was added.
>>>>>>> qemu-common.h already provides these includes.
>>>>>>>
>>>>>>> * Remove local definitions which now come from stdio.h.
>>>>>>> These definitions were needed before tcg was introduced.
>>>>>>> They raise conflicts when qemu-common.h is included.
>>>>>>
>>>>>> IIRC the problem was that some system headers were incompatible with
>>>>>> global asm variables. There is still one, AREG0.
>>>>>>
>>>>>> But I'd rather not keep the hideous local definitions forever. Maybe
>>>>>> those systems which are broken by the patch are not interesting
>>>>>> anymore?
>>>>>
>>>>> Are there such systems? Or did the problems with earlier
>>>>> versions arise from the fact that a lot of global asm variables
>>>>> were reserved by qemu? How could a correctly defined AREG0
>>>>> interfere with system headers?
>>>>
>>>> One explanation is that the code in target-*/op_helper.c may assume
>>>> that env/AREG0 is always available but since library functions may
>>>> clobber that, we want to hide them.
>>>>
>>>>> For linux and win32, I did not notice problems caused by these changes.
>>>>
>>>> It looks like that code has origins in one of the very first patches,
>>>> r16 or ba1c6e37fc5efc0f3d1e50d0760f9f4a1061187b. It was moved from
>>>> exec-i386.h to dyngen-exec.h by r236 or
>>>> 79638566e5b87058e92f537b989df0dbc23f8b41. R997 or
>>>> 1e6cae953d6a37216359b79e05d23e1bf4dc6bbe added a warning about system
>>>> headers. The commits around that add OS X support, maybe the problem
>>>> was there?
>>>
>>>
>>> Current qemu code includes several locations where standard headers
>>> like stdio.h are forbidden. See qemu-common.h (__DYNGEN_EXEC_H__),
>>> dyngen-exec.h, cris-dis.h and perhaps more examples of this
>>> restriction.
>>>
>>> Who knows the reason for this restriction? Was it use of global registers
>>> with dyngen? Was it needed only for certain hosts (maybe OSX) or old
>>> versions of gcc?
>>>
>>> Most important: Is this restriction still needed?
>>>
>>> It would simplify things like common declarations and also allow
>>> cleaner code (without private declarations for FILE etc.) if we could
>>> remove this restriction.
>>>
>>> In my personal test environment (gcc-4.x, linux on different hosts,
>>> win32)
>>> the restriction was not needed.
>>
>> Tested-by: Andreas Färber <andreas.faerber@web.de>
>>
>> Patch 2/3 [1] compiles without warnings on Mac OS X v10.5 ppc64, using
>> Apple's GCC 4.0.1.
>> As guests, AIX/ppc64, Haiku/ppc, Fedora/x64 and Haiku/i386 booted as
>> before.
>>
>> Andreas
>>
>> [1] http://patchwork.ozlabs.org/patch/65574/
>
> Andreas, thank you for testing.
>
> Blue Swirl, for the next steps towards getting full format checks
> patch 2/3 or something equivalent is needed because GCC_FMT_ATTR
> (which is defined in qemu-common.h) should be available
> everywhere.
>
> With Andreas test results, we now know that Linux, OSX and Win32
> don't need the restriction regarding system include files like stdio.h.
>
> Do you think more tests are needed, should we wait for more feedback
> or can the patch be applied?

What about the library compatibility situation, do we know anything about that?

On the other hand, we could apply the patch and wait for bug reports.

Patch

diff --git a/cpu-all.h b/cpu-all.h
index 67a3266..11edddc 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -773,7 +773,7 @@  void cpu_dump_statistics (CPUState *env, FILE *f,
                           int flags);
 
 void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...)
-    __attribute__ ((__format__ (__printf__, 2, 3)));
+    GCC_FMT_ATTR(2, 3);
 extern CPUState *first_cpu;
 extern CPUState *cpu_single_env;
 
diff --git a/cpu-exec.c b/cpu-exec.c
index dbdfdcc..1cb36e0 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -16,6 +16,8 @@ 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
+
+#include "qemu-common.h"
 #include "config.h"
 #include "exec.h"
 #include "disas.h"
diff --git a/dyngen-exec.h b/dyngen-exec.h
index 5bfef3f..97e2556 100644
--- a/dyngen-exec.h
+++ b/dyngen-exec.h
@@ -40,15 +40,6 @@ 
 /* XXX: This may be wrong for 64-bit ILP32 hosts.  */
 typedef void * host_reg_t;
 
-#ifdef CONFIG_BSD
-typedef struct __sFILE FILE;
-#else
-typedef struct FILE FILE;
-#endif
-extern int fprintf(FILE *, const char *, ...);
-extern int fputs(const char *, FILE *);
-extern int printf(const char *, ...);
-
 #if defined(__i386__)
 #define AREG0 "ebp"
 #elif defined(__x86_64__)
diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c
index ff5ae26..39a6a85 100644
--- a/target-alpha/op_helper.c
+++ b/target-alpha/op_helper.c
@@ -17,6 +17,7 @@ 
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu-common.h"
 #include "exec.h"
 #include "host-utils.h"
 #include "softfloat.h"
diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index 9b1a014..71cd8ff 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -16,6 +16,8 @@ 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
+
+#include "qemu-common.h"
 #include "exec.h"
 #include "helpers.h"
 
diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c
index a60da94..9e21799 100644
--- a/target-cris/op_helper.c
+++ b/target-cris/op_helper.c
@@ -18,6 +18,7 @@ 
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu-common.h"
 #include "exec.h"
 #include "mmu.h"
 #include "helper.h"
diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c
index ec6b3e9..b1f3bf9 100644
--- a/target-i386/op_helper.c
+++ b/target-i386/op_helper.c
@@ -17,6 +17,7 @@ 
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "qemu-common.h"
 #include "exec.h"
 #include "exec-all.h"
 #include "host-utils.h"
diff --git a/target-m68k/op_helper.c b/target-m68k/op_helper.c
index 0711107..5c5fb5b 100644
--- a/target-m68k/op_helper.c
+++ b/target-m68k/op_helper.c
@@ -16,6 +16,8 @@ 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
+
+#include "qemu-common.h"
 #include "exec.h"
 #include "helpers.h"
 
diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
index 3d2b313..dd6e262 100644
--- a/target-microblaze/op_helper.c
+++ b/target-microblaze/op_helper.c
@@ -17,7 +17,7 @@ 
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <assert.h>
+#include "qemu-common.h"
 #include "exec.h"
 #include "helper.h"
 #include "host-utils.h"
diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c
index 41abd57..2429ff7 100644
--- a/target-mips/op_helper.c
+++ b/target-mips/op_helper.c
@@ -16,7 +16,8 @@ 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
-#include <stdlib.h>
+
+#include "qemu-common.h"
 #include "exec.h"
 
 #include "host-utils.h"
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 3e6db85..4692646 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -16,7 +16,8 @@ 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
-#include <string.h>
+
+#include "qemu-common.h"
 #include "exec.h"
 #include "host-utils.h"
 #include "helper.h"
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index 2e5f555..fdc183c 100644
--- a/target-sh4/op_helper.c
+++ b/target-sh4/op_helper.c
@@ -16,8 +16,8 @@ 
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  */
-#include <assert.h>
-#include <stdlib.h>
+
+#include "qemu-common.h"
 #include "exec.h"
 #include "helper.h"
 
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index be3c1e0..547793f 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -1,3 +1,4 @@ 
+#include "qemu-common.h"
 #include "exec.h"
 #include "host-utils.h"
 #include "helper.h"