diff mbox

tools/libxc: Provide evtchn_port_or_error_t for compat xenctrl interface

Message ID 1454324883-8288-1-git-send-email-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Cooper Feb. 1, 2016, 11:08 a.m. UTC
c/s 2d2f789 "tools: rename libxc's evtchn_port_or_error_t with an xc_
prefix" doesn't cater for older applications which have requested
XC_WANT_COMPAT_EVTCHN_API

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxc/include/xenctrl_compat.h | 1 +
 1 file changed, 1 insertion(+)

Comments

Ian Campbell Feb. 1, 2016, 11:19 a.m. UTC | #1
On Mon, 2016-02-01 at 11:08 +0000, Andrew Cooper wrote:
> c/s 2d2f789 "tools: rename libxc's evtchn_port_or_error_t with an xc_
> prefix" doesn't cater for older applications which have requested
> XC_WANT_COMPAT_EVTCHN_API

I think we can safely assume that such apps are not also using xenevtchn.h
(otherwise there would be clashes already) so:

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxc/include/xenctrl_compat.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/libxc/include/xenctrl_compat.h
> b/tools/libxc/include/xenctrl_compat.h
> index dc513a3..93ccadb 100644
> --- a/tools/libxc/include/xenctrl_compat.h
> +++ b/tools/libxc/include/xenctrl_compat.h
> @@ -51,6 +51,7 @@ void *xc_map_foreign_bulk(xc_interface *xch, uint32_t
> dom, int prot,
>  #ifdef XC_WANT_COMPAT_EVTCHN_API
>  
>  typedef struct xenevtchn_handle xc_evtchn;
> +typedef xc_evtchn_port_or_error_t evtchn_port_or_error_t;
>  
>  xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
>                               unsigned open_flags);
Ian Campbell Feb. 3, 2016, 11:48 a.m. UTC | #2
On Mon, 2016-02-01 at 11:19 +0000, Ian Campbell wrote:
> On Mon, 2016-02-01 at 11:08 +0000, Andrew Cooper wrote:
> > c/s 2d2f789 "tools: rename libxc's evtchn_port_or_error_t with an xc_
> > prefix" doesn't cater for older applications which have requested
> > XC_WANT_COMPAT_EVTCHN_API
> 
> I think we can safely assume that such apps are not also using
> xenevtchn.h
> (otherwise there would be clashes already) so:
> 
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>

applied.
Olaf Hering Feb. 3, 2016, 5:12 p.m. UTC | #3
On Mon, Feb 01, Andrew Cooper wrote:

> c/s 2d2f789 "tools: rename libxc's evtchn_port_or_error_t with an xc_
> prefix" doesn't cater for older applications which have requested
> XC_WANT_COMPAT_EVTCHN_API

Not sure, but I think this breaks staging at last in SLES11:

[   93s] gcc  -DPIC -O1 -fno-omit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement   -O0 -g3 -D__XEN_TOOLS__ -MMD -MF .xc_evtchn_compat.opic.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -D_GNU_SOURCE -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I./include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -pthread -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/toollog/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/evtchn/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/includ
 e -include /usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/config.h -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/call/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/foreignmemory/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/gnttab/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/gnttab/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include  -fPIC -c -o xc_evtchn_compat.opic xc_evtchn
 _compat.c
[   93s] In file included from ./include/xenctrl.h:2577,
[   93s]                  from xc_evtchn_compat.c:9:
[   93s] ./include/xenctrl_compat.h:54: error: redefinition of typedef 'evtchn_port_or_error_t'
[   93s] /usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/evtchn/include/xenevtchn.h:31: error: previous declaration of 'evtchn_port_or_error_t' was here
[   93s] make[4]: *** [xc_evtchn_compat.opic] Error 1

Olaf
Andrew Cooper Feb. 3, 2016, 5:18 p.m. UTC | #4
On 03/02/16 17:12, Olaf Hering wrote:
> On Mon, Feb 01, Andrew Cooper wrote:
>
>> c/s 2d2f789 "tools: rename libxc's evtchn_port_or_error_t with an xc_
>> prefix" doesn't cater for older applications which have requested
>> XC_WANT_COMPAT_EVTCHN_API
> Not sure, but I think this breaks staging at last in SLES11:
>
> [   93s] gcc  -DPIC -O1 -fno-omit-frame-pointer -m64 -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement   -O0 -g3 -D__XEN_TOOLS__ -MMD -MF .xc_evtchn_compat.opic.d -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls -D_GNU_SOURCE -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I./include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -pthread -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/toollog/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/evtchn/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/incl
 ude -include /usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/config.h -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/call/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/foreignmemory/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/gnttab/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/gnttab/include -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/include  -fPIC -c -o xc_evtchn_compat.opic xc_evtc
 hn_compat.c
