From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: Re: [PATCH 1/3] mini-os: add BUILD_BUG_ON() Date: Wed, 2 Jul 2014 18:10:20 +0200 Message-ID: <20140702161019.GA6022@type> References: <53B42ADE020000780001F94F@mail.emea.novell.com> <53B43275020000780001F9CD@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X2N72-0005Mo-K6 for xen-devel@lists.xenproject.org; Wed, 02 Jul 2014 16:10:24 +0000 Content-Disposition: inline In-Reply-To: <53B43275020000780001F9CD@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Jan Beulich, le Wed 02 Jul 2014 15:25:25 +0100, a =E9crit : > Just copy over what the hypervisor currently uses. > = > Signed-off-by: Jan Beulich Acked-by: Samuel Thibault > --- a/extras/mini-os/include/lib.h > +++ b/extras/mini-os/include/lib.h > @@ -54,6 +54,20 @@ > #include > #include "gntmap.h" > = > +#if __GNUC__ > 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ >=3D 6) > +/* Force a compilation error if condition is true */ > +#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); }) > +/* Force a compilation error if condition is true, but also produce a > + result (of value 0 and type size_t), so the expression can be used > + e.g. in a structure initializer (or where-ever else comma expressions > + aren't permitted). */ > +#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 > = > = > = > mini-os: add BUILD_BUG_ON() > = > Just copy over what the hypervisor currently uses. > = > Signed-off-by: Jan Beulich > = > --- a/extras/mini-os/include/lib.h > +++ b/extras/mini-os/include/lib.h > @@ -54,6 +54,20 @@ > #include > #include "gntmap.h" > = > +#if __GNUC__ > 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ >=3D 6) > +/* Force a compilation error if condition is true */ > +#define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); }) > +/* Force a compilation error if condition is true, but also produce a > + result (of value 0 and type size_t), so the expression can be used > + e.g. in a structure initializer (or where-ever else comma expressions > + aren't permitted). */ > +#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 -- = Samuel je la connaissais pas celle la : "make: Entering an unknown directory" -+- #ens-mim -+-