From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47475 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy76Y-00075c-3U for qemu-devel@nongnu.org; Tue, 21 Sep 2010 13:58:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy6xW-0003ME-Vd for qemu-devel@nongnu.org; Tue, 21 Sep 2010 13:48:52 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:58029) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy6xW-0003Lv-Kz for qemu-devel@nongnu.org; Tue, 21 Sep 2010 13:48:50 -0400 From: Stefan Weil Date: Tue, 21 Sep 2010 19:48:37 +0200 Message-Id: <1285091317-6060-1-git-send-email-weil@mail.berlios.de> In-Reply-To: <4C98EF6A.9010107@mail.berlios.de> References: <4C98EF6A.9010107@mail.berlios.de> Subject: [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers Cc: Blue Swirl By moving the definition of GCC_ATTR and GCC_FMT_ATTR from audio_int.h to qemu-common.h these macros are now generally available for further patches which add the gcc format attribute. Newer gcc versions support format gnu_printf which is better suited for use in QEMU than format printf (QEMU always uses standard format strings (even with mingw32)). V2: Use correct operator '==' (instead of '=') Cc: Blue Swirl Signed-off-by: Stefan Weil --- audio/audio_int.h | 8 -------- qemu-common.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/audio/audio_int.h b/audio/audio_int.h index f6a77ad..d8560b6 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -236,14 +236,6 @@ static inline int audio_ring_dist (int dst, int src, int len) return (dst >= src) ? (dst - src) : (len - src + dst); } -#if defined __GNUC__ -#define GCC_ATTR __attribute__ ((__unused__, format (gnu_printf, 1, 2))) -#define GCC_FMT_ATTR(n, m) __attribute__ ((format (gnu_printf, n, m))) -#else -#define GCC_ATTR /**/ -#define GCC_FMT_ATTR(n, m) -#endif - static void GCC_ATTR dolog (const char *fmt, ...) { va_list ap; diff --git a/qemu-common.h b/qemu-common.h index 956b545..e97a96e 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -70,6 +70,22 @@ struct iovec { #include #endif +#if defined __GNUC__ +# if (__GNUC__ < 4) || \ + defined(__GNUC_MINOR__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4) + /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */ +# define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m))) +# else + /* Use gnu_printf when supported (qemu uses standard format strings). */ +# define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2))) +# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m))) +# endif +#else +#define GCC_ATTR /**/ +#define GCC_FMT_ATTR(n, m) +#endif + #ifdef _WIN32 #define fsync _commit #define lseek _lseeki64 -- 1.7.1