From patchwork Tue Sep 21 20:27:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Weil X-Patchwork-Id: 65378 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 9F4C4B70D0 for ; Wed, 22 Sep 2010 06:28:45 +1000 (EST) Received: from localhost ([127.0.0.1]:40905 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy9SE-0003HY-2l for incoming@patchwork.ozlabs.org; Tue, 21 Sep 2010 16:28:42 -0400 Received: from [140.186.70.92] (port=33270 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy9Rb-0003GV-Rx for qemu-devel@nongnu.org; Tue, 21 Sep 2010 16:28:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy9Ra-000842-FY for qemu-devel@nongnu.org; Tue, 21 Sep 2010 16:28:03 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:57681) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy9Ra-00082i-3k for qemu-devel@nongnu.org; Tue, 21 Sep 2010 16:28:02 -0400 Received: from flocke.weilnetz.de (p54ADAC6A.dip.t-dialin.net [84.173.172.106]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MgYEB-1PCm1H2oJ5-00Nqu9; Tue, 21 Sep 2010 22:27:52 +0200 Received: from stefan by flocke.weilnetz.de with local (Exim 4.72) (envelope-from ) id 1Oy9RP-0002s0-DP; Tue, 21 Sep 2010 22:27:51 +0200 From: Stefan Weil To: QEMU Developers Date: Tue, 21 Sep 2010 22:27:49 +0200 Message-Id: <1285100869-11002-1-git-send-email-weil@mail.berlios.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: X-Provags-ID: V02:K0:CRTXESqN6o9IuylR4ZUL2tDZvha2S5z4Zhpl2F7iDOQ YULObs8SR+ZSp+S9C9I4xzp6r59jUDPnv2ZJYU+rVa9ZiZwqRZ OQtA2bjNHxx+W7M9QbUhcz14WKWy4f8+2pUooJW0O9KUhFQn2S 0YD4BGgUm4HndG++0ClsemxJUelNuWoMrGuIskpX2uZerKiRRc QnZje2EOdrzJWQjaRid3MtLKhfTaqVw0W7mX6aTXPP39Y3KsfS iQeE1rkhKgz1j X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Blue Swirl Subject: [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file 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 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 06e313f..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__ (__printf__, 1, 2))) -#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__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 dfd3dc0..96be1d4 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