Patchwork [RFC,qom-cpu,2/4] qemu-common.h: Move fprintf_function to qemu-types.h

login
register
mail settings
Submitter Andreas Färber
Date Dec. 18, 2012, 7:53 a.m.
Message ID <1355817223-13076-3-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/207040/
State New
Headers show

Comments

Andreas Färber - Dec. 18, 2012, 7:53 a.m.
This avoids a dependency on qemu-common.h from qemu/cpu.h.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/qemu/cpu.h |    2 +-
 qemu-common.h      |    5 -----
 qemu-types.h       |    6 ++++++
 3 Dateien geändert, 7 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
Eduardo Habkost - Dec. 18, 2012, 5:25 p.m.
On Tue, Dec 18, 2012 at 08:53:41AM +0100, Andreas Färber wrote:
> This avoids a dependency on qemu-common.h from qemu/cpu.h.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

When I introduced qemu-types.h, I just planned to use it for the trivial
"typedef struct Foobar Foobar" typedefs that can't be anywhere else
because it would cause circular header dependencies.

I am not against this patch, but I wonder if osdep.h (or even a new
qemu-stdio.h header) isn't more appropriate for this (and for other
I/O-related definitions currently on qemu-common.h).

> ---
>  include/qemu/cpu.h |    2 +-
>  qemu-common.h      |    5 -----
>  qemu-types.h       |    6 ++++++
>  3 Dateien geändert, 7 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)
> 
> diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
> index 5fbb3f9..d737fcd 100644
> --- a/include/qemu/cpu.h
> +++ b/include/qemu/cpu.h
> @@ -21,7 +21,7 @@
>  #define QEMU_CPU_H
>  
>  #include "qemu/object.h"
> -#include "qemu-common.h"
> +#include "qemu-types.h"
>  #include "qemu-thread.h"
>  
>  /**
> diff --git a/qemu-common.h b/qemu-common.h
> index e674786..98ab78d 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -12,7 +12,6 @@
>  #ifndef QEMU_COMMON_H
>  #define QEMU_COMMON_H
>  
> -#include "compiler.h"
>  #include "config-host.h"
>  #include "qemu-types.h"
>  
> @@ -24,7 +23,6 @@
>  
>  /* we put basic includes here to avoid repeating them in device drivers */
>  #include <stdlib.h>
> -#include <stdio.h>
>  #include <stdarg.h>
>  #include <stdbool.h>
>  #include <string.h>
> @@ -95,9 +93,6 @@ struct iovec {
>  #include <sys/uio.h>
>  #endif
>  
> -typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
> -    GCC_FMT_ATTR(2, 3);
> -
>  #ifdef _WIN32
>  #define fsync _commit
>  #if !defined(lseek)
> diff --git a/qemu-types.h b/qemu-types.h
> index fd532a2..f7a7194 100644
> --- a/qemu-types.h
> +++ b/qemu-types.h
> @@ -1,6 +1,12 @@
>  #ifndef QEMU_TYPEDEFS_H
>  #define QEMU_TYPEDEFS_H
>  
> +#include "compiler.h"
> +#include <stdio.h>
> +
> +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
> +    GCC_FMT_ATTR(2, 3);
> +
>  /* A load of opaque types so that device init declarations don't have to
>     pull in all the real definitions.  */
>  typedef struct QEMUTimer QEMUTimer;
> -- 
> 1.7.10.4
> 
>

Patch

diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h
index 5fbb3f9..d737fcd 100644
--- a/include/qemu/cpu.h
+++ b/include/qemu/cpu.h
@@ -21,7 +21,7 @@ 
 #define QEMU_CPU_H
 
 #include "qemu/object.h"
-#include "qemu-common.h"
+#include "qemu-types.h"
 #include "qemu-thread.h"
 
 /**
diff --git a/qemu-common.h b/qemu-common.h
index e674786..98ab78d 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -12,7 +12,6 @@ 
 #ifndef QEMU_COMMON_H
 #define QEMU_COMMON_H
 
-#include "compiler.h"
 #include "config-host.h"
 #include "qemu-types.h"
 
@@ -24,7 +23,6 @@ 
 
 /* we put basic includes here to avoid repeating them in device drivers */
 #include <stdlib.h>
-#include <stdio.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <string.h>
@@ -95,9 +93,6 @@  struct iovec {
 #include <sys/uio.h>
 #endif
 
-typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
-    GCC_FMT_ATTR(2, 3);
-
 #ifdef _WIN32
 #define fsync _commit
 #if !defined(lseek)
diff --git a/qemu-types.h b/qemu-types.h
index fd532a2..f7a7194 100644
--- a/qemu-types.h
+++ b/qemu-types.h
@@ -1,6 +1,12 @@ 
 #ifndef QEMU_TYPEDEFS_H
 #define QEMU_TYPEDEFS_H
 
+#include "compiler.h"
+#include <stdio.h>
+
+typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
+    GCC_FMT_ATTR(2, 3);
+
 /* A load of opaque types so that device init declarations don't have to
    pull in all the real definitions.  */
 typedef struct QEMUTimer QEMUTimer;