[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/8] add QEMU_BUILD_BUG_EXPR
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PATCH 2/8] add QEMU_BUILD_BUG_EXPR |
Date: |
Thu, 27 Oct 2016 16:32:11 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Glib's GLIB_STATIC_ASSERT_EXPR can't be used in an array initialisation
where as this rune can.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
include/qemu/compiler.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 157698b..b6ad32c 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -88,6 +88,11 @@
#define QEMU_BUILD_BUG_ON(x) \
typedef char glue(qemu_build_bug_on__,__LINE__)[(x)?-1:1]
__attribute__((unused));
+/* Evaluates to 0 or fails; seems to work in an array initialisation unlike
+ * GLIB_STATIC_ASSERT_EXPR. Fails on true.
+ */
+#define QEMU_BUILD_BUG_EXPR(x) (sizeof(int [(x)?-1:1])-sizeof(int [1]))
+
#if defined __GNUC__
# if !QEMU_GNUC_PREREQ(4, 4)
/* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
--
2.9.3
- [Qemu-devel] [PATCH 0/8] VMSTATE_WITH_TMP and it's use in SLIRP, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 2/8] add QEMU_BUILD_BUG_EXPR,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PATCH 4/8] tests/migration: Add test for VMSTATE_WITH_TMP, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 3/8] migration: Add VMSTATE_WITH_TMP, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 1/8] migration: extend VMStateInfo, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 8/8] slirp: VMStatify remaining except for loop, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 5/8] slirp: VMState conversion; tcpcb, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 7/8] slirp: VMStatify socket level, Dr. David Alan Gilbert (git), 2016/10/27
- [Qemu-devel] [PATCH 6/8] slirp: VMStatify sbuf, Dr. David Alan Gilbert (git), 2016/10/27