> [   93s] In file included from ./include/xenctrl.h:2577,
> [   93s]                  from xc_evtchn_compat.c:9:
> [   93s] ./include/xenctrl_compat.h:54: error: redefinition of typedef 'evtchn_port_or_error_t'
> [   93s] /usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-dbg/tools/libxc/../../tools/libs/evtchn/include/xenevtchn.h:31: error: previous declaration of 'evtchn_port_or_error_t' was here
> [   93s] make[4]: *** [xc_evtchn_compat.opic] Error 1
>
> Olaf

Urgh.  This is getting even more complicated.

This patch is needed to avoid breaking the build for older programs
using just

#define XC_WANT_COMPAT_EVTCHN_API
#include <xenctrl.h>

so simply reverting it isn't a viable option either.

Is there any way in C to determine whether a typedef already exists?

~Andrew
Ian Campbell Feb. 4, 2016, 9:27 a.m. UTC | #5
On Wed, 2016-02-03 at 17:18 +0000, Andrew Cooper wrote:
> On 03/02/16 17:12, Olaf Hering wrote:
> > On Mon, Feb 01, Andrew Cooper wrote:
> > 
> > > c/s 2d2f789 "tools: rename libxc's evtchn_port_or_error_t with an xc_
> > > prefix" doesn't cater for older applications which have requested
> > > XC_WANT_COMPAT_EVTCHN_API
> > Not sure, but I think this breaks staging at last in SLES11:
> > 
> > [   93s] gcc  -DPIC -O1 -fno-omit-frame-pointer -m64 -fno-strict-
> > aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-
> > statement   -O0 -g3 -D__XEN_TOOLS__ -MMD -MF .xc_evtchn_compat.opic.d
> > -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -fno-optimize-sibling-calls
> > -D_GNU_SOURCE -fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-
> > protector -funwind-tables -fasynchronous-unwind-tables
> > -I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I./include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include -pthread
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/toollog/include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-
> > 4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/evtchn/include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include -include
> > /usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/config.h -I/usr/src/packages/BUILD/xen-
> > 4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/call/include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-
> > 4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/foreignmemory/include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-
> > 4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/gnttab/include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include -I/usr/src/packages/BUILD/xen-
> > 4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/gnttab/include
> > -I/usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/include  -fPIC -c -o xc_evtchn_compat.opic
> > xc_evtchn_compat.c
> > [   93s] In file included from ./include/xenctrl.h:2577,
> > [   93s]                  from xc_evtchn_compat.c:9:
> > [   93s] ./include/xenctrl_compat.h:54: error: redefinition of typedef
> > 'evtchn_port_or_error_t'
> > [   93s] /usr/src/packages/BUILD/xen-4.7.20160203T131200.be05b53/non-
> > dbg/tools/libxc/../../tools/libs/evtchn/include/xenevtchn.h:31: error:
> > previous declaration of 'evtchn_port_or_error_t' was here
> > [   93s] make[4]: *** [xc_evtchn_compat.opic] Error 1
> > 
> > Olaf
> 
> Urgh.  This is getting even more complicated.
> 
> This patch is needed to avoid breaking the build for older programs
> using just
> 
> #define XC_WANT_COMPAT_EVTCHN_API
> #include <xenctrl.h>
> 
> so simply reverting it isn't a viable option either.
> 
> Is there any way in C to determine whether a typedef already exists?

Not AFAIK.

A common trick is
#ifndef type_t
#define type_t type_t
typedef int type_t;
#endif

But I think what I'll do instead is have xc_evtchn_compat.c
#define XC_BUILDING_COMPAT_EVTCHN_API and have xc_compat_evtchn.h DTRT
based on that. There's a similar construct
in XC_BUILDING_COMPAT_MAP_FOREIGN_API (although for different reasons).

Patch forthcoming.

Ian.
diff mbox

Patch

diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libxc/include/xenctrl_compat.h
index dc513a3..93ccadb 100644
--- a/tools/libxc/include/xenctrl_compat.h
+++ b/tools/libxc/include/xenctrl_compat.h
@@ -51,6 +51,7 @@  void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
 #ifdef XC_WANT_COMPAT_EVTCHN_API
 
 typedef struct xenevtchn_handle xc_evtchn;
+typedef xc_evtchn_port_or_error_t evtchn_port_or_error_t;
 
 xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
                              unsigned open_flags);