tools: libxc: do not redefine evtchn_port_or_error_t in xc_evtchn_compat.c
PATCH 1/1 tools: libxc: do not redefine evtchn_port_or_error_t in xc_evtchn_compat.c
This file stradles the xenevtchn and libxc evtchn_compat worlds, and hence ends up with two evtchn_port_or_error_t typedefs which older gcc's (and the C standard) do not like.
Avoid this by gating the compat definition on a gate provided by the compat implementation.
Note that this would still be broken by an application which does:
#define XC_WANT_COMPAT_EVTCHN_API
#include <xenevtchn.h>
#include <xenctrl.h>Which effectively means that an application must be ported over to xenevtchn in one go rather than incrementally (e.g. if it uses evtchn's for multiple purposes). Since the port is actually fairly mechanical I hope this is acceptable.
---
I'm not super happy about this approach, due to the caveat in the second half of the commit message.
Other approaches:
rename the libxenevtchn type, e.g. xenevtchn_port_or_error_t?
Some sort of skank based on the header guard #defines, but that's awful (and fragile).
--- tools/libxc/include/xenctrl_compat.h | 2 ++ tools/libxc/xc_evtchn_compat.c | 1 + 2 files changed, 3 insertions(+)
tools/libxc/include/xenctrl_compat.h +2 -0
@@ -51,7 +51,9 @@ 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 ; +#ifndef XC_BUILDING_COMPAT_EVTCHN_API typedef xc_evtchn_port_or_error_t evtchn_port_or_error_t ; +#endif xc_evtchn *xc_evtchn_open (xentoollog_logger *logger,unsigned open_flags);
tools/libxc/xc_evtchn_compat.c +1 -0
@@ -6,6 +6,7 @@#include <xenevtchn.h> #define XC_WANT_COMPAT_EVTCHN_API +#define XC_BUILDING_COMPAT_EVTCHN_API #include "xenctrl.h" xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
Signature · 1 line
2.1.4
Adding Olaf, I forgot that Reported-by doesn't turn into a Cc.
Quoted 20 lines · Ian Campbell
This file stradles the xenevtchn and libxc
evtchn_compatworlds, and hence ends up with twoevtchn_port_or_error_ttypedefs which older gcc's (and the C standard) do not like.Avoid this by gating the compat definition on a gate provided by the compat implementation.
Note that this would still be broken by an application which does:
#defineXC_WANT_COMPAT_EVTCHN_API
#include <xenevtchn.h>
#include <xenctrl.h>Which effectively means that an application must be ported over to xenevtchn in one go rather than incrementally (e.g. if it uses evtchn's for multiple purposes). Since the port is actually fairly mechanical I hope this is acceptable.
Reported-by Olaf Hering <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Andrew Cooper <[email protected]>
Quoted 7 lines
---
I'm not super happy about this approach, due to the caveat in the second half of the commit message.Other approaches:
rename the libxenevtchn type, e.g. xenevtchn_port_or_error_t?
Thinking about this some more this might be the best approach. The type is not used by qemu-xen, it is used by qemu-xen-traditional but we can fix that in lockstep.
All of the in tree users are easy, of course.
Thoughts?
Quoted 31 lines
Some sort of skank based on the header guard #defines, but that's awful (and fragile).
---
tools/libxc/include/xenctrl_compat.h | 2 ++ tools/libxc/xc_evtchn_compat.c | 1 +2 files changed, 3 insertions(+)tools/libxc/include/xenctrl_compat.h +0
-0@@ -51,7 +51,9 @@ void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot, #ifdef XC_WANT_COMPAT_EVTCHN_API
typedef structxenevtchn_handlexc_evtchn; +#ifndefXC_BUILDING_COMPAT_EVTCHN_API
typedefxc_evtchn_port_or_error_tevtchn_port_or_error_t; +#endif
xc_evtchn *xc_evtchn_open(xentoollog_logger *logger, unsignedopen_flags);tools/libxc/xc_evtchn_compat.c +0
-0@@ -6,6 +6,7 @@ #include <xenevtchn.h>
Quoted 6 lines
#defineXC_WANT_COMPAT_EVTCHN_API
+#defineXC_BUILDING_COMPAT_EVTCHN_API#include "xenctrl.h"
xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 29 lines · Ian Campbell
Adding Olaf, I forgot that Reported-by doesn't turn into a Cc.
Quoted 26 lines · Ian Campbell
This file stradles the xenevtchn and libxc
evtchn_compatworlds, and hence ends up with twoevtchn_port_or_error_ttypedefs which older gcc's (and the C standard) do not like.Avoid this by gating the compat definition on a gate provided by the compat implementation.
Note that this would still be broken by an application which does:
#define XC_WANT_COMPAT_EVTCHN_API #include <xenevtchn.h> #include <xenctrl.h>Which effectively means that an application must be ported over to xenevtchn in one go rather than incrementally (e.g. if it uses evtchn's for multiple purposes). Since the port is actually fairly mechanical I hope this is acceptable.
Reported-by Olaf Hering <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Andrew Cooper <[email protected]>---
I'm not super happy about this approach, due to the caveat in the second half of the commit message.Other approaches:
Quoted 8 lines
Quoted 1 line
rename the libxenevtchn type, e.g.
xenevtchn_port_or_error_t?Thinking about this some more this might be the best approach. The type is not used by qemu-xen, it is used by qemu-xen-traditional but we can fix that in lockstep.
All of the in tree users are easy, of course.
Thoughts?
Thinking about it, this looks like a better option. It is also more in line with the library naming.
~Andrew
Quoted 31 lines · Ian Campbell
Adding Olaf, I forgot that Reported-by doesn't turn into a Cc.
Quoted 20 lines · Ian Campbell
This file stradles the xenevtchn and libxc
evtchn_compatworlds, and hence ends up with twoevtchn_port_or_error_ttypedefs which older gcc's (and the C standard) do not like.Avoid this by gating the compat definition on a gate provided by the compat implementation.
Note that this would still be broken by an application which does:
#defineXC_WANT_COMPAT_EVTCHN_API
#include <xenevtchn.h>
#include <xenctrl.h>Which effectively means that an application must be ported over to xenevtchn in one go rather than incrementally (e.g. if it uses evtchn's for multiple purposes). Since the port is actually fairly mechanical I hope this is acceptable.
Reported-by Olaf Hering <[email protected]>Signed-off-by Ian Campbell <[email protected]>Cc Andrew Cooper <[email protected]>Quoted 7 lines
---
I'm not super happy about this approach, due to the caveat in the second half of the commit message.Other approaches:
rename the libxenevtchn type, e.g. xenevtchn_port_or_error_t?
Quoted 8 lines
Thinking about this some more this might be the best approach. The type is not used by qemu-xen, it is used by qemu-xen-traditional but we can fix that in lockstep.
All of the in tree users are easy, of course.
Thoughts?
+1 for this
Quoted 1 line · Ian Campbell
Reported-by Olaf Hering <[email protected]>
be05b53 + this change can be compiled in SLE11 and SLE12. Thanks.
Olaf