From nobody Wed May 8 11:11:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148950284820780.82618683701196; Tue, 14 Mar 2017 07:47:28 -0700 (PDT) Received: from localhost ([::1]:59876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnnjR-0003tV-3W for importer@patchew.org; Tue, 14 Mar 2017 10:47:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnnhO-00030u-Fx for qemu-devel@nongnu.org; Tue, 14 Mar 2017 10:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnnhN-0007M9-PT for qemu-devel@nongnu.org; Tue, 14 Mar 2017 10:45:18 -0400 Received: from www145.your-server.de ([78.47.15.66]:34906) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnnhJ-0007GI-6k; Tue, 14 Mar 2017 10:45:13 -0400 Received: from [88.198.220.132] (helo=sslproxy03.your-server.de) by www145.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1cnnhH-0006IK-UN; Tue, 14 Mar 2017 15:45:11 +0100 Received: from [141.89.226.146] (helo=parabola-pocket.hpi.uni-potsdam.de) by sslproxy03.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES128-GCM-SHA256:128) (Exim 4.84_2) (envelope-from ) id 1cnnhH-0007SJ-Hk; Tue, 14 Mar 2017 15:45:11 +0100 From: Andreas Grapentin To: qemu-devel@nongnu.org Date: Tue, 14 Mar 2017 15:44:53 +0100 Message-Id: <20170314144453.5027-2-andreas@grapentin.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170314144453.5027-1-andreas@grapentin.org> References: <20170314144453.5027-1-andreas@grapentin.org> X-Authenticated-Sender: andreas@grapentin.org X-Virus-Scanned: Clear (ClamAV 0.99.2/23203/Tue Mar 14 13:13:21 2017) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 78.47.15.66 Subject: [Qemu-devel] [PATCH 1/1] added configure check for _Static_assert and updated QEMU_BUILD_BUG_ON(...) accordingly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Andreas Grapentin Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" --- 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 =20 ########################################## +# check for _Static_assert() + +have_static_assert=3Dno +cat > $TMPC << EOF +_Static_assert(1, "success."); +int main(void) { + return 0; +} +EOF +if compile_prog "" "" ; then + have_static_assert=3Dyes +fi + +########################################## # End of CC checks # After here, no more $cc or $ld runs =20 @@ -5694,6 +5708,10 @@ if test "$have_sysmacros" =3D "yes" ; then echo "CONFIG_SYSMACROS=3Dy" >> $config_host_mak fi =20 +if test "$have_static_assert" =3D "yes" ; then + echo "CONFIG_STATIC_ASSERT=3Dy" >> $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; \ } =20 -#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 --=20 2.12.0