Skip to contentSkip to conversation

xenctrl: Make the headers C++ friendly

PATCH In review Razvan Cojocaru 4 participants 6 messages Jul 2, 2014 – Jul 16, 2014

lore
Share & tools
lore
#0 lore raw

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
index af6f249..abd8947 100644
@@ -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
#1 lore raw
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

#2 lore raw
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_page
xc_domain_decrease_reservation_exact
xc_domain_get_tsc_info
xc_domain_getinfo
xc_domain_hvm_getcontext_partial
xc_domain_pause
xc_domain_populate_physmap_exact
xc_domain_set_access_required
xc_domain_set_pagefault_info
xc_domain_shutdown
xc_domain_unpause
xc_evtchn_bind_interdomain
xc_evtchn_close
xc_evtchn_fd
xc_evtchn_notify
xc_evtchn_open
xc_evtchn_pending
xc_evtchn_unbind
xc_evtchn_unmask
xc_get_hvm_param
xc_get_mem_access
xc_interface_close
xc_interface_open
xc_map_foreign_batch
xc_map_foreign_range
xc_mem_access_disable
xc_mem_access_enable
xc_mem_access_resume
xc_set_hvm_param
xc_set_mem_access
xc_translate_foreign_address
xc_vcpu_getcontext
xc_vcpu_setcontext
xc_version
xs_close
xs_directory
xs_fileno
xs_is_domain_introduced
xs_open
xs_read
xs_read_watch
xs_unwatch
xs_watch

Libxl is, unfortunately, too high-level for our needs.

Thanks,
Razvan Cojocaru

#3 lore raw
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
index 13f816b..37031ad 100644
@@ -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