On Mon, May 23, 2011 at 07:36:10PM +0200, Matthias Bolte wrote:
Remove some special case code that took care of mapping hyper to the
correct C types.
Use macros for hyper to long assignments that perform overflow checks
when long is smaller than hyper. Also use such macros for the safe
hyper to longlong assignemts as this allows to keep the generator a
bit simpler.
+ } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+)\[\S+\];/) {
+ # error out on unannotated hypers
+ die "(unsigned)? hyper without (u)?(long|longlong) annotation:
$ret_member";
'hyper' in XDR world is a fixed 64 bit type, so IMHO, this
should automatically map to 'long long' in the API, without
requiring an annotation.
eg, we should only annotate if the public API uses the variable
sized 'long' / 'unsigned long' types in C.
+ } elsif ($ret_member =~ m/<\S+>;/ or $ret_member =~
m/\[\S+\];/) {
+ # just make all other array types fail
+ die "unhandled type for multi-return-value: $ret_member";
+ } elsif ($ret_member =~ m/^(unsigned )?(char|short|int) (\S+);/) {
+ return "$dst->$3 = $src.$3;";
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 2b9f9de..9928b77 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -371,7 +371,11 @@ struct remote_memory_param {
*
* 'remote_CALL_ret' members that are filled via call-by-reference must be
* annotated with a insert@<offset> comment to indicate the offset in the
- * parameter list of the function to be called. */
+ * parameter list of the function to be called.
+ *
+ * 'remote_CALL_args' and 'remote_CALL_ret' members of type hyper must
be
+ * annotated with the C type they should be mapped to: long, ulong, longlong
+ * or ulonglong */
struct remote_open_args {
/* NB. "name" might be NULL although in practice you can't
@@ -394,11 +398,11 @@ struct remote_get_type_ret {
};
struct remote_get_version_ret {
- unsigned hyper hv_ver;
+ unsigned hyper hv_ver; /* ulong */
};
struct remote_get_lib_version_ret {
- unsigned hyper lib_ver;
+ unsigned hyper lib_ver; /* ulong */
};
struct remote_get_hostname_ret {
@@ -430,7 +434,7 @@ struct remote_get_max_vcpus_ret {
struct remote_node_get_info_ret {
char model[32];
- unsigned hyper memory;
+ unsigned hyper memory; /* ulong */
int cpus;
int mhz;
int nodes;
@@ -449,11 +453,11 @@ struct remote_node_get_cells_free_memory_args {
};
struct remote_node_get_cells_free_memory_ret {
- unsigned hyper cells<REMOTE_NODE_MAX_CELLS>; /* insert@1 */
+ unsigned hyper cells<REMOTE_NODE_MAX_CELLS>; /* insert@1 ulonglong */
};
struct remote_node_get_free_memory_ret {
- unsigned hyper freeMem;
+ unsigned hyper freeMem; /* ulonglong */
};
struct remote_domain_get_scheduler_type_args {
@@ -525,11 +529,11 @@ struct remote_domain_block_stats_args {
};
struct remote_domain_block_stats_ret {
- hyper rd_req;
- hyper rd_bytes;
- hyper wr_req;
- hyper wr_bytes;
- hyper errs;
+ hyper rd_req; /* longlong */
+ hyper rd_bytes; /* longlong */
+ hyper wr_req; /* longlong */
+ hyper wr_bytes; /* longlong */
+ hyper errs; /* longlong */
};
struct remote_domain_interface_stats_args {
@@ -538,14 +542,14 @@ struct remote_domain_interface_stats_args {
};
struct remote_domain_interface_stats_ret {
- hyper rx_bytes;
- hyper rx_packets;
- hyper rx_errs;
- hyper rx_drop;
- hyper tx_bytes;
- hyper tx_packets;
- hyper tx_errs;
- hyper tx_drop;
+ hyper rx_bytes; /* longlong */
+ hyper rx_packets; /* longlong */
+ hyper rx_errs; /* longlong */
+ hyper rx_drop; /* longlong */
+ hyper tx_bytes; /* longlong */
+ hyper tx_packets; /* longlong */
+ hyper tx_errs; /* longlong */
+ hyper tx_drop; /* longlong */
};
struct remote_domain_memory_stats_args {
@@ -556,7 +560,7 @@ struct remote_domain_memory_stats_args {
struct remote_domain_memory_stat {
int tag;
- unsigned hyper val;
+ unsigned hyper val; /* longlong */
};
struct remote_domain_memory_stats_ret {
@@ -593,9 +597,9 @@ struct remote_domain_get_block_info_args {
};
struct remote_domain_get_block_info_ret {
- unsigned hyper allocation;
- unsigned hyper capacity;
- unsigned hyper physical;
+ unsigned hyper allocation; /* ulonglong */
+ unsigned hyper capacity; /* ulonglong */
+ unsigned hyper physical; /* ulonglong */
};
struct remote_list_domains_args {
@@ -677,22 +681,22 @@ struct remote_domain_get_max_memory_args {
};
struct remote_domain_get_max_memory_ret {
- unsigned hyper memory;
+ unsigned hyper memory; /* ulong */
};
struct remote_domain_set_max_memory_args {
remote_nonnull_domain dom;
- unsigned hyper memory;
+ unsigned hyper memory; /* ulong */
};
struct remote_domain_set_memory_args {
remote_nonnull_domain dom;
- unsigned hyper memory;
+ unsigned hyper memory; /* ulong */
};
struct remote_domain_set_memory_flags_args {
remote_nonnull_domain dom;
- unsigned hyper memory;
+ unsigned hyper memory; /* ulong */
unsigned int flags;
};
@@ -702,10 +706,10 @@ struct remote_domain_get_info_args {
struct remote_domain_get_info_ret {
unsigned char state;
- unsigned hyper maxMem;
- unsigned hyper memory;
+ unsigned hyper maxMem; /* ulong */
+ unsigned hyper memory; /* ulong */
unsigned short nrVirtCpu;
- unsigned hyper cpuTime;
+ unsigned hyper cpuTime; /* ulonglong */
};
struct remote_domain_save_args {
@@ -758,16 +762,16 @@ struct remote_domain_migrate_perform_args {
remote_nonnull_domain dom;
opaque cookie<REMOTE_MIGRATE_COOKIE_MAX>;
remote_nonnull_string uri;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
};
struct remote_domain_migrate_finish_args {
remote_nonnull_string dname;
opaque cookie<REMOTE_MIGRATE_COOKIE_MAX>;
remote_nonnull_string uri;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
};
struct remote_domain_migrate_finish_ret {
@@ -776,9 +780,9 @@ struct remote_domain_migrate_finish_ret {
struct remote_domain_migrate_prepare2_args {
remote_string uri_in;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
remote_nonnull_string dom_xml;
};
@@ -791,7 +795,7 @@ struct remote_domain_migrate_finish2_args {
remote_nonnull_string dname;
opaque cookie<REMOTE_MIGRATE_COOKIE_MAX>;
remote_nonnull_string uri;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
int retcode;
};
@@ -1328,9 +1332,9 @@ struct remote_storage_pool_get_info_args {
struct remote_storage_pool_get_info_ret {
unsigned char state;
- unsigned hyper capacity;
- unsigned hyper allocation;
- unsigned hyper available;
+ unsigned hyper capacity; /* ulonglong */
+ unsigned hyper allocation; /* ulonglong */
+ unsigned hyper available; /* ulonglong */
};
struct remote_storage_pool_get_autostart_args {
@@ -1438,8 +1442,8 @@ struct remote_storage_vol_get_info_args {
struct remote_storage_vol_get_info_ret {
char type;
- unsigned hyper capacity;
- unsigned hyper allocation;
+ unsigned hyper capacity; /* ulonglong */
+ unsigned hyper allocation; /* ulonglong */
};
struct remote_storage_vol_get_path_args {
@@ -1649,9 +1653,9 @@ struct remote_secret_lookup_by_usage_ret {
};
struct remote_domain_migrate_prepare_tunnel_args {
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
remote_nonnull_string dom_xml;
};
@@ -1756,20 +1760,20 @@ struct remote_domain_get_job_info_args {
struct remote_domain_get_job_info_ret {
int type;
- unsigned hyper timeElapsed;
- unsigned hyper timeRemaining;
+ unsigned hyper timeElapsed; /* ulonglong */
+ unsigned hyper timeRemaining; /* ulonglong */
- unsigned hyper dataTotal;
- unsigned hyper dataProcessed;
- unsigned hyper dataRemaining;
+ unsigned hyper dataTotal; /* ulonglong */
+ unsigned hyper dataProcessed; /* ulonglong */
+ unsigned hyper dataRemaining; /* ulonglong */
- unsigned hyper memTotal;
- unsigned hyper memProcessed;
- unsigned hyper memRemaining;
+ unsigned hyper memTotal; /* ulonglong */
+ unsigned hyper memProcessed; /* ulonglong */
+ unsigned hyper memRemaining; /* ulonglong */
- unsigned hyper fileTotal;
- unsigned hyper fileProcessed;
- unsigned hyper fileRemaining;
+ unsigned hyper fileTotal; /* ulonglong */
+ unsigned hyper fileProcessed; /* ulonglong */
+ unsigned hyper fileRemaining; /* ulonglong */
};
@@ -1780,13 +1784,13 @@ struct remote_domain_abort_job_args {
struct remote_domain_migrate_set_max_downtime_args {
remote_nonnull_domain dom;
- unsigned hyper downtime;
+ unsigned hyper downtime; /* ulonglong */
unsigned int flags;
};
struct remote_domain_migrate_set_max_speed_args {
remote_nonnull_domain dom;
- unsigned hyper bandwidth;
+ unsigned hyper bandwidth; /* ulong */
unsigned int flags;
};
@@ -1952,15 +1956,15 @@ struct remote_domain_open_console_args {
struct remote_storage_vol_upload_args {
remote_nonnull_storage_vol vol;
- unsigned hyper offset;
- unsigned hyper length;
+ unsigned hyper offset; /* ulonglong */
+ unsigned hyper length; /* ulonglong */
unsigned int flags;
};
struct remote_storage_vol_download_args {
remote_nonnull_storage_vol vol;
- unsigned hyper offset;
- unsigned hyper length;
+ unsigned hyper offset; /* ulonglong */
+ unsigned hyper length; /* ulonglong */
unsigned int flags;
};
@@ -1976,9 +1980,9 @@ struct remote_domain_get_state_ret {
struct remote_domain_migrate_begin3_args {
remote_nonnull_domain dom;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
};
struct remote_domain_migrate_begin3_ret {
@@ -1989,9 +1993,9 @@ struct remote_domain_migrate_begin3_ret {
struct remote_domain_migrate_prepare3_args {
opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
remote_string uri_in;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
remote_nonnull_string dom_xml;
};
@@ -2002,9 +2006,9 @@ struct remote_domain_migrate_prepare3_ret {
struct remote_domain_migrate_prepare_tunnel3_args {
opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
remote_nonnull_string dom_xml;
};
@@ -2016,9 +2020,9 @@ struct remote_domain_migrate_perform3_args {
remote_nonnull_domain dom;
opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
remote_nonnull_string uri;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
remote_string dname;
- unsigned hyper resource;
+ unsigned hyper resource; /* ulong */
};
struct remote_domain_migrate_perform3_ret {
@@ -2029,7 +2033,7 @@ struct remote_domain_migrate_finish3_args {
remote_nonnull_string dname;
opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
remote_nonnull_string uri;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
int cancelled;
};
@@ -2041,7 +2045,7 @@ struct remote_domain_migrate_finish3_ret {
struct remote_domain_migrate_confirm3_args {
remote_nonnull_domain dom;
opaque cookie_in<REMOTE_MIGRATE_COOKIE_MAX>;
- unsigned hyper flags;
+ unsigned hyper flags; /* ulong */
int cancelled;
};
All the 'longlong' and 'ulonglong' annotations should
be removed here IMHO, since they should be the default
for hyper/unsigned hyper.
Regards,
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|