qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__
@ 2017-01-31 14:43 Michael S. Tsirkin
  2017-01-31 15:02 ` Peter Maydell
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Michael S. Tsirkin @ 2017-01-31 14:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Eric Blake, Peter Maydell, Paolo Bonzini, Markus Armbruster

Some headers use QEMU_BUILD_BUG_ON. This causes a problem
if the C file including that header happens to have
QEMU_BUILD_BUG_ON at the same line number.

Fix using a widely available extension: __COUNTER__.
If unavailable, provide a stub.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/qemu/compiler.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index e0fb18b..bad25a9 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -89,8 +89,12 @@
     struct { \
         int:(x) ? -1 : 1; \
     }
+#ifdef __COUNTER__
 #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
-    glue(qemu_build_bug_on__, __LINE__) __attribute__((unused))
+    glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
+#else
+#define QEMU_BUILD_BUG_ON(x)
+#endif
 
 #define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \
                                    sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
-- 
MST

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-01-31 18:58 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-31 14:43 [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__ Michael S. Tsirkin
2017-01-31 15:02 ` Peter Maydell
2017-01-31 15:03 ` Eric Blake
2017-01-31 15:12   ` Peter Maydell
2017-01-31 15:16     ` Eric Blake
2017-01-31 15:26       ` Peter Maydell
2017-01-31 15:28         ` Paolo Bonzini
2017-01-31 16:17           ` Peter Maydell
2017-01-31 15:34     ` Markus Armbruster
2017-01-31 17:58       ` Michael S. Tsirkin
2017-01-31 15:26 ` Markus Armbruster
2017-01-31 15:29   ` Michael S. Tsirkin
2017-01-31 16:07     ` Markus Armbruster
2017-01-31 16:37       ` Eric Blake
2017-01-31 16:54         ` Peter Maydell
2017-01-31 15:47   ` Peter Maydell
2017-01-31 16:50 ` Daniel P. Berrange
2017-01-31 17:56   ` Michael S. Tsirkin
2017-01-31 18:43   ` Markus Armbruster
2017-01-31 18:58     ` Eric Blake

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