Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1487CC11F67 for ; Thu, 1 Jul 2021 21:55:01 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5283B61411 for ; Thu, 1 Jul 2021 21:55:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5283B61411 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A635882C5F; Thu, 1 Jul 2021 23:54:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="mPWsmqUJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F47482C23; Thu, 1 Jul 2021 23:54:56 +0200 (CEST) Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A0EE282C23 for ; Thu, 1 Jul 2021 23:54:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf2d.google.com with SMTP id p7so3757625qvn.5 for ; Thu, 01 Jul 2021 14:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9H5qBtGOmcMPkSze6joG2pWNORQ3gzCK9ceaQ+ViPLA=; b=mPWsmqUJwarIQKkcgG7SVI8erURTCtYdY6lLk7wzHzx0DxPqNGOOmsgkk16vL/d8xO GQPR52oHT91OvKzfTpo2zyO12A4ZY87lg/rcM//wRpku0mQivbHF2eOru4xR0yZjJTRy FDlGc0P0MZz7XS5GVikL6G/urkFhTM3QXmKLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9H5qBtGOmcMPkSze6joG2pWNORQ3gzCK9ceaQ+ViPLA=; b=pmnkXFH39NhtnmDJn0IJsXaJGdGcusqoyx/jbcemsmW6DcSPNUimcEXEwUU5SozCXT ZL4aLOjo/rqKq2BM1wDgWsrOroN2amnizqDJCnwnP/RlBO8tXvN+dc+8zvm+dK1kC1kV Sq7KfHLuSwShfKz+w9Hw6it0Gu+kqVMUcosEUeAlqAzaXQ1G06PvqVkRdEGsE6hzUtVn rkYbmG++GUGMRkz8gx7lJLeWpVv/LgIOK5GyV9yfbqTGsDxH0txxyzW7WASGBT4HBzzX 1GNbh6rtw+GJ6wWvkFDQR1auHJxC4qw/StlZoPf3pU0snor2d3Mik4nGcdU2qOxjuiEc 91cw== X-Gm-Message-State: AOAM533yabeJXk4alZZOP8/NzAV8zA0WK4hQi/2XdeNlrqnUIZmRMg4X 5KeJE0Ym8ExyMmbZ0458bu7oyA== X-Google-Smtp-Source: ABdhPJzMEyBsgN3SDeUDwXKNDkHq86UFz75u1ktHUPwAixblYGefG4/F9vicWEh5uMydW7oQPJADSQ== X-Received: by 2002:ad4:4682:: with SMTP id bq2mr2082898qvb.34.1625176492386; Thu, 01 Jul 2021 14:54:52 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-91af-d604-26f4-428b.res6.spectrum.com. [2603:6081:7b01:cbda:91af:d604:26f4:428b]) by smtp.gmail.com with ESMTPSA id u3sm508713qtg.16.2021.07.01.14.54.51 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Jul 2021 14:54:51 -0700 (PDT) Date: Thu, 1 Jul 2021 17:54:49 -0400 From: Tom Rini To: Rasmus Villemoes Cc: u-boot@lists.denx.de, Stefan Roese , Matt Merhar , Simon Glass Subject: Re: [RFC PATCH 1/2] build_bug.h: add wrapper for _Static_assert Message-ID: <20210701215449.GR9516@bill-the-cat> References: <20210518091947.63513-1-rasmus.villemoes@prevas.dk> <20210518091947.63513-2-rasmus.villemoes@prevas.dk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5qDhD2bBXZNsfkt8" Content-Disposition: inline In-Reply-To: <20210518091947.63513-2-rasmus.villemoes@prevas.dk> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --5qDhD2bBXZNsfkt8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 18, 2021 at 11:19:46AM +0200, Rasmus Villemoes wrote: > [Linux commit 6bab69c65013bed5fce9f101a64a84d0385b3946] >=20 > BUILD_BUG_ON() is a little annoying, since it cannot be used outside > function scope. So one cannot put assertions about the sizeof() a > struct next to the struct definition, but has to hide that in some more > or less arbitrary function. >=20 > Since gcc 4.6 (which is now also the required minimum), there is support > for the C11 _Static_assert in all C modes, including gnu89. So add a > simple wrapper for that. >=20 > _Static_assert() requires a message argument, which is usually quite > redundant (and I believe that bug got fixed at least in newer C++ > standards), but we can easily work around that with a little macro > magic, making it optional. >=20 > For example, adding >=20 > static_assert(sizeof(struct printf_spec) =3D=3D 8); >=20 > in vsprintf.c and modifying that struct to violate it, one gets >=20 > ./include/linux/build_bug.h:78:41: error: static assertion failed: "sizeo= f(struct printf_spec) =3D=3D 8" > #define __static_assert(expr, msg, ...) _Static_assert(expr, "" msg "") >=20 > godbolt.org suggests that _Static_assert() has been support by clang > since at least 3.0.0. >=20 > Signed-off-by: Rasmus Villemoes > Reviewed-by: Simon Glass Applied to u-boot/next, thanks! --=20 Tom --5qDhD2bBXZNsfkt8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmDeOaMACgkQFHw5/5Y0 tywyRgwAqwtxAveA+8V6g5WfvqBvfdSKb2aNcOAEtbtOPJvVaCN/ZRnsfGYf3pt8 +lurWzDSwAyOk8fjPua/+GzC5oHy3d7ctq8wx2HTML7qWeeG0zhMTHtMLM4sPrdy qsCjLq5ACTHxk3qcSH+Ckw1KDVpWzEML/TakuEO4cFPK7bwT4qucX4ezbFxzZ/NR okuf0kXez63Hcu7ND7c1ia9lSvYArnXBF+z/Ie9l2eDAgqNqyaHyOJRD1peVstHV BRHEFOg7G3nA+obHpx5UNBiio9mg2rDQUAi+grdIMWMZfgShH6UtFYTBEJ3XRBhy +evoRdfyZjsI+B3BtwmjowpfkIU5p0nsnvqjTYEQoIYNlwR6el/yIBEwZBvdpfQT 5jI8cM6i/ftSwelN6HBOWaurYpHS5wQU9MA5nwLtLQSjyNNhJA5/SS+4zJoIMwFi QYtoM8adhkulNH0I/+7Wtzn+iKTY7gWNBl02MIlMCvuMl8kbt0adlJ31QoOyLgQI OIbWEcHh =CUEI -----END PGP SIGNATURE----- --5qDhD2bBXZNsfkt8--