qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Grapentin <andreas@grapentin.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Andreas Grapentin <andreas@grapentin.org>
Subject: [Qemu-devel] [PATCH 1/1] added configure check for _Static_assert and updated QEMU_BUILD_BUG_ON(...) accordingly
Date: Tue, 14 Mar 2017 15:44:53 +0100	[thread overview]
Message-ID: <20170314144453.5027-2-andreas@grapentin.org> (raw)
In-Reply-To: <20170314144453.5027-1-andreas@grapentin.org>

---
 configure               | 18 ++++++++++++++++++
 include/qemu/compiler.h |  4 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 75c7c3526c..e9b33d9cf8 100755
--- a/configure
+++ b/configure
@@ -4725,6 +4725,20 @@ if compile_prog "" "" ; then
 fi
 
 ##########################################
+# check for _Static_assert()
+
+have_static_assert=no
+cat > $TMPC << EOF
+_Static_assert(1, "success.");
+int main(void) {
+    return 0;
+}
+EOF
+if compile_prog "" "" ; then
+    have_static_assert=yes
+fi
+
+##########################################
 # End of CC checks
 # After here, no more $cc or $ld runs
 
@@ -5694,6 +5708,10 @@ if test "$have_sysmacros" = "yes" ; then
   echo "CONFIG_SYSMACROS=y" >> $config_host_mak
 fi
 
+if test "$have_static_assert" = "yes" ; then
+  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
+fi
+
 # Hold two types of flag:
 #   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
 #                                     a thread we have a handle to
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index e0ce9ffb28..37a65d4bb7 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -90,7 +90,9 @@
         int:(x) ? -1 : 1; \
     }
 
-#ifdef __COUNTER__
+#if defined(CONFIG_STATIC_ASSERT)
+#define QEMU_BUILD_BUG_ON(x) _Static_assert(!(x), #x)
+#elif defined(__COUNTER__)
 #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
     glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
 #else
-- 
2.12.0

  reply	other threads:[~2017-03-14 14:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-14 14:44 [Qemu-devel] [PATCH 0/1] Developer Conveniences - check for _Static_assert and use in QEMU_BUILD_BUG_ON Andreas Grapentin
2017-03-14 14:44 ` Andreas Grapentin [this message]
2017-03-14 15:08   ` [Qemu-devel] [PATCH 1/1] added configure check for _Static_assert and updated QEMU_BUILD_BUG_ON(...) accordingly Eric Blake
2017-03-14 14:58 ` [Qemu-devel] [PATCH 0/1] Developer Conveniences - check for _Static_assert and use in QEMU_BUILD_BUG_ON Eric Blake

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=20170314144453.5027-2-andreas@grapentin.org \
    --to=andreas@grapentin.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).