qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Weil <weil@mail.berlios.de>
To: QEMU Developers <qemu-devel@nongnu.org>
Cc: Blue Swirl <blauwirbel@gmail.com>
Subject: [Qemu-devel] [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file
Date: Mon, 20 Sep 2010 23:05:02 +0200	[thread overview]
Message-ID: <1285016702-31558-1-git-send-email-weil@mail.berlios.de> (raw)
In-Reply-To: <AANLkTi=cnXfrCxiW6LapJHrzceTWV_084eZcxpRR+6=r@mail.gmail.com>

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)).

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 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..8a2872a 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -70,6 +70,22 @@ struct iovec {
 #include <sys/uio.h>
 #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

  parent reply	other threads:[~2010-09-20 21:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-11  6:46 [Qemu-devel] [PATCH] mips_fulong2e: Detect format errors for function prom_set Stefan Weil
2010-09-11  6:46 ` [Qemu-devel] [PATCH] mips_malta: " Stefan Weil
2010-09-13 20:02   ` [Qemu-devel] [PATCH 1/2] Add support for gcc format attribute gnu_printf Stefan Weil
2010-09-20 19:18     ` Blue Swirl
2010-09-20 21:03       ` Stefan Weil
2010-09-20 21:05       ` Stefan Weil [this message]
2010-09-21 17:46         ` [Qemu-devel] Re: [PATCH] Move macros GCC_ATTR and GCC_FMT_ATTR to common header file Stefan Weil
2010-09-21 17:48           ` [Qemu-devel] " Stefan Weil
2010-09-21 18:17             ` [Qemu-devel] " Blue Swirl
2010-09-21 20:27               ` [Qemu-devel] " Stefan Weil
2010-09-22 20:30                 ` [Qemu-devel] " Blue Swirl
2010-09-13 20:02   ` [Qemu-devel] [PATCH 2/2] Use new gcc format attribute gnu_printf Stefan Weil
2010-09-20 18:53     ` Blue Swirl
2010-09-20 19:04   ` [Qemu-devel] [PATCH] mips_malta: Detect format errors for function prom_set Blue Swirl
2010-09-20 19:03 ` [Qemu-devel] [PATCH] mips_fulong2e: " Blue Swirl
2010-09-20 20:18   ` [Qemu-devel] [PATCH 1/2] mips_fulong2e: Fix format strings Stefan Weil
2010-09-21 19:48     ` [Qemu-devel] " Blue Swirl
2010-09-20 20:18   ` [Qemu-devel] [PATCH 2/2] mips_malta: " Stefan Weil
2010-09-21 19:48     ` [Qemu-devel] " Blue Swirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285016702-31558-1-git-send-email-weil@mail.berlios.de \
    --to=weil@mail.berlios.de \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).