xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>,
	Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] libs/gnttab: introduce BUILD_BUG_ON
Date: Wed, 13 Jul 2016 13:21:25 +0100	[thread overview]
Message-ID: <20160713122125.GE31770@citrix.com> (raw)
In-Reply-To: <1b2ddbf2-121c-7a89-e8f4-8c5f8a1d01f0@citrix.com>

On Wed, Jul 13, 2016 at 01:16:51PM +0100, Andrew Cooper wrote:
> On 13/07/16 13:07, Wei Liu wrote:
> > On Wed, Jul 13, 2016 at 01:32:10PM +0200, Paulina Szubarczyk wrote:
> >>
> >> On 07/13/2016 11:25 AM, Wei Liu wrote:
> >>> The implementation is taken from libxc.
> >>>
> >>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> >>> ---
> >>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> >>> Cc: Paulina Szubarczyk <paulinaszubarczyk@gmail.com>
> >>>
> >>> I could have put it in a header file accessible to all libraries under
> >>> libs but this construct is only relevant to xengnttab library at the
> >>> moment so it's put under gnttab/private.h. It can be easily moved to
> >>> a common place when other libraries under libs require it.
> >>>
> >>> This patch is necessary to unblock Paulina on her gnttab copy work.
> >>> ---
> >>>  tools/libs/gnttab/private.h | 7 +++++++
> >>>  1 file changed, 7 insertions(+)
> >>>
> >>> diff --git a/tools/libs/gnttab/private.h b/tools/libs/gnttab/private.h
> >>> index d286c86..da487f2 100644
> >>> --- a/tools/libs/gnttab/private.h
> >>> +++ b/tools/libs/gnttab/private.h
> >>> @@ -4,6 +4,13 @@
> >>>  #include <xentoollog.h>
> >>>  #include <xengnttab.h>
> >>>
> >>> +/* Force a compilation error if condition is true */
> >>> +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
> >>> +#define BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
> >>> +#else
> >>> +#define BUILD_BUG_ON(p) ((void)sizeof(struct { int:-!!(p); }))
> >>> +#endif
> >>> +
> >>>  struct xengntdev_handle {
> >>>      xentoollog_logger *logger, *logger_tofree;
> >>>      int fd;
> >>>
> >> Hi Wei,
> >>
> >> thank you for the help with the grant copy patch. I have just rebuild Xen
> >> and there is a conflict with definition of BUILD_BUG_ON for mini-os build:
> >>
> >> In file included from minios.c:33:0:
> >> private.h:9:0: error: "BUILD_BUG_ON" redefined [-Werror]
> >>  #define BUILD_BUG_ON(p) ({ _Static_assert(!(p), "!(" #p ")"); })
> >>  ^
> >> In file included from minios.c:25:0:
> >> xen/extras/mini-os-remote/include/lib.h:58:0: note: this is the location of
> >> the previous definition
> >>  #define BUILD_BUG_ON(cond) ({ _Static_assert(!(cond), "!(" #cond ")"); })
> >>  ^
> >> I thought about wrapping the code in #ifndef BUILD_BUG_ON #endif.
> > We could use a prefix to the one used in gnttab.
> >
> > Maybe call it XENGNTTAB_BUILD_BUG_ON for now?
> 
> The contents of gnttabs private.h is entirely up to gnttab.
> 
> It is MiniOS (who is poking about in someone elses private.h) with the
> responsibility not to have a broken build.  It needs to do this by not
> leaking so much stuff into its global namespace.
> 

Yeah, I know. It wouldn't hurt to prefix the name anyway.

The mini-os build system problem can be solve separately.

Wei.

> ~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

      reply	other threads:[~2016-07-13 12:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13  9:25 [PATCH] libs/gnttab: introduce BUILD_BUG_ON Wei Liu
2016-07-13 11:32 ` Paulina Szubarczyk
2016-07-13 12:07   ` Wei Liu
2016-07-13 12:16     ` Andrew Cooper
2016-07-13 12:21       ` Wei Liu [this message]

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=20160713122125.GE31770@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=paulinaszubarczyk@gmail.com \
    --cc=xen-devel@lists.xenproject.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).