From patchwork Mon Mar 29 19:16:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 48887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CA65EB7CBB for ; Tue, 30 Mar 2010 06:24:03 +1100 (EST) Received: from localhost ([127.0.0.1]:48554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NwKZ6-0007DR-Ph for incoming@patchwork.ozlabs.org; Mon, 29 Mar 2010 15:24:00 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NwKU9-0005u5-HV for qemu-devel@nongnu.org; Mon, 29 Mar 2010 15:18:53 -0400 Received: from [140.186.70.92] (port=33551 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NwKU7-0005rt-5W for qemu-devel@nongnu.org; Mon, 29 Mar 2010 15:18:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NwKU4-00080k-Ut for qemu-devel@nongnu.org; Mon, 29 Mar 2010 15:18:51 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:58545) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwKU4-00080V-JE for qemu-devel@nongnu.org; Mon, 29 Mar 2010 15:18:48 -0400 Received: from flocke.weilnetz.de (p54ADF80E.dip.t-dialin.net [84.173.248.14]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MgaRP-1OBMem149X-00O0YO; Mon, 29 Mar 2010 21:18:47 +0200 Received: from stefan by flocke.weilnetz.de with local (Exim 4.71) (envelope-from ) id 1NwKTs-0003Z6-G3; Mon, 29 Mar 2010 21:18:36 +0200 From: Stefan Weil To: QEMU Developers Date: Mon, 29 Mar 2010 21:16:52 +0200 Message-Id: <1269890225-13639-2-git-send-email-weil@mail.berlios.de> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1269890225-13639-1-git-send-email-weil@mail.berlios.de> References: <1269890225-13639-1-git-send-email-weil@mail.berlios.de> X-Provags-ID: V01U2FsdGVkX1+sgd43PL52HOp+TwT2BOgpUmbrvOBfHj9qYDM J9X2XrJSAjWDRcg4BY2gmOnVaek5cvG3a2QUIMiZyp4fh//dvX bnV/0x7QdORVXrms7WwtsqjLAKPLhMzZlj7v/DuMpPHvSQcZCD pqA== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 01/14] Add new data type for fprintf like function pointers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The compiler should check the arguments for these functions. gcc can do this, but only if the function pointer's prototype includes the __attribute__ flag. As the necessary declaration is a bit lengthy, we use a new data type 'fprintf_function'. It is not easy to find a single header file which is included everywhere, so fprint_function had to be declared in several header files. Signed-off-by: Stefan Weil --- cpu-all.h | 13 +++++++++---- cpu-defs.h | 6 ++++++ qemu-common.h | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cpu-all.h b/cpu-all.h index f281a91..d5c1380 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -760,11 +760,17 @@ void cpu_exec_init_all(unsigned long tb_size); CPUState *cpu_copy(CPUState *env); CPUState *qemu_get_cpu(int cpu); +#if !defined(FPRINTF_FUNCTION_DEFINED) +#define FPRINTF_FUNCTION_DEFINED +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); +#endif + void cpu_dump_state(CPUState *env, FILE *f, - int (*cpu_fprintf)(FILE *f, const char *fmt, ...), + fprintf_function cpu_fprintf, int flags); void cpu_dump_statistics (CPUState *env, FILE *f, - int (*cpu_fprintf)(FILE *f, const char *fmt, ...), + fprintf_function cpu_fprintf, int flags); void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...) @@ -915,8 +921,7 @@ int cpu_physical_memory_get_dirty_tracking(void); int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_addr_t end_addr); -void dump_exec_info(FILE *f, - int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); +void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); #endif /* !CONFIG_USER_ONLY */ int cpu_memory_rw_debug(CPUState *env, target_ulong addr, diff --git a/cpu-defs.h b/cpu-defs.h index 2e94585..81edf87 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -72,6 +72,12 @@ typedef uint64_t target_ulong; #define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) #define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE) +#if !defined(FPRINTF_FUNCTION_DEFINED) +#define FPRINTF_FUNCTION_DEFINED +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); +#endif + #if !defined(CONFIG_USER_ONLY) #define CPU_TLB_BITS 8 #define CPU_TLB_SIZE (1 << CPU_TLB_BITS) diff --git a/qemu-common.h b/qemu-common.h index 087c034..3658bfe 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -91,6 +91,12 @@ static inline char *realpath(const char *path, char *resolved_path) #else +#if !defined(FPRINTF_FUNCTION_DEFINED) +#define FPRINTF_FUNCTION_DEFINED +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) + __attribute__ ((format(printf, 2, 3))); +#endif + #include "cpu.h" #endif /* !defined(NEED_CPU_H) */