From: "Jan Beulich" Subject: [PATCH v2 1/3] mini-os: add BUILD_BUG_ON() Date: Thu, 03 Jul 2014 11:34:12 +0100 Message-ID: <53B54DC402000078000201EC@mail.emea.novell.com> References: <53B42ADE020000780001F94F@mail.emea.novell.com> <53B43275020000780001F9CD@mail.emea.novell.com> <20140703095818.GA32669@deinos.phlegethon.org> <53B5481D020000780002016A@mail.emea.novell.com> <20140703102654.GA32726@deinos.phlegethon.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part0B39E0B4.2__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2eLG-0003S1-UE for xen-devel@lists.xenproject.org; Thu, 03 Jul 2014 10:34:15 +0000 In-Reply-To: <20140703102654.GA32726@deinos.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Samuel Thibault , Tim Deegan , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part0B39E0B4.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just copy over what the hypervisor currently uses (comments dropped due to being of unknown origin; the implementation was done by me anyway). Signed-off-by: Jan Beulich --- v2: Drop comments and clarify origin as per Tim's suggestion. --- a/extras/mini-os/include/lib.h +++ b/extras/mini-os/include/lib.h @@ -54,6 +54,15 @@ #include #include "gntmap.h" =20 +#if __GNUC__ > 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ >=3D 6) +#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); }) +#define BUILD_BUG_ON_ZERO(cond) \ + sizeof(struct { _Static_assert(!(cond), "!(" #cond ")"); }) +#else +#define BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); }) +#define BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond)) +#endif + #ifdef HAVE_LIBC #include #include --=__Part0B39E0B4.2__= Content-Type: text/plain; name="minios-build-bug-on.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="minios-build-bug-on.patch" mini-os: add BUILD_BUG_ON()=0A=0AJust copy over what the hypervisor = currently uses (comments dropped due=0Ato being of unknown origin; the = implementation was done by me anyway).=0A=0ASigned-off-by: Jan Beulich = =0A---=0Av2: Drop comments and clarify origin as per = Tim's suggestion.=0A=0A--- a/extras/mini-os/include/lib.h=0A+++ b/extras/mi= ni-os/include/lib.h=0A@@ -54,6 +54,15 @@=0A #include = =0A #include "gntmap.h"=0A =0A+#if __GNUC__ > 4 || (__GNUC__ =3D=3D 4 && = __GNUC_MINOR__ >=3D 6)=0A+#define BUILD_BUG_ON(cond) ({ _Static_assert(!(co= nd), "!(" #cond ")"); })=0A+#define BUILD_BUG_ON_ZERO(cond) \=0A+ = sizeof(struct { _Static_assert(!(cond), "!(" #cond ")"); })=0A+#else=0A+#de= fine BUILD_BUG_ON_ZERO(cond) sizeof(struct { int:-!!(cond); })=0A+#define = BUILD_BUG_ON(cond) ((void)BUILD_BUG_ON_ZERO(cond))=0A+#endif=0A+=0A #ifdef = HAVE_LIBC=0A #include =0A #include =0A --=__Part0B39E0B4.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part0B39E0B4.2__=--