From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Eric Blake <eblake@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PULL 03/16] compiler: expression version of QEMU_BUILD_BUG_ON
Date: Wed, 25 Jan 2017 00:36:26 +0200 [thread overview]
Message-ID: <1485297322-10595-4-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1485297322-10595-1-git-send-email-mst@redhat.com>
QEMU_BUILD_BUG_ON uses a typedef in order to be safe
to use outside functions, but sometimes it's useful
to have a version that can be used within an expression.
Following what Linux does, introduce QEMU_BUILD_BUG_ON_ZERO
that return zero after checking condition at build time.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
include/qemu/compiler.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 1da500e..e0fb18b 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -92,6 +92,9 @@
#define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
glue(qemu_build_bug_on__, __LINE__) __attribute__((unused))
+#define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \
+ sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
+
#if defined __GNUC__
# if !QEMU_GNUC_PREREQ(4, 4)
/* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
--
MST
next prev parent reply other threads:[~2017-01-24 22:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-24 22:36 [Qemu-devel] [PULL 00/16] virtio, vhost, pci: fixes, features Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 01/16] compiler: drop ; after BUILD_BUG_ON Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 02/16] compiler: rework BUG_ON using a struct Michael S. Tsirkin
2017-01-24 22:36 ` Michael S. Tsirkin [this message]
2017-01-24 22:36 ` [Qemu-devel] [PULL 04/16] ARRAY_SIZE: check that argument is an array Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 05/16] pci: mark ROMs read-only Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 06/16] intel_iommu: fix and simplify size calculation in process_device_iotlb_desc() Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 07/16] hw/pcie: Introduce a base class for PCI Express Root Ports Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 08/16] hw/ioh3420: derive from PCI Express Root Port base class Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 09/16] hw/pcie: Introduce Generic PCI Express Root Port Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 10/16] hw/i386: check if nvdimm is enabled before plugging Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 11/16] msix: Follow CODING_STYLE Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 12/16] hcd-xhci: check & correct param before using it Michael S. Tsirkin
2017-01-24 22:36 ` [Qemu-devel] [PULL 13/16] pci: Convert msix_init() to Error and fix callers Michael S. Tsirkin
2017-01-24 22:37 ` [Qemu-devel] [PULL 14/16] virtio: make virtio_should_notify static Michael S. Tsirkin
2017-01-24 22:37 ` [Qemu-devel] [PULL 15/16] vhost: skip ROM sections Michael S. Tsirkin
2017-01-24 22:37 ` [Qemu-devel] [PULL 16/16] vhost-user: delete chardev on cleanup Michael S. Tsirkin
2017-01-25 16:36 ` [Qemu-devel] [PULL 00/16] virtio, vhost, pci: fixes, features Peter Maydell
2017-01-25 18:02 ` Marcel Apfelbaum
2017-01-25 18:08 ` Peter Maydell
2017-01-25 18:45 ` Marcel Apfelbaum
2017-01-25 19:24 ` Peter Maydell
2017-01-25 21:57 ` Michael S. Tsirkin
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=1485297322-10595-4-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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).