Razvan Cojocaru
2013-Jan-23 15:46 UTC
[PATCH 1 of 2 V4] libxc, libxenstore: make the headers C++-friendlier
Made the xenctrl.h and xenstore.h easier to use with C++:
added ''extern "C"'' statements, moved the definition
of
enum xc_error_code above it''s typedef.
Signed-off-by: Razvan Cojocaru <rzvncj@gmail.com>
diff -r 5af4f2ab06f3 -r 3a9979cf50f3 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Tue Jan 22 09:33:10 2013 +0100
+++ b/tools/libxc/xenctrl.h Wed Jan 23 17:27:20 2013 +0200
@@ -26,6 +26,10 @@
#ifndef XENCTRL_H
#define XENCTRL_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Tell the Xen public headers we are a user-space tools build. */
#ifndef __XEN_TOOLS__
#define __XEN_TOOLS__ 1
@@ -114,6 +118,15 @@ typedef struct xc_interface_core xc_inte
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;
@@ -1618,16 +1631,6 @@ int xc_hvm_inject_trap(
* LOGGING AND ERROR REPORTING
*/
-
-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;
@@ -2236,4 +2239,8 @@ int xc_compression_uncompress_page(xc_in
unsigned long compbuf_size,
unsigned long *compbuf_pos, char *dest);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* XENCTRL_H */
diff -r 5af4f2ab06f3 -r 3a9979cf50f3 tools/xenstore/xenstore.h
--- a/tools/xenstore/xenstore.h Tue Jan 22 09:33:10 2013 +0100
+++ b/tools/xenstore/xenstore.h Wed Jan 23 17:27:20 2013 +0200
@@ -20,6 +20,10 @@
#ifndef XENSTORE_H
#define XENSTORE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <xenstore_lib.h>
#define XBT_NULL 0
@@ -244,6 +248,11 @@ char *xs_debug_command(struct xs_handle
void *data, unsigned int len);
int xs_suspend_evtchn_port(int domid);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* XENSTORE_H */
/*
Prevent the compiler from re-ordering the reads and writes.
Suggested by Jan Beulich.
Signed-off-by: Razvan Cojocaru <rzvncj@gmail.com>
diff -r 3a9979cf50f3 -r 550e437674c7 xen/include/public/arch-x86/hvm/save.h
--- a/xen/include/public/arch-x86/hvm/save.h Wed Jan 23 17:27:20 2013 +0200
+++ b/xen/include/public/arch-x86/hvm/save.h Wed Jan 23 17:44:20 2013 +0200
@@ -269,15 +269,20 @@ struct hvm_hw_cpu_compat {
};
static inline int _hvm_hw_fix_cpu(void *h) {
- struct hvm_hw_cpu *new=h;
- struct hvm_hw_cpu_compat *old=h;
+
+ union hvm_hw_cpu_union {
+ struct hvm_hw_cpu nat;
+ struct hvm_hw_cpu_compat cmp;
+ };
+
+ union hvm_hw_cpu_union *ucpu = (union hvm_hw_cpu_union *)h;;
/* If we copy from the end backwards, we should
* be able to do the modification in-place */
- new->error_code=old->error_code;
- new->pending_event=old->pending_event;
- new->tsc=old->tsc;
- new->msr_tsc_aux=0;
+ ucpu->nat.error_code = ucpu->cmp.error_code;
+ ucpu->nat.pending_event = ucpu->cmp.pending_event;
+ ucpu->nat.tsc = ucpu->cmp.tsc;
+ ucpu->nat.msr_tsc_aux = 0;
return 0;
}
At 17:46 +0200 on 23 Jan (1358963209), Razvan Cojocaru wrote:> Prevent the compiler from re-ordering the reads and writes. > Suggested by Jan Beulich. > > Signed-off-by: Razvan Cojocaru <rzvncj@gmail.com>Acked-by: Tim Deegan <tim@xen.org>> diff -r 3a9979cf50f3 -r 550e437674c7 xen/include/public/arch-x86/hvm/save.h > --- a/xen/include/public/arch-x86/hvm/save.h Wed Jan 23 17:27:20 2013 +0200 > +++ b/xen/include/public/arch-x86/hvm/save.h Wed Jan 23 17:44:20 2013 +0200 > @@ -269,15 +269,20 @@ struct hvm_hw_cpu_compat { > }; > > static inline int _hvm_hw_fix_cpu(void *h) { > - struct hvm_hw_cpu *new=h; > - struct hvm_hw_cpu_compat *old=h; > + > + union hvm_hw_cpu_union { > + struct hvm_hw_cpu nat; > + struct hvm_hw_cpu_compat cmp; > + }; > + > + union hvm_hw_cpu_union *ucpu = (union hvm_hw_cpu_union *)h;; > > /* If we copy from the end backwards, we should > * be able to do the modification in-place */ > - new->error_code=old->error_code; > - new->pending_event=old->pending_event; > - new->tsc=old->tsc; > - new->msr_tsc_aux=0; > + ucpu->nat.error_code = ucpu->cmp.error_code; > + ucpu->nat.pending_event = ucpu->cmp.pending_event; > + ucpu->nat.tsc = ucpu->cmp.tsc; > + ucpu->nat.msr_tsc_aux = 0; > > return 0; > } > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel
On 24/01/2013 12:12, "Tim Deegan" <tim@xen.org> wrote:> At 17:46 +0200 on 23 Jan (1358963209), Razvan Cojocaru wrote: >> Prevent the compiler from re-ordering the reads and writes. >> Suggested by Jan Beulich. >> >> Signed-off-by: Razvan Cojocaru <rzvncj@gmail.com> > > Acked-by: Tim Deegan <tim@xen.org>Acked-by: Keir Fraser <keir@xen.org>>> diff -r 3a9979cf50f3 -r 550e437674c7 xen/include/public/arch-x86/hvm/save.h >> --- a/xen/include/public/arch-x86/hvm/save.h Wed Jan 23 17:27:20 2013 +0200 >> +++ b/xen/include/public/arch-x86/hvm/save.h Wed Jan 23 17:44:20 2013 +0200 >> @@ -269,15 +269,20 @@ struct hvm_hw_cpu_compat { >> }; >> >> static inline int _hvm_hw_fix_cpu(void *h) { >> - struct hvm_hw_cpu *new=h; >> - struct hvm_hw_cpu_compat *old=h; >> + >> + union hvm_hw_cpu_union { >> + struct hvm_hw_cpu nat; >> + struct hvm_hw_cpu_compat cmp; >> + }; >> + >> + union hvm_hw_cpu_union *ucpu = (union hvm_hw_cpu_union *)h;; >> >> /* If we copy from the end backwards, we should >> * be able to do the modification in-place */ >> - new->error_code=old->error_code; >> - new->pending_event=old->pending_event; >> - new->tsc=old->tsc; >> - new->msr_tsc_aux=0; >> + ucpu->nat.error_code = ucpu->cmp.error_code; >> + ucpu->nat.pending_event = ucpu->cmp.pending_event; >> + ucpu->nat.tsc = ucpu->cmp.tsc; >> + ucpu->nat.msr_tsc_aux = 0; >> >> return 0; >> } >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xen.org >> http://lists.xen.org/xen-devel > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel