Skip to contentSkip to conversation

Remove special handling of system include files (no longer needed)

PATCH Applied Stefan Weil 2 participants 4 messages Oct 13, 2010 – Oct 22, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Remove special handling of system include files (no longer needed)

The formerly used dyngen code did not work with system include files like stdio.h.

Tests with Linux, OSX and Win32 show that this restriction is no longer needed.

So we hopefully can remove that special piece of code. This results in cleaner code and allows better use of the new GCC_FMT_ATTR macro.

---
 cris-dis.c    |    4 +---
 disas.h       |    3 ---
 dyngen-exec.h |   23 +----------------------
 qemu-common.h |    7 -------
 4 files changed, 2 insertions(+), 35 deletions(-)
cris-dis.c +1 -3
index 455ba8a..afd775c 100644
@@ -18,13 +18,11 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>. */
 
+#include "qemu-common.h"
 #include "dis-asm.h"
 //#include "sysdep.h"
 #include "target-cris/opcode-cris.h"
 //#include "libiberty.h"
-
 
-
-void *qemu_malloc(size_t len); /* can't include qemu-common.h here */
 
 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
disas.h +0 -3
index 6a9332d..f9287f7 100644
@@ -8,11 +8,8 @@
 void disas(FILE *out, void *code, unsigned long size);
 void target_disas(FILE *out, target_ulong code, target_ulong size, int flags);
 
-/* The usual mess... FIXME: Remove this condition once dyngen-exec.h is gone */
-#ifndef __DYNGEN_EXEC_H__
 void monitor_disas(Monitor *mon, CPUState *env,
                    target_ulong pc, int nb_insn, int is_physical, int flags);
-#endif
 
 /* Look up symbol for debugging purpose.  Returns "" if unknown. */
 const char *lookup_symbol(target_ulong orig_addr);
dyngen-exec.h +1 -22
index 5bfef3f..db00fba 100644
@@ -19,19 +19,7 @@
 #if !defined(__DYNGEN_EXEC_H__)
 #define __DYNGEN_EXEC_H__
 
-/* prevent Solaris from trying to typedef FILE in gcc's
-   include/floatingpoint.h which will conflict with the
-   definition down below */
-#ifdef __sun__
-#define _FILEDEFED
-#endif
-
-/* NOTE: standard headers should be used with special care at this
-   point because host CPU registers are used as global variables. Some
-   host headers do not allow that. */
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
+#include "qemu-common.h"
 
 #ifdef __OpenBSD__
 #include <sys/types.h>
@@ -40,15 +28,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__)
qemu-common.h +0 -7
index 81aafa0..d5ae420 100644
@@ -18,11 +18,6 @@ typedef struct QEMUFile QEMUFile;
 typedef struct QEMUBH QEMUBH;
 typedef struct DeviceState DeviceState;
 
-/* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that
-   cannot include the following headers without conflicts. This condition has
-   to be removed once dyngen is gone. */
-#ifndef __DYNGEN_EXEC_H__
-
 /* we put basic includes here to avoid repeating them in device drivers */
 #include <stdlib.h>
 #include <stdio.h>
@@ -318,6 +313,4 @@ static inline uint8_t from_bcd(uint8_t val)
 
 #include "module.h"
 
-#endif /* dyngen-exec.h hack */
-
 #endif
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/2 Replace remaining gcc format attributes by macro GCC_FMT_ATTR (format checking)

Replace the remaining format attribute printf by macro GCC_FMT_ATTR which uses gnu_printf (if supported).

v2
* Removal of dyngen specific code is now done in a separate patch.
* Handle attribute in new ui/spice-display.c, too.

---
 cpu-all.h          |    2 +-
 ui/spice-display.c |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
cpu-all.h +1 -1
index 67a3266..11edddc 100644
@@ -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;
 
ui/spice-display.c +1 -2
index 6702dfd..7b4f5c1 100644
@@ -29,8 +29,7 @@
 
 static int debug = 0;
 
-static void __attribute__((format(printf,2,3)))
-dprint(int level, const char *fmt, ...)
+static void GCC_FMT_ATTR(2, 3) dprint(int level, const char *fmt, ...)
 {
     va_list args;
 
Signature · 1 line
1.7.1
#2 lore raw

[Qemu-devel] Re: [PATCH 2/2] Replace remaining gcc format attributes by macro GCC_FMT_ATTR (format checking)

Am 13.10.2010 20:54, schrieb Stefan Weil:

Quoted 33 lines

Replace the remaining format attribute printf by macro GCC_FMT_ATTR which uses gnu_printf (if supported).

v2
* Removal of dyngen specific code is now done in a separate patch.
* Handle attribute in new ui/spice-display.c, too.

---
  cpu-all.h          |    2 +-
  ui/spice-display.c |    3 +--
  2 files changed, 2 insertions(+), 3 deletions(-)
cpu-all.h +1 -1
index 67a3266..11edddc 100644
@@ -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;
 
ui/spice-display.c +0 -0
index 6702dfd..7b4f5c1 100644

ui/spice-display.c line 35

Quoted 9 lines
ui/spice-display.c +1 -2
@@ -29,8 +29,7 @@
 
  static int debug = 0;
 
-static void __attribute__((format(printf,2,3)))
-dprint(int level, const char *fmt, ...)
+static void GCC_FMT_ATTR(2, 3) dprint(int level, const char *fmt, ...)
  {
      va_list args;
 

Can these two patches be applied to qemu master, or is there still something missing? They are needed for additional format checks.

Regards,
Stefan

Applied
#3 lore raw

[Qemu-devel] Re: [PATCH 2/2] Replace remaining gcc format attributes by macro GCC_FMT_ATTR (format checking)

Thanks, applied both.

Quoted 54 lines · Stefan Weil

Am 13.10.2010 20:54, schrieb Stefan Weil:

Quoted 34 lines

Replace the remaining format attribute printf by macro GCC_FMT_ATTR which uses gnu_printf (if supported).

v2
* Removal of dyngen specific code is now done in a separate patch.
* Handle attribute in new ui/spice-display.c, too.

---
 cpu-all.h          |    2 +-
 ui/spice-display.c |    3 +--

 2 files changed, 2 insertions(+), 3 deletions(-)
cpu-all.h +1 -1
index 67a3266..11edddc 100644
@@ -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;
 
ui/spice-display.c +0 -0
index 6702dfd..7b4f5c1 100644

ui/spice-display.c line 35

Quoted 9 lines
ui/spice-display.c +1 -2
@@ -29,8 +29,7 @@
 
  static int debug = 0;
 
-static void __attribute__((format(printf,2,3)))
-dprint(int level, const char *fmt, ...)
+static void GCC_FMT_ATTR(2, 3) dprint(int level, const char *fmt, ...)
  {
      va_list args;
 

Can these two patches be applied to qemu master, or is there still something missing?
They are needed for additional format checks.

Regards,
Stefan