xenctrl: Make the headers C++ friendly
PATCH 1/1 xenctrl: Make the headers C++ friendly
Moved an enum definition before the typedef that uses it.
--- tools/libxc/xenctrl.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
tools/libxc/xenctrl.h +10 -9
@@ -119,6 +119,16 @@ typedef struct xc_interface_core xc_interface;typedef struct xc_interface_core xc_evtchn ;typedef struct xc_interface_core xc_gnttab ;typedef struct xc_interface_core xc_gntshr ; + +enum xc_error_code { +XC_ERROR_NONE =0 , +XC_INTERNAL_ERROR =1 , +XC_INVALID_KERNEL =2 , +XC_INVALID_PARAM =3 , +XC_OUT_OF_MEMORY =4 , +/* new codes need to be added to xc_error_level_to_desc too */ +}; +typedef enum xc_error_code xc_error_code ;
@@ -1766,15 +1776,6 @@ int xc_hvm_inject_trap(*/ -enum xc_error_code { -XC_ERROR_NONE =0 , -XC_INTERNAL_ERROR =1 , -XC_INVALID_KERNEL =2 , -XC_INVALID_PARAM =3 , -XC_OUT_OF_MEMORY =4 , -/* new codes need to be added to xc_error_level_to_desc too */ -}; -#define XC_MAX_ERROR_MSG_LEN 1024 typedef struct xc_error { enum xc_error_code code;
Signature · 1 line
1.7.9.5
Quoted 1 line · Razvan Cojocaru
Moved an enum definition before the typedef that uses it.
Presumably you want this because you have an out-of-tree program that you want to compile against libxc. You do realize that libxc isn't a stable API, right? That it may change in incompatible ways in every release?
I presume you'd rather use a stable API -- in which case maybe we should ask what it is your application needs, and we can try to come up with a way to support you. (Perhaps by declaring certain parts of the libxc interface as "stable", if libxl isn't suitable for some reason.)
-George
Quoted 8 lines · George Dunlap
Quoted 1 line · Razvan Cojocaru
Moved an enum definition before the typedef that uses it.
Presumably you want this because you have an out-of-tree program that you want to compile against libxc. You do realize that libxc isn't a stable API, right? That it may change in incompatible ways in every release?
Yes, I've glimpsed into that by following it since Xen 4.1. I am indeed compiling an application against libxc.
Quoted 5 lines
I presume you'd rather use a stable API -- in which case maybe we should ask what it is your application needs, and we can try to come up with a way to support you. (Perhaps by declaring certain parts of the libxc interface as "stable", if libxl isn't suitable for some reason.)
Thanks, that's a very gracious offer. Well, here's what nm has to say about what I'm using from the Xen libraries:
xc_copy_to_domain_pagexc_domain_decrease_reservation_exactxc_domain_get_tsc_infoxc_domain_getinfoxc_domain_hvm_getcontext_partialxc_domain_pausexc_domain_populate_physmap_exactxc_domain_set_access_requiredxc_domain_set_pagefault_infoxc_domain_shutdownxc_domain_unpausexc_evtchn_bind_interdomainxc_evtchn_closexc_evtchn_fdxc_evtchn_notifyxc_evtchn_openxc_evtchn_pendingxc_evtchn_unbindxc_evtchn_unmaskxc_get_hvm_paramxc_get_mem_accessxc_interface_closexc_interface_openxc_map_foreign_batchxc_map_foreign_rangexc_mem_access_disablexc_mem_access_enablexc_mem_access_resumexc_set_hvm_paramxc_set_mem_accessxc_translate_foreign_addressxc_vcpu_getcontextxc_vcpu_setcontextxc_versionxs_closexs_directoryxs_filenoxs_is_domain_introducedxs_openxs_readxs_read_watchxs_unwatchxs_watch
Libxl is, unfortunately, too high-level for our needs.
Thanks,
Razvan Cojocaru
Quoted 10 lines · Razvan Cojocaru
Quoted 7 lines · George Dunlap
Quoted 1 line · Razvan Cojocaru
Moved an enum definition before the typedef that uses it.
Presumably you want this because you have an out-of-tree program that you want to compile against libxc. You do realize that libxc isn't a stable API, right? That it may change in incompatible ways in every release?
Yes, I've glimpsed into that by following it since Xen 4.1. I am indeed compiling an application against libxc.
I also have one that is both libxc and libxl in c++. I fixed it by moving the
typedef:
tools/libxc/xenctrl.h +2 -3
@@ -119,7 +119,6 @@ typedef struct xc_interface_core xc_interface;typedef struct xc_interface_core xc_evtchn ;typedef struct xc_interface_core xc_gnttab ;typedef struct xc_interface_core xc_gntshr ; -typedef enum xc_error_code xc_error_code ;/*
@@ -1756,14 +1755,14 @@ int xc_hvm_inject_trap(*/ -enum xc_error_code { +typedef enum xc_error_code {XC_ERROR_NONE =0 ,XC_INTERNAL_ERROR =1 ,XC_INVALID_KERNEL =2 ,XC_INVALID_PARAM =3 ,XC_OUT_OF_MEMORY =4 ,/* new codes need to be added to xc_error_level_to_desc too */ -}; +}xc_error_code ;#define XC_MAX_ERROR_MSG_LEN 1024 typedef struct xc_error {
So I would like to see either of these done.
Quoted 5 lines
Quoted 5 lines
I presume you'd rather use a stable API -- in which case maybe we should ask what it is your application needs, and we can try to come up with a way to support you. (Perhaps by declaring certain parts of the libxc interface as "stable", if libxl isn't suitable for some reason.)
I have no need for a stable API; but it might allow the C++ code to not include this file from /usr/include/xenctrl.h
-Don Slutz
Quoted 4 lines · Razvan Cojocaru
Moved an enum definition before the typedef that uses it.
Signed-off-by Razvan Cojocaru <[email protected]>Reviewed-by Andrew Cooper <[email protected]>
Previously the idea of C++ifying the headers has been controversial but this particular patch seems OK.
Acked + applied.
Ian.
Quoted 10 lines · Ian Campbell
Quoted 4 lines · Razvan Cojocaru
Moved an enum definition before the typedef that uses it.
Signed-off-by Razvan Cojocaru <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Previously the idea of C++ifying the headers has been controversial but this particular patch seems OK.
Acked + applied.
Thanks